error.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. from libs.exception import BaseHTTPException
  2. class AppUnavailableError(BaseHTTPException):
  3. error_code = "app_unavailable"
  4. description = "App unavailable, please check your app configurations."
  5. code = 400
  6. class NotCompletionAppError(BaseHTTPException):
  7. error_code = "not_completion_app"
  8. description = "Please check if your Completion app mode matches the right API route."
  9. code = 400
  10. class NotChatAppError(BaseHTTPException):
  11. error_code = "not_chat_app"
  12. description = "Please check if your app mode matches the right API route."
  13. code = 400
  14. class NotWorkflowAppError(BaseHTTPException):
  15. error_code = "not_workflow_app"
  16. description = "Please check if your Workflow app mode matches the right API route."
  17. code = 400
  18. class ConversationCompletedError(BaseHTTPException):
  19. error_code = "conversation_completed"
  20. description = "The conversation has ended. Please start a new conversation."
  21. code = 400
  22. class ProviderNotInitializeError(BaseHTTPException):
  23. error_code = "provider_not_initialize"
  24. description = (
  25. "No valid model provider credentials found. "
  26. "Please go to Settings -> Model Provider to complete your provider credentials."
  27. )
  28. code = 400
  29. class ProviderQuotaExceededError(BaseHTTPException):
  30. error_code = "provider_quota_exceeded"
  31. description = (
  32. "Your quota for Dify Hosted OpenAI has been exhausted. "
  33. "Please go to Settings -> Model Provider to complete your own provider credentials."
  34. )
  35. code = 400
  36. class ProviderModelCurrentlyNotSupportError(BaseHTTPException):
  37. error_code = "model_currently_not_support"
  38. description = "Dify Hosted OpenAI trial currently not support the GPT-4 model."
  39. code = 400
  40. class CompletionRequestError(BaseHTTPException):
  41. error_code = "completion_request_error"
  42. description = "Completion request failed."
  43. code = 400
  44. class AppMoreLikeThisDisabledError(BaseHTTPException):
  45. error_code = "app_more_like_this_disabled"
  46. description = "The 'More like this' feature is disabled. Please refresh your page."
  47. code = 403
  48. class AppSuggestedQuestionsAfterAnswerDisabledError(BaseHTTPException):
  49. error_code = "app_suggested_questions_after_answer_disabled"
  50. description = "The 'Suggested Questions After Answer' feature is disabled. Please refresh your page."
  51. code = 403
  52. class NoAudioUploadedError(BaseHTTPException):
  53. error_code = "no_audio_uploaded"
  54. description = "Please upload your audio."
  55. code = 400
  56. class AudioTooLargeError(BaseHTTPException):
  57. error_code = "audio_too_large"
  58. description = "Audio size exceeded. {message}"
  59. code = 413
  60. class UnsupportedAudioTypeError(BaseHTTPException):
  61. error_code = "unsupported_audio_type"
  62. description = "Audio type not allowed."
  63. code = 415
  64. class ProviderNotSupportSpeechToTextError(BaseHTTPException):
  65. error_code = "provider_not_support_speech_to_text"
  66. description = "Provider not support speech to text."
  67. code = 400
  68. class NoFileUploadedError(BaseHTTPException):
  69. error_code = "no_file_uploaded"
  70. description = "Please upload your file."
  71. code = 400
  72. class TooManyFilesError(BaseHTTPException):
  73. error_code = "too_many_files"
  74. description = "Only one file is allowed."
  75. code = 400
  76. class FileTooLargeError(BaseHTTPException):
  77. error_code = "file_too_large"
  78. description = "File size exceeded. {message}"
  79. code = 413
  80. class UnsupportedFileTypeError(BaseHTTPException):
  81. error_code = "unsupported_file_type"
  82. description = "File type not allowed."
  83. code = 415
  84. class WebSSOAuthRequiredError(BaseHTTPException):
  85. error_code = "web_sso_auth_required"
  86. description = "Web SSO authentication required."
  87. code = 401
  88. class InvokeRateLimitError(BaseHTTPException):
  89. """Raised when the Invoke returns rate limit error."""
  90. error_code = "rate_limit_error"
  91. description = "Rate Limit Error"
  92. code = 429