nomic-ai / gpt4all

GPT4All: Run Local LLMs on Any Device. Open-source and available for commercial use.
https://nomic.ai/gpt4all
MIT License
70.68k stars 7.7k forks source link

chatllm: do not pass nullptr as response callback #2995

Closed cebtenzzre closed 1 month ago

cebtenzzre commented 1 month ago

In #1970, the response callback used by processRestoreStateFromText was set to nullptr because it was never used.

In #2929, this callback is now used to properly count tokens of previous assistant replies provided by the client. (The fact that processRestoreStateFromText doesn't do this causes the "regenerate" button to not work on chats freshly loaded from disk, but it's always been that way.)

The effect of this is that GPT4All throws an unhandled std::bad_function_call exception and crashes if you try to load a chat from disk and then continue it in any way. This is a regression in the v3.3.0 release, which this PR fixes.