From dc2e7d6e9bce412fd260f4c5a6b46da18020c1e1 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Sat, 28 Oct 2023 16:39:25 -0400 Subject: [PATCH] Don't start recalculating context immediately upon switching to a new chat but rather wait until the first prompt. This allows users to switch between chats fast and to delete chats more easily. Fixes issue #1545 --- gpt4all-chat/chatllm.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gpt4all-chat/chatllm.cpp b/gpt4all-chat/chatllm.cpp index efb43ee4..2131760e 100644 --- a/gpt4all-chat/chatllm.cpp +++ b/gpt4all-chat/chatllm.cpp @@ -503,6 +503,11 @@ bool ChatLLM::handleRecalculate(bool isRecalc) } bool ChatLLM::prompt(const QList &collectionList, const QString &prompt) { + if (m_restoreStateFromText) { + Q_ASSERT(m_state.isEmpty()); + processRestoreStateFromText(); + } + if (!m_processedSystemPrompt) processSystemPrompt(); const QString promptTemplate = MySettings::globalInstance()->modelPromptTemplate(m_modelInfo); @@ -906,11 +911,6 @@ void ChatLLM::restoreState() return; } - if (m_restoreStateFromText) { - Q_ASSERT(m_state.isEmpty()); - processRestoreStateFromText(); - } - #if defined(DEBUG) qDebug() << "restoreState" << m_llmThread.objectName() << "size:" << m_state.size(); #endif