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.

Exceptions.cs 2.6 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System;
  2. namespace LLama.Batched;
  3. /// <summary>
  4. /// Base class for exceptions thrown from <see cref="BatchedExecutor"/>
  5. /// </summary>
  6. public class ExperimentalBatchedExecutorException
  7. : Exception
  8. {
  9. internal ExperimentalBatchedExecutorException(string message)
  10. : base(message)
  11. {
  12. }
  13. }
  14. /// <summary>
  15. /// This exception is thrown when "Prompt()" is called on a <see cref="Conversation"/> which has
  16. /// already been prompted and before "Infer()" has been called on the associated
  17. /// <see cref="BatchedExecutor"/>.
  18. /// </summary>
  19. public class AlreadyPromptedConversationException
  20. : ExperimentalBatchedExecutorException
  21. {
  22. internal AlreadyPromptedConversationException()
  23. : base("Must call `Infer()` before prompting this Conversation again")
  24. {
  25. }
  26. }
  27. /// <summary>
  28. /// This exception is thrown when "Sample()" is called on a <see cref="Conversation"/> which has
  29. /// already been prompted and before "Infer()" has been called on the associated
  30. /// <see cref="BatchedExecutor"/>.
  31. /// </summary>
  32. public class CannotSampleRequiresInferenceException
  33. : ExperimentalBatchedExecutorException
  34. {
  35. internal CannotSampleRequiresInferenceException()
  36. : base("Must call `Infer()` before sampling from this Conversation")
  37. {
  38. }
  39. }
  40. /// <summary>
  41. /// This exception is thrown when "Sample()" is called on a <see cref="Conversation"/> which was not
  42. /// first prompted.
  43. /// <see cref="BatchedExecutor"/>.
  44. /// </summary>
  45. public class CannotSampleRequiresPromptException
  46. : ExperimentalBatchedExecutorException
  47. {
  48. internal CannotSampleRequiresPromptException()
  49. : base("Must call `Prompt()` and then `Infer()` before sampling from this Conversation")
  50. {
  51. }
  52. }
  53. /// <summary>
  54. /// This exception is thrown when <see cref="Conversation.Modify"/> is called when <see cref="Conversation.RequiresInference"/> = true
  55. /// </summary>
  56. public class CannotModifyWhileRequiresInferenceException
  57. : ExperimentalBatchedExecutorException
  58. {
  59. internal CannotModifyWhileRequiresInferenceException()
  60. : base("Cannot `Modify()` a conversation while RequiresInference is true")
  61. {
  62. }
  63. }
  64. /// <summary>
  65. /// This exception is thrown when "Save()" is called on a <see cref="Conversation"/> which has
  66. /// already been prompted and before "Infer()" has been called.
  67. /// <see cref="BatchedExecutor"/>.
  68. /// </summary>
  69. public class CannotSaveWhileRequiresInferenceException
  70. : ExperimentalBatchedExecutorException
  71. {
  72. internal CannotSaveWhileRequiresInferenceException()
  73. : base("Must call `Infer()` before saving this Conversation")
  74. {
  75. }
  76. }