error.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 = (
  9. "No valid model provider credentials found. "
  10. "Please go to Settings -> Model Provider to complete your provider credentials."
  11. )
  12. code = 400
  13. class ProviderQuotaExceededError(BaseHTTPException):
  14. error_code = "provider_quota_exceeded"
  15. description = (
  16. "Your quota for Dify Hosted Model Provider has been exhausted. "
  17. "Please go to Settings -> Model Provider to complete your own provider credentials."
  18. )
  19. code = 400
  20. class ProviderModelCurrentlyNotSupportError(BaseHTTPException):
  21. error_code = "model_currently_not_support"
  22. description = "Dify Hosted OpenAI trial currently not support the GPT-4 model."
  23. code = 400
  24. class ConversationCompletedError(BaseHTTPException):
  25. error_code = "conversation_completed"
  26. description = "The conversation has ended. Please start a new conversation."
  27. code = 400
  28. class AppUnavailableError(BaseHTTPException):
  29. error_code = "app_unavailable"
  30. description = "App unavailable, please check your app configurations."
  31. code = 400
  32. class CompletionRequestError(BaseHTTPException):
  33. error_code = "completion_request_error"
  34. description = "Completion request failed."
  35. code = 400
  36. class AppMoreLikeThisDisabledError(BaseHTTPException):
  37. error_code = "app_more_like_this_disabled"
  38. description = "The 'More like this' feature is disabled. Please refresh your page."
  39. code = 403
  40. class NoAudioUploadedError(BaseHTTPException):
  41. error_code = "no_audio_uploaded"
  42. description = "Please upload your audio."
  43. code = 400
  44. class AudioTooLargeError(BaseHTTPException):
  45. error_code = "audio_too_large"
  46. description = "Audio size exceeded. {message}"
  47. code = 413
  48. class UnsupportedAudioTypeError(BaseHTTPException):
  49. error_code = "unsupported_audio_type"
  50. description = "Audio type not allowed."
  51. code = 415
  52. class ProviderNotSupportSpeechToTextError(BaseHTTPException):
  53. error_code = "provider_not_support_speech_to_text"
  54. description = "Provider not support speech to text."
  55. code = 400
  56. class NoFileUploadedError(BaseHTTPException):
  57. error_code = "no_file_uploaded"
  58. description = "Please upload your file."
  59. code = 400
  60. class TooManyFilesError(BaseHTTPException):
  61. error_code = "too_many_files"
  62. description = "Only one file is allowed."
  63. code = 400
  64. class DraftWorkflowNotExist(BaseHTTPException):
  65. error_code = "draft_workflow_not_exist"
  66. description = "Draft workflow need to be initialized."
  67. code = 400
  68. class DraftWorkflowNotSync(BaseHTTPException):
  69. error_code = "draft_workflow_not_sync"
  70. description = "Workflow graph might have been modified, please refresh and resubmit."
  71. code = 400
  72. class TracingConfigNotExist(BaseHTTPException):
  73. error_code = "trace_config_not_exist"
  74. description = "Trace config not exist."
  75. code = 400
  76. class TracingConfigIsExist(BaseHTTPException):
  77. error_code = "trace_config_is_exist"
  78. description = "Trace config is exist."
  79. code = 400
  80. class TracingConfigCheckError(BaseHTTPException):
  81. error_code = "trace_config_check_error"
  82. description = "Invalid Credentials."
  83. code = 400
  84. class InvokeRateLimitError(BaseHTTPException):
  85. """Raised when the Invoke returns rate limit error."""
  86. error_code = "rate_limit_error"
  87. description = "Rate Limit Error"
  88. code = 429