Skip to content

Commit

Permalink
make sure nkeep is set when chatting or at a new prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
amakropoulos committed Feb 1, 2024
1 parent cb45601 commit 76e806b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Runtime/LLMClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -143,7 +144,7 @@ protected static string GetAssetPath(string relPath = "")

private async Task InitNKeep()
{
if (setNKeepToPrompt)
if (setNKeepToPrompt && nKeep == -1)
{
await Tokenize(prompt, SetNKeep);
}
Expand Down Expand Up @@ -280,6 +281,7 @@ public async Task Chat(string question, Callback<string> 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)
Expand Down

0 comments on commit 76e806b

Please sign in to comment.