invoke.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from typing import Optional
  2. class InvokeError(Exception):
  3. """Base class for all LLM exceptions."""
  4. description: Optional[str] = None
  5. def __init__(self, description: Optional[str] = None) -> None:
  6. self.description = description
  7. def __str__(self):
  8. return self.description or self.__class__.__name__
  9. class InvokeConnectionError(InvokeError):
  10. """Raised when the Invoke returns connection error."""
  11. description = "Connection Error"
  12. class InvokeServerUnavailableError(InvokeError):
  13. """Raised when the Invoke returns server unavailable error."""
  14. description = "Server Unavailable Error"
  15. class InvokeRateLimitError(InvokeError):
  16. """Raised when the Invoke returns rate limit error."""
  17. description = "Rate Limit Error"
  18. class InvokeAuthorizationError(InvokeError):
  19. """Raised when the Invoke returns authorization error."""
  20. description = "Incorrect model credentials provided, please check and try again. "
  21. class InvokeBadRequestError(InvokeError):
  22. """Raised when the Invoke returns bad request."""
  23. description = "Bad Request Error"