error.py 989 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. from typing import Optional
  2. class LLMError(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 LLMBadRequestError(LLMError):
  8. """Raised when the LLM returns bad request."""
  9. description = "Bad Request"
  10. class ProviderTokenNotInitError(Exception):
  11. """
  12. Custom exception raised when the provider token is not initialized.
  13. """
  14. description = "Provider Token Not Init"
  15. def __init__(self, *args, **kwargs):
  16. self.description = args[0] if args else self.description
  17. class QuotaExceededError(Exception):
  18. """
  19. Custom exception raised when the quota for a provider has been exceeded.
  20. """
  21. description = "Quota Exceeded"
  22. class ModelCurrentlyNotSupportError(Exception):
  23. """
  24. Custom exception raised when the model not support
  25. """
  26. description = "Model Currently Not Support"