invoke.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  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. class InvokeConnectionError(InvokeError):
  8. """Raised when the Invoke returns connection error."""
  9. description = "Connection Error"
  10. class InvokeServerUnavailableError(InvokeError):
  11. """Raised when the Invoke returns server unavailable error."""
  12. description = "Server Unavailable Error"
  13. class InvokeRateLimitError(InvokeError):
  14. """Raised when the Invoke returns rate limit error."""
  15. description = "Rate Limit Error"
  16. class InvokeAuthorizationError(InvokeError):
  17. """Raised when the Invoke returns authorization error."""
  18. description = "Incorrect model credentials provided, please check and try again. "
  19. class InvokeBadRequestError(InvokeError):
  20. """Raised when the Invoke returns bad request."""
  21. description = "Bad Request Error"