diff --git a/LLama.Examples/Examples/GrammarJsonResponse.cs b/LLama.Examples/Examples/GrammarJsonResponse.cs index 0a86a912d..96bd1f86e 100644 --- a/LLama.Examples/Examples/GrammarJsonResponse.cs +++ b/LLama.Examples/Examples/GrammarJsonResponse.cs @@ -25,20 +25,23 @@ public static async Task Run() Console.WriteLine("The executor has been enabled. In this example, the LLM will follow your instructions and always respond in a JSON format. For example, you can input \"Tell me the attributes of a good dish\""); Console.ForegroundColor = ConsoleColor.White; - using var grammarInstance = grammar.CreateInstance(); + var samplingPipeline = new DefaultSamplingPipeline + { + Temperature = 0.6f + }; + var inferenceParams = new InferenceParams() { - SamplingPipeline = new DefaultSamplingPipeline - { - Temperature = 0.6f, - Grammar = grammarInstance - }, + SamplingPipeline = samplingPipeline, AntiPrompts = new List { "Question:", "#", "Question: ", ".\n" }, MaxTokens = 50, }; while (true) { + using var grammarInstance = grammar.CreateInstance(); + samplingPipeline.Grammar = grammarInstance; + Console.Write("\nQuestion: "); Console.ForegroundColor = ConsoleColor.Green; var prompt = Console.ReadLine();