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.

Program.cs 1.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using LLama.Native;
  2. using Spectre.Console;
  3. using System.Runtime.InteropServices;
  4. AnsiConsole.MarkupLineInterpolated(
  5. $"""
  6. [purple]======================================================================================================[/]
  7. __ __ ____ __
  8. /\ \ /\ \ /\ _`\ /\ \
  9. \ \ \ \ \ \ __ ___ ___ __ \ \,\L\_\\ \ \___ __ _ __ _____
  10. \ \ \ __\ \ \ __ /'__`\ /' __` __`\ /'__`\ \/_\__ \ \ \ _ `\ /'__`\ /\` __\/\ __`\
  11. \ \ \L\ \\ \ \L\ \/\ \L\.\_ /\ \/\ \/\ \ /\ \L\.\_ /\ \L\ \\ \ \ \ \ /\ \L\.\_\ \ \/ \ \ \L\ \
  12. \ \____/ \ \____/\ \__/.\_\\ \_\ \_\ \_\\ \__/.\_\\ `\____\\ \_\ \_\\ \__/.\_\\ \_\ \ \ ,__/
  13. \/___/ \/___/ \/__/\/_/ \/_/\/_/\/_/ \/__/\/_/ \/_____/ \/_/\/_/ \/__/\/_/ \/_/ \ \ \/
  14. [purple]=========================================================================================[/] \ \_\ [purple]======[/]
  15. \/_/
  16. """);
  17. // Configure logging. Change this to `true` to see log messages from llama.cpp
  18. var showLLamaCppLogs = false;
  19. NativeLibraryConfig
  20. .All
  21. .WithLogCallback((level, message) =>
  22. {
  23. if (showLLamaCppLogs)
  24. Console.WriteLine($"[llama {level}]: {message.TrimEnd('\n')}");
  25. });
  26. // Configure native library to use. This must be done before any other llama.cpp methods are called!
  27. NativeLibraryConfig
  28. .All
  29. .WithCuda()
  30. //.WithAutoDownload() // An experimental feature
  31. .DryRun(out var loadedllamaLibrary, out var loadedLLavaLibrary);
  32. // Calling this method forces loading to occur now.
  33. NativeApi.llama_empty_call();
  34. await ExampleRunner.Run();