From aea94f756d9ef72d34924e2dbd2cfc19f9b034c1 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Thu, 1 Jun 2023 16:12:21 -0400 Subject: [PATCH] Better name for database results. --- gpt4all-chat/chat.cpp | 8 ++++---- gpt4all-chat/chat.h | 2 +- gpt4all-chat/chatllm.cpp | 8 ++++---- gpt4all-chat/chatllm.h | 4 ++-- gpt4all-chat/server.cpp | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gpt4all-chat/chat.cpp b/gpt4all-chat/chat.cpp index b61b1548..7b6cca79 100644 --- a/gpt4all-chat/chat.cpp +++ b/gpt4all-chat/chat.cpp @@ -159,14 +159,14 @@ void Chat::handleModelLoadedChanged() deleteLater(); } -QList Chat::results() const +QList Chat::databaseResults() const { - return m_llmodel->results(); + return m_llmodel->databaseResults(); } void Chat::promptProcessing() { - m_responseState = !results().isEmpty() ? Chat::LocalDocsProcessing : Chat::PromptProcessing; + m_responseState = !databaseResults().isEmpty() ? Chat::LocalDocsProcessing : Chat::PromptProcessing; emit responseStateChanged(); } @@ -176,7 +176,7 @@ void Chat::responseStopped() QList references; QList referencesContext; int validReferenceNumber = 1; - for (const ResultInfo &info : results()) { + for (const ResultInfo &info : databaseResults()) { if (info.file.isEmpty()) continue; if (validReferenceNumber == 1) diff --git a/gpt4all-chat/chat.h b/gpt4all-chat/chat.h index 984a4bda..be885a9e 100644 --- a/gpt4all-chat/chat.h +++ b/gpt4all-chat/chat.h @@ -60,7 +60,7 @@ public: Q_INVOKABLE void stopGenerating(); Q_INVOKABLE void newPromptResponsePair(const QString &prompt); - QList results() const; + QList databaseResults() const; QString response() const; bool responseInProgress() const { return m_responseInProgress; } diff --git a/gpt4all-chat/chatllm.cpp b/gpt4all-chat/chatllm.cpp index 6184815a..51c06f00 100644 --- a/gpt4all-chat/chatllm.cpp +++ b/gpt4all-chat/chatllm.cpp @@ -392,15 +392,15 @@ bool ChatLLM::prompt(const QString &prompt, const QString &prompt_template, int3 if (!isModelLoaded()) return false; - m_results.clear(); + m_databaseResults.clear(); const int retrievalSize = LocalDocs::globalInstance()->retrievalSize(); - emit requestRetrieveFromDB(m_chat->collectionList(), prompt, retrievalSize, &m_results); // blocks + emit requestRetrieveFromDB(m_chat->collectionList(), prompt, retrievalSize, &m_databaseResults); // blocks // Augment the prompt template with the results if any QList augmentedTemplate; - if (!m_results.isEmpty()) + if (!m_databaseResults.isEmpty()) augmentedTemplate.append("### Context:"); - for (const ResultInfo &info : m_results) + for (const ResultInfo &info : m_databaseResults) augmentedTemplate.append(info.text); augmentedTemplate.append(prompt_template); diff --git a/gpt4all-chat/chatllm.h b/gpt4all-chat/chatllm.h index 42de7d08..78fb8999 100644 --- a/gpt4all-chat/chatllm.h +++ b/gpt4all-chat/chatllm.h @@ -40,7 +40,7 @@ public: void regenerateResponse(); void resetResponse(); void resetContext(); - QList results() const { return m_results; } + QList databaseResults() const { return m_databaseResults; } void stopGenerating() { m_stopGenerating = true; } @@ -115,7 +115,7 @@ protected: QThread m_llmThread; std::atomic m_stopGenerating; std::atomic m_shouldBeLoaded; - QList m_results; + QList m_databaseResults; bool m_isRecalc; bool m_isServer; bool m_isChatGPT; diff --git a/gpt4all-chat/server.cpp b/gpt4all-chat/server.cpp index c7090670..87ba5cde 100644 --- a/gpt4all-chat/server.cpp +++ b/gpt4all-chat/server.cpp @@ -331,7 +331,7 @@ QHttpServerResponse Server::handleCompletionRequest(const QHttpServerRequest &re QString echoedPrompt = actualPrompt; if (!echoedPrompt.endsWith("\n")) echoedPrompt += "\n"; - responses.append(qMakePair((echo ? QString("%1\n").arg(actualPrompt) : QString()) + response(), m_results)); + responses.append(qMakePair((echo ? QString("%1\n").arg(actualPrompt) : QString()) + response(), m_databaseResults)); if (!promptTokens) promptTokens += m_promptTokens; responseTokens += m_promptResponseTokens - m_promptTokens;