wxMaxima
Loading...
Searching...
No Matches
AiChatSidebar.h
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2//
3// Copyright (C) 2026 Gunter Königsmann <wxMaxima@physikbuch.de>
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19//
20// SPDX-License-Identifier: GPL-2.0+
21
22#ifndef AICHATSIDEBAR_H
23#define AICHATSIDEBAR_H
24
25#include "precomp.h"
26#include "ai/AiProvider.h"
27#include "mcp/McpTools.h"
28#include <wx/wx.h>
29#include <memory>
30#include <vector>
31
32class Configuration;
33class Worksheet;
34class Variablespane;
35
58class AiChatSidebar : public wxPanel {
59public:
60 AiChatSidebar(wxWindow *parent, Configuration *configuration,
61 Worksheet *worksheet, Variablespane *variablesPane,
62 wxWindowID id = wxID_ANY);
63
70
72 void ClearConversation();
73
74private:
75 void OnSend(wxCommandEvent &event);
76 void OnInputKeyDown(wxKeyEvent &event);
85 void OnOpenOptions(wxCommandEvent &event);
86 void AppendToHistory(const wxString &speaker, const wxString &text);
87 void SetBusy(bool busy);
91 wxString BuildContextSnapshot() const;
92 void UpdateStatusText();
93
94 Configuration *m_configuration;
95 McpTools m_tools;
96 std::shared_ptr<AiProvider> m_provider;
97 std::vector<AiChatMessage> m_history;
98 bool m_requestInFlight = false;
99
100 wxTextCtrl *m_historyCtrl;
101 wxTextCtrl *m_inputCtrl;
102 wxButton *m_sendButton;
103 wxButton *m_clearButton;
104 wxStaticText *m_statusText;
105 wxButton *m_openOptionsButton;
106
112 static constexpr std::size_t MAX_CONTEXT_LENGTH = 8000;
113};
114
115#endif // AICHATSIDEBAR_H
Talks to one of a handful of external AI chat APIs for the AI chat sidebar (AiChatSidebar).
A sidebar to chat with an external AI about the current worksheet (follow-up to the MCP server,...
Definition: AiChatSidebar.h:58
void ReloadProviderFromConfig()
Re-reads Configuration for the selected provider/API key/model and rebuilds this sidebar's provider a...
Definition: AiChatSidebar.cpp:93
void ClearConversation()
Clears the conversation history (but not the provider/API key setup).
Definition: AiChatSidebar.cpp:147
The configuration storage for the current worksheet.
Definition: Configuration.h:98
Implements the read-only "worksheet context" tools the MCP server exposes to an external AI tool (GH ...
Definition: McpTools.h:70
A "variables" sidepane.
Definition: VariablesPane.h:45
The canvas that contains the spreadsheet the whole program is about.
Definition: Worksheet.h:116