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.

ChatWithLLamaModel.cs 1.2 kB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using LLama.OldVersion;
  7. namespace LLama.Examples.Old
  8. {
  9. [Obsolete("The entire LLama.OldVersion namespace will be removed")]
  10. public class ChatWithLLamaModel
  11. {
  12. LLama.OldVersion.LLamaModel _model;
  13. public ChatWithLLamaModel(string modelPath, string promptFilePath, string[] antiprompt)
  14. {
  15. _model = new LLama.OldVersion.LLamaModel(new LLamaParams(model: modelPath, n_ctx: 512, interactive: true, antiprompt: antiprompt.ToList(),
  16. repeat_penalty: 1.0f)).WithPromptFile(promptFilePath);
  17. }
  18. public void Run()
  19. {
  20. Console.Write("\nUser:");
  21. while (true)
  22. {
  23. Console.ForegroundColor = ConsoleColor.Green;
  24. var question = Console.ReadLine();
  25. question += "\n";
  26. Console.ForegroundColor = ConsoleColor.White;
  27. var outputs = _model.Call(question);
  28. foreach (var output in outputs)
  29. {
  30. Console.Write(output);
  31. }
  32. }
  33. }
  34. }
  35. }