error.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 AppInvokeQuotaExceededError(Exception):
  23. """
  24. Custom exception raised when the quota for an app has been exceeded.
  25. """
  26. description = "App Invoke Quota Exceeded"
  27. class ModelCurrentlyNotSupportError(Exception):
  28. """
  29. Custom exception raised when the model not support
  30. """
  31. description = "Model Currently Not Support"