2024-12-21 21:22:14 +08:00
|
|
|
class InvokeError(ValueError):
|
2024-01-02 23:42:00 +08:00
|
|
|
"""Base class for all LLM exceptions."""
|
2024-09-10 17:00:20 +08:00
|
|
|
|
2025-09-15 13:06:33 +08:00
|
|
|
description: str | None = None
|
2024-01-02 23:42:00 +08:00
|
|
|
|
2025-09-15 13:06:33 +08:00
|
|
|
def __init__(self, description: str | None = None):
|
2024-01-02 23:42:00 +08:00
|
|
|
self.description = description
|
|
|
|
|
|
2024-01-05 03:47:46 +08:00
|
|
|
def __str__(self):
|
|
|
|
|
return self.description or self.__class__.__name__
|
|
|
|
|
|
2024-01-02 23:42:00 +08:00
|
|
|
|
|
|
|
|
class InvokeConnectionError(InvokeError):
|
|
|
|
|
"""Raised when the Invoke returns connection error."""
|
2024-09-10 17:00:20 +08:00
|
|
|
|
2024-01-02 23:42:00 +08:00
|
|
|
description = "Connection Error"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InvokeServerUnavailableError(InvokeError):
|
|
|
|
|
"""Raised when the Invoke returns server unavailable error."""
|
2024-09-10 17:00:20 +08:00
|
|
|
|
2024-01-02 23:42:00 +08:00
|
|
|
description = "Server Unavailable Error"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InvokeRateLimitError(InvokeError):
|
|
|
|
|
"""Raised when the Invoke returns rate limit error."""
|
2024-09-10 17:00:20 +08:00
|
|
|
|
2024-01-02 23:42:00 +08:00
|
|
|
description = "Rate Limit Error"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InvokeAuthorizationError(InvokeError):
|
|
|
|
|
"""Raised when the Invoke returns authorization error."""
|
2024-09-10 17:00:20 +08:00
|
|
|
|
2024-01-02 23:42:00 +08:00
|
|
|
description = "Incorrect model credentials provided, please check and try again. "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InvokeBadRequestError(InvokeError):
|
|
|
|
|
"""Raised when the Invoke returns bad request."""
|
2024-09-10 17:00:20 +08:00
|
|
|
|
2024-01-02 23:42:00 +08:00
|
|
|
description = "Bad Request Error"
|