From c77a8c81af68e0f2293f6b8fc77a5e193a4e69a5 Mon Sep 17 00:00:00 2001 From: Thomas Beverley Date: Wed, 13 Nov 2024 10:27:05 +0000 Subject: [PATCH] Fix an undefined assignment when using grammar --- src/native/main/APIHandler/LlmSessionAPIHandler.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/native/main/APIHandler/LlmSessionAPIHandler.ts b/src/native/main/APIHandler/LlmSessionAPIHandler.ts index c670341..1433986 100644 --- a/src/native/main/APIHandler/LlmSessionAPIHandler.ts +++ b/src/native/main/APIHandler/LlmSessionAPIHandler.ts @@ -248,14 +248,16 @@ class LlmSessionAPIHandler { contextSequence: context.getSequence() }) + let grammar: LlamaGrammar | undefined if (chatOptions.grammar !== undefined) { - this.#activeSession.chat.grammar = await this.#activeSession.llama.createGrammarForJsonSchema(chatOptions.grammar) + grammar = await this.#activeSession.llama.createGrammarForJsonSchema(chatOptions.grammar) } this.#activeSession.chat = { options: chatOptions, context, - session + session, + grammar } } }