chat: generate follow-up questions after response (#2634)

* user can configure the prompt and when they appear
* also make the name generation prompt configurable

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:
AT
2024-07-10 15:45:20 -04:00
committed by GitHub
parent ef4e362d92
commit 66bc04aa8e
14 changed files with 621 additions and 138 deletions

View File

@@ -39,6 +39,7 @@ class Chat : public QObject
Q_PROPERTY(LocalDocsCollectionsModel *collectionModel READ collectionModel NOTIFY collectionModelChanged)
// 0=no, 1=waiting, 2=working
Q_PROPERTY(int trySwitchContextInProgress READ trySwitchContextInProgress NOTIFY trySwitchContextInProgressChanged)
Q_PROPERTY(QList<QString> generatedQuestions READ generatedQuestions NOTIFY generatedQuestionsChanged)
QML_ELEMENT
QML_UNCREATABLE("Only creatable from c++!")
@@ -48,6 +49,7 @@ public:
LocalDocsRetrieval,
LocalDocsProcessing,
PromptProcessing,
GeneratingQuestions,
ResponseGeneration
};
Q_ENUM(ResponseState)
@@ -119,6 +121,8 @@ public:
int trySwitchContextInProgress() const { return m_trySwitchContextInProgress; }
QList<QString> generatedQuestions() const { return m_generatedQuestions; }
public Q_SLOTS:
void serverNewPromptResponsePair(const QString &prompt);
@@ -153,13 +157,16 @@ Q_SIGNALS:
void collectionModelChanged();
void trySwitchContextInProgressChanged();
void loadedModelInfoChanged();
void generatedQuestionsChanged();
private Q_SLOTS:
void handleResponseChanged(const QString &response);
void handleModelLoadingPercentageChanged(float);
void promptProcessing();
void generatingQuestions();
void responseStopped(qint64 promptResponseMs);
void generatedNameChanged(const QString &name);
void generatedQuestionFinished(const QString &question);
void handleRecalculating();
void handleModelLoadingError(const QString &error);
void handleTokenSpeedChanged(const QString &tokenSpeed);
@@ -179,6 +186,7 @@ private:
QString m_fallbackReason;
QString m_response;
QList<QString> m_collections;
QList<QString> m_generatedQuestions;
ChatModel *m_chatModel;
bool m_responseInProgress = false;
ResponseState m_responseState;