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.

RuntimeError.cs 1.3 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using LLama.Native;
  3. namespace LLama.Exceptions;
  4. /// <summary>
  5. /// Base class for LLamaSharp runtime errors (i.e. errors produced by llama.cpp, converted into exceptions)
  6. /// </summary>
  7. public class RuntimeError
  8. : Exception
  9. {
  10. /// <summary>
  11. /// Create a new RuntimeError
  12. /// </summary>
  13. /// <param name="message"></param>
  14. public RuntimeError(string message)
  15. : base(message)
  16. {
  17. }
  18. }
  19. /// <summary>
  20. /// Loading model weights failed
  21. /// </summary>
  22. public class LoadWeightsFailedException
  23. : RuntimeError
  24. {
  25. /// <summary>
  26. /// The model path which failed to load
  27. /// </summary>
  28. public string ModelPath { get; }
  29. /// <inheritdoc />
  30. public LoadWeightsFailedException(string modelPath)
  31. : base($"Failed to load model '{modelPath}'")
  32. {
  33. ModelPath = modelPath;
  34. }
  35. }
  36. /// <summary>
  37. /// `llama_decode` return a non-zero status code
  38. /// </summary>
  39. public class LLamaDecodeError
  40. : RuntimeError
  41. {
  42. /// <summary>
  43. /// The return status code
  44. /// </summary>
  45. public DecodeResult ReturnCode { get; }
  46. /// <inheritdoc />
  47. public LLamaDecodeError(DecodeResult returnCode)
  48. : base($"llama_decode failed: '{returnCode}'")
  49. {
  50. ReturnCode = returnCode;
  51. }
  52. }