3#include <QNetworkAccessManager>
35 return m_ThreadProxyList.get();
39 [[nodiscard]] QString
model()
const;
41 [[nodiscard]] QStringList
modelList()
const {
return m_ModelList; }
68 void sendMessage(
const int index,
const QString &prompt);
92 QScopedPointer<QNetworkAccessManager> m_Manager{
new QNetworkAccessManager};
93 QScopedPointer<ThreadList> m_ThreadList{
new ThreadList};
94 QScopedPointer<ThreadProxyList> m_ThreadProxyList{
new ThreadProxyList};
95 QList<QString> m_ModelList;
100 void sendRequestToOllama(Thread *thread,
const QString &prompt);
104 void handleStreamResponse(Thread *thread, QNetworkReply *reply)
const;
The ChatBackend class handles the communication with the Ollama server.
Definition backend.h:15
void newThreadCreated()
Emitted when the current thread is changed.
void setModel(const QString &model)
Sets the model name.
Definition backend.cpp:137
ThreadList * threadList() const
Returns the chat threads.
Definition backend.h:31
QStringList modelList
Definition backend.h:19
void ollamaServerUrlChanged()
Emitted when the ollama server url is changed.
void deleteThread(const int index)
Removes the thread at the given index.
Definition backend.cpp:169
void modelChanged()
Emitted when the model is changed.
ThreadProxyList * sortedThreads
Definition backend.h:17
ThreadProxyList * threadProxyList() const
Returns the sorted chat threads.
Definition backend.h:34
void setSystemPrompt(const QString &prompt)
Set the system prompt.
Definition backend.cpp:182
void systemPromptChanged()
Emitted when the system prompt is changed.
QString systemPrompt
Definition backend.h:21
void fetchModelList()
Fetches the list of available models from the Ollama server.
Definition backend.cpp:144
Thread * getThread(const int index)
Returns the thread at the given index.
Definition backend.cpp:162
void setOllamaServerUrl(const QString &url)
Set the ollama server url.
Definition backend.cpp:193
void sendMessage(const int index, const QString &prompt)
Sends a message to the Ollama server.
Definition backend.cpp:22
QString model
Definition backend.h:18
void clearThreads()
Removes all the threads.
Definition backend.cpp:176
void retryLatestMessage(const int index)
Retries the latest message.
Definition backend.cpp:201
QString ollamaServerUrl
Definition backend.h:23
void modelListFetched()
Emitted when the list of models is fetched.
QStringList modelList() const
Get the list of available models.
Definition backend.h:41
The ThreadList class provides a model for the chat threads.
Definition thread_list.h:10
The ThreadProxyList class provides a sorted model for the chat.
Definition thread_proxy_list.h:8
The Thread class provides a model for the chat interface.
Definition thread.h:13
Definition backend.cpp:11