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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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.Fork"/> is called when <see cref="Conversation.RequiresInference"/> = true
  55. /// </summary>
  56. public class CannotForkWhileRequiresInferenceException
  57. : ExperimentalBatchedExecutorException
  58. {
  59. internal CannotForkWhileRequiresInferenceException()
  60. : base("Cannot `Fork()` a conversation while RequiresInference is true")
  61. {
  62. }
  63. }
  64. /// <summary>
  65. /// This exception is thrown when <see cref="Conversation.Modify"/> is called when <see cref="Conversation.RequiresInference"/> = true
  66. /// </summary>
  67. public class CannotModifyWhileRequiresInferenceException
  68. : ExperimentalBatchedExecutorException
  69. {
  70. internal CannotModifyWhileRequiresInferenceException()
  71. : base("Cannot `Modify()` a conversation while RequiresInference is true")
  72. {
  73. }
  74. }