You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestRunner.cs 2.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System.Linq.Expressions;
  2. using Spectre.Console;
  3. namespace LLama.Examples.NewVersion
  4. {
  5. public class NewVersionTestRunner
  6. {
  7. static Dictionary<string, Func<Task>> Examples = new Dictionary<string, Func<Task>>
  8. {
  9. {"Run a chat session without stripping the role names.", () => ChatSessionWithRoleName.Run()},
  10. {"Run a chat session with the role names stripped.",()=> ChatSessionStripRoleName.Run()},
  11. {"Interactive mode chat by using executor.",()=> InteractiveModeExecute.Run()},
  12. {"Instruct mode chat by using executor.",()=> InstructModeExecute.Run()},
  13. {"Stateless mode chat by using executor.",()=> StatelessModeExecute.Run()},
  14. {"Load and save chat session.",()=> SaveAndLoadSession.Run()},
  15. {"Load and save state of model and executor.",()=> LoadAndSaveState.Run()},
  16. {"Get embeddings from LLama model.",()=> GetEmbeddings.Run()},
  17. {"Quantize the model.",()=> QuantizeModel.Run()},
  18. {"Automatic conversation.",()=> TalkToYourself.Run()},
  19. {"Constrain response to json format using grammar.",()=> GrammarJsonResponse.Run()},
  20. {"Semantic Kernel Prompt.",()=> SemanticKernelPrompt.Run()},
  21. {"Semantic Kernel Chat.",()=> SemanticKernelChat.Run()},
  22. {"Semantic Kernel Memory.",()=> SemanticKernelMemory.Run()},
  23. {"Coding Assistant.",()=> CodingAssistant.Run()},
  24. {"Batch Decoding.",()=> BatchedDecoding.Run()},
  25. {"SK Kernel Memory.",()=> KernelMemory.Run()},
  26. {"Exit", ()=> Task.CompletedTask}
  27. };
  28. public static async Task Run()
  29. {
  30. AnsiConsole.Write(new Rule("LLamaSharp Examples"));
  31. while (true)
  32. {
  33. var choice = AnsiConsole.Prompt(
  34. new SelectionPrompt<string>()
  35. .Title("Please choose[green] an example[/] to run: ")
  36. .AddChoices(Examples.Keys));
  37. if (Examples.TryGetValue(choice, out var example))
  38. {
  39. if (choice == "Exit")
  40. {
  41. break;
  42. }
  43. AnsiConsole.Write(new Rule(choice));
  44. await example();
  45. }
  46. AnsiConsole.Clear();
  47. }
  48. }
  49. }
  50. }