error.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. from libs.exception import BaseHTTPException
  2. class AppNotFoundError(BaseHTTPException):
  3. error_code = 'app_not_found'
  4. description = "App not found."
  5. code = 404
  6. class ProviderNotInitializeError(BaseHTTPException):
  7. error_code = 'provider_not_initialize'
  8. description = "No valid model provider credentials found. " \
  9. "Please go to Settings -> Model Provider to complete your provider credentials."
  10. code = 400
  11. class ProviderQuotaExceededError(BaseHTTPException):
  12. error_code = 'provider_quota_exceeded'
  13. description = "Your quota for Dify Hosted Model Provider has been exhausted. " \
  14. "Please go to Settings -> Model Provider to complete your own provider credentials."
  15. code = 400
  16. class ProviderModelCurrentlyNotSupportError(BaseHTTPException):
  17. error_code = 'model_currently_not_support'
  18. description = "Dify Hosted OpenAI trial currently not support the GPT-4 model."
  19. code = 400
  20. class ConversationCompletedError(BaseHTTPException):
  21. error_code = 'conversation_completed'
  22. description = "The conversation has ended. Please start a new conversation."
  23. code = 400
  24. class AppUnavailableError(BaseHTTPException):
  25. error_code = 'app_unavailable'
  26. description = "App unavailable, please check your app configurations."
  27. code = 400
  28. class CompletionRequestError(BaseHTTPException):
  29. error_code = 'completion_request_error'
  30. description = "Completion request failed."
  31. code = 400
  32. class AppMoreLikeThisDisabledError(BaseHTTPException):
  33. error_code = 'app_more_like_this_disabled'
  34. description = "The 'More like this' feature is disabled. Please refresh your page."
  35. code = 403
  36. class NoAudioUploadedError(BaseHTTPException):
  37. error_code = 'no_audio_uploaded'
  38. description = "Please upload your audio."
  39. code = 400
  40. class AudioTooLargeError(BaseHTTPException):
  41. error_code = 'audio_too_large'
  42. description = "Audio size exceeded. {message}"
  43. code = 413
  44. class UnsupportedAudioTypeError(BaseHTTPException):
  45. error_code = 'unsupported_audio_type'
  46. description = "Audio type not allowed."
  47. code = 415
  48. class ProviderNotSupportSpeechToTextError(BaseHTTPException):
  49. error_code = 'provider_not_support_speech_to_text'
  50. description = "Provider not support speech to text."
  51. code = 400