From 76e806b87e145b1b241781de85b796c8bafb25f1 Mon Sep 17 00:00:00 2001 From: Antonis Makropoulos Date: Thu, 1 Feb 2024 17:11:48 +0200 Subject: [PATCH] make sure nkeep is set when chatting or at a new prompt --- Runtime/LLMClient.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Runtime/LLMClient.cs b/Runtime/LLMClient.cs index c0d5f284..9ff3daf2 100644 --- a/Runtime/LLMClient.cs +++ b/Runtime/LLMClient.cs @@ -132,6 +132,7 @@ private async Task InitPrompt(bool clearChat = true) public async Task SetPrompt(string newPrompt, bool clearChat = true) { prompt = newPrompt; + nKeep = -1; await InitPrompt(clearChat); } @@ -143,7 +144,7 @@ protected static string GetAssetPath(string relPath = "") private async Task InitNKeep() { - if (setNKeepToPrompt) + if (setNKeepToPrompt && nKeep == -1) { await Tokenize(prompt, SetNKeep); } @@ -280,6 +281,7 @@ public async Task Chat(string question, Callback callback = null, EmptyC // handle a chat message by the user // call the callback function while the answer is received // call the completionCallback function when the answer is fully received + await InitNKeep(); string json = JsonUtility.ToJson(GenerateRequest(question)); string result; if (stream)