From 8467e69f24b9acdb5d150dc98761f1fd80623003 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Mon, 10 Jul 2023 17:29:21 -0400 Subject: [PATCH] Check that we're not null. This is necessary because the loop can make us recursive. Need to fix that. --- gpt4all-chat/chatgpt.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gpt4all-chat/chatgpt.cpp b/gpt4all-chat/chatgpt.cpp index 5d378930..d9f6114e 100644 --- a/gpt4all-chat/chatgpt.cpp +++ b/gpt4all-chat/chatgpt.cpp @@ -134,7 +134,8 @@ void ChatGPT::prompt(const std::string &prompt, qDebug() << "ChatGPT::prompt end network request"; #endif - m_ctx->n_past += 1; + if (m_ctx) + m_ctx->n_past += 1; m_context.append(QString::fromStdString(prompt)); m_context.append(m_currentResponse);