2023-05-11 23:46:25 +03:00
|
|
|
#ifndef SERVER_H
|
|
|
|
#define SERVER_H
|
|
|
|
|
|
|
|
#include "chatllm.h"
|
2024-06-04 21:47:11 +03:00
|
|
|
#include "database.h"
|
2023-05-11 23:46:25 +03:00
|
|
|
|
2024-06-06 18:59:28 +03:00
|
|
|
#include <QHttpServerRequest>
|
2024-06-04 21:47:11 +03:00
|
|
|
#include <QHttpServerResponse>
|
2023-05-11 23:46:25 +03:00
|
|
|
#include <QObject>
|
2024-06-04 21:47:11 +03:00
|
|
|
#include <QList>
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
class Chat;
|
|
|
|
class QHttpServer;
|
2023-05-11 23:46:25 +03:00
|
|
|
|
|
|
|
class Server : public ChatLLM
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
Server(Chat *parent);
|
|
|
|
virtual ~Server();
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void start();
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void requestServerNewPromptResponsePair(const QString &prompt);
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
QHttpServerResponse handleCompletionRequest(const QHttpServerRequest &request, bool isChat);
|
2023-06-20 01:23:54 +03:00
|
|
|
void handleDatabaseResultsChanged(const QList<ResultInfo> &results) { m_databaseResults = results; }
|
2023-06-20 02:51:28 +03:00
|
|
|
void handleCollectionListChanged(const QList<QString> &collectionList) { m_collections = collectionList; }
|
2023-05-11 23:46:25 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
Chat *m_chat;
|
|
|
|
QHttpServer *m_server;
|
2023-06-20 01:23:54 +03:00
|
|
|
QList<ResultInfo> m_databaseResults;
|
2023-06-20 02:51:28 +03:00
|
|
|
QList<QString> m_collections;
|
2023-05-11 23:46:25 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SERVER_H
|