From 364d9772e4fabbbf7904138498dbadbae9b8832c Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Thu, 26 Sep 2024 17:07:01 -0400 Subject: [PATCH] chatllm: do not pass nullptr as response callback (#2995) Signed-off-by: Jared Van Bortel --- gpt4all-chat/CHANGELOG.md | 3 +++ gpt4all-chat/src/chatllm.cpp | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/gpt4all-chat/CHANGELOG.md b/gpt4all-chat/CHANGELOG.md index 6edd4ce8..faceaf58 100644 --- a/gpt4all-chat/CHANGELOG.md +++ b/gpt4all-chat/CHANGELOG.md @@ -9,6 +9,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Added - Add bm25 hybrid search to localdocs ([#2969](https://github.com/nomic-ai/gpt4all/pull/2969)) +### Fixed +- Fix a crash when attempting to continue a chat loaded from disk ([#2995](https://github.com/nomic-ai/gpt4all/pull/2995)) + ## [3.3.0] - 2024-09-20 ### Added diff --git a/gpt4all-chat/src/chatllm.cpp b/gpt4all-chat/src/chatllm.cpp index a81d49bd..930f0a81 100644 --- a/gpt4all-chat/src/chatllm.cpp +++ b/gpt4all-chat/src/chatllm.cpp @@ -1314,8 +1314,16 @@ void ChatLLM::processRestoreStateFromText() auto &response = *it++; Q_ASSERT(response.first != "Prompt: "); - m_llModelInfo.model->prompt(prompt.second.toStdString(), promptTemplate.toStdString(), promptFunc, nullptr, - /*allowContextShift*/ true, m_ctx, false, response.second.toUtf8().constData()); + // FIXME(jared): this doesn't work well with the "regenerate" button since we are not incrementing + // m_promptTokens or m_promptResponseTokens + m_llModelInfo.model->prompt( + prompt.second.toStdString(), promptTemplate.toStdString(), + promptFunc, /*responseFunc*/ [](auto &&...) { return true; }, + /*allowContextShift*/ true, + m_ctx, + /*special*/ false, + response.second.toUtf8().constData() + ); } if (!m_stopGenerating) {