mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-09-06 19:10:15 +00:00
chat: major UI redesign for v3.0.0 (#2396)
Signed-off-by: Adam Treat <treat.adam@gmail.com> Signed-off-by: Jared Van Bortel <jared@nomic.ai> Co-authored-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#define EMBLLM_H
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
@@ -16,6 +17,7 @@ class LLModel;
|
||||
class QNetworkAccessManager;
|
||||
|
||||
struct EmbeddingChunk {
|
||||
QString model; // TODO(jared): use to select model
|
||||
int folder_id;
|
||||
int chunk_id;
|
||||
QString chunk;
|
||||
@@ -24,6 +26,7 @@ struct EmbeddingChunk {
|
||||
Q_DECLARE_METATYPE(EmbeddingChunk)
|
||||
|
||||
struct EmbeddingResult {
|
||||
QString model;
|
||||
int folder_id;
|
||||
int chunk_id;
|
||||
std::vector<float> embedding;
|
||||
@@ -33,32 +36,33 @@ class EmbeddingLLMWorker : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
EmbeddingLLMWorker();
|
||||
virtual ~EmbeddingLLMWorker();
|
||||
~EmbeddingLLMWorker() override;
|
||||
|
||||
void wait();
|
||||
|
||||
std::vector<float> lastResponse() const { return m_lastResponse; }
|
||||
|
||||
bool loadModel();
|
||||
bool hasModel() const;
|
||||
bool isNomic() const;
|
||||
bool isNomic() const { return !m_nomicAPIKey.isEmpty(); }
|
||||
bool hasModel() const { return isNomic() || m_model; }
|
||||
|
||||
std::vector<float> generateSyncEmbedding(const QString &text);
|
||||
std::vector<float> generateQueryEmbedding(const QString &text);
|
||||
|
||||
public Q_SLOTS:
|
||||
void requestSyncEmbedding(const QString &text);
|
||||
void requestAsyncEmbedding(const QVector<EmbeddingChunk> &chunks);
|
||||
void atlasQueryEmbeddingRequested(const QString &text);
|
||||
void docEmbeddingsRequested(const QVector<EmbeddingChunk> &chunks);
|
||||
|
||||
Q_SIGNALS:
|
||||
void requestAtlasQueryEmbedding(const QString &text);
|
||||
void embeddingsGenerated(const QVector<EmbeddingResult> &embeddings);
|
||||
void errorGenerated(int folder_id, const QString &error);
|
||||
void errorGenerated(const QVector<EmbeddingChunk> &chunks, const QString &error);
|
||||
void finished();
|
||||
|
||||
private Q_SLOTS:
|
||||
void handleFinished();
|
||||
|
||||
private:
|
||||
void sendAtlasRequest(const QStringList &texts, const QString &taskType, QVariant userData = {});
|
||||
void sendAtlasRequest(const QStringList &texts, const QString &taskType, const QVariant &userData = {});
|
||||
|
||||
QString m_nomicAPIKey;
|
||||
QNetworkAccessManager *m_networkManager;
|
||||
@@ -66,6 +70,7 @@ private:
|
||||
LLModel *m_model = nullptr;
|
||||
std::atomic<bool> m_stopGenerating;
|
||||
QThread m_workerThread;
|
||||
QMutex m_mutex; // guards m_model and m_nomicAPIKey
|
||||
};
|
||||
|
||||
class EmbeddingLLM : public QObject
|
||||
@@ -73,20 +78,20 @@ class EmbeddingLLM : public QObject
|
||||
Q_OBJECT
|
||||
public:
|
||||
EmbeddingLLM();
|
||||
virtual ~EmbeddingLLM();
|
||||
~EmbeddingLLM() override;
|
||||
|
||||
static QString model();
|
||||
bool loadModel();
|
||||
bool hasModel() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
std::vector<float> generateEmbeddings(const QString &text); // synchronous
|
||||
void generateAsyncEmbeddings(const QVector<EmbeddingChunk> &chunks);
|
||||
std::vector<float> generateQueryEmbedding(const QString &text); // synchronous
|
||||
void generateDocEmbeddingsAsync(const QVector<EmbeddingChunk> &chunks);
|
||||
|
||||
Q_SIGNALS:
|
||||
void requestSyncEmbedding(const QString &text);
|
||||
void requestAsyncEmbedding(const QVector<EmbeddingChunk> &chunks);
|
||||
void requestDocEmbeddings(const QVector<EmbeddingChunk> &chunks);
|
||||
void embeddingsGenerated(const QVector<EmbeddingResult> &embeddings);
|
||||
void errorGenerated(int folder_id, const QString &error);
|
||||
void errorGenerated(const QVector<EmbeddingChunk> &chunks, const QString &error);
|
||||
|
||||
private:
|
||||
EmbeddingLLMWorker *m_embeddingWorker;
|
||||
|
Reference in New Issue
Block a user