exceptions.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. class MaxCharsExceedError(Exception):
  2. def __init__(self, num_of_chars=None, max_chars_limit=None):
  3. if num_of_chars is not None and max_chars_limit is not None:
  4. message = f'Number of characters {num_of_chars} exceeds MAX_CHARS limit: {max_chars_limit}'
  5. else:
  6. message = 'Number of characters exceeds MAX_CHARS limit'
  7. super().__init__(message)
  8. class AgentNoActionError(Exception):
  9. def __init__(self, message='Agent must return an action'):
  10. super().__init__(message)
  11. class AgentNoInstructionError(Exception):
  12. def __init__(self, message='Instruction must be provided'):
  13. super().__init__(message)
  14. class AgentEventTypeError(Exception):
  15. def __init__(self, message='Event must be a dictionary'):
  16. super().__init__(message)
  17. class AgentAlreadyRegisteredError(Exception):
  18. def __init__(self, name=None):
  19. if name is not None:
  20. message = f"Agent class already registered under '{name}'"
  21. else:
  22. message = 'Agent class already registered'
  23. super().__init__(message)
  24. class AgentNotRegisteredError(Exception):
  25. def __init__(self, name=None):
  26. if name is not None:
  27. message = f"No agent class registered under '{name}'"
  28. else:
  29. message = 'No agent class registered'
  30. super().__init__(message)
  31. class LLMOutputError(Exception):
  32. def __init__(self, message):
  33. super().__init__(message)
  34. class SandboxInvalidBackgroundCommandError(Exception):
  35. def __init__(self, id=None):
  36. if id is not None:
  37. message = f'Invalid background command id {id}'
  38. else:
  39. message = 'Invalid background command id'
  40. super().__init__(message)
  41. class PlanInvalidStateError(Exception):
  42. def __init__(self, state=None):
  43. if state is not None:
  44. message = f'Invalid state {state}'
  45. else:
  46. message = 'Invalid state'
  47. super().__init__(message)