Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions LLama.Examples/Examples/GrammarJsonResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> { "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();
Expand Down