using System.Linq.Expressions; using Spectre.Console; namespace LLama.Examples.NewVersion { public class NewVersionTestRunner { static Dictionary> Examples = new Dictionary> { {"Run a chat session without stripping the role names.", () => ChatSessionWithRoleName.Run()}, {"Run a chat session with the role names stripped.",()=> ChatSessionStripRoleName.Run()}, {"Interactive mode chat by using executor.",()=> InteractiveModeExecute.Run()}, {"Instruct mode chat by using executor.",()=> InstructModeExecute.Run()}, {"Stateless mode chat by using executor.",()=> StatelessModeExecute.Run()}, {"Load and save chat session.",()=> SaveAndLoadSession.Run()}, {"Load and save state of model and executor.",()=> LoadAndSaveState.Run()}, {"Get embeddings from LLama model.",()=> GetEmbeddings.Run()}, {"Quantize the model.",()=> QuantizeModel.Run()}, {"Automatic conversation.",()=> TalkToYourself.Run()}, {"Constrain response to json format using grammar.",()=> GrammarJsonResponse.Run()}, {"Semantic Kernel Prompt.",()=> SemanticKernelPrompt.Run()}, {"Semantic Kernel Chat.",()=> SemanticKernelChat.Run()}, {"Semantic Kernel Memory.",()=> SemanticKernelMemory.Run()}, {"Coding Assistant.",()=> CodingAssistant.Run()}, {"Batch Decoding.",()=> BatchedDecoding.Run()}, {"SK Kernel Memory.",()=> KernelMemory.Run()}, {"Exit", ()=> Task.CompletedTask} }; public static async Task Run() { AnsiConsole.Write(new Rule("LLamaSharp Examples")); while (true) { var choice = AnsiConsole.Prompt( new SelectionPrompt() .Title("Please choose[green] an example[/] to run: ") .AddChoices(Examples.Keys)); if (Examples.TryGetValue(choice, out var example)) { if (choice == "Exit") { break; } AnsiConsole.Write(new Rule(choice)); await example(); } AnsiConsole.Clear(); } } } }