error.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 Chat app mode matches the right API route."
  13. code = 400
  14. class ConversationCompletedError(BaseHTTPException):
  15. error_code = 'conversation_completed'
  16. description = "The conversation has ended. Please start a new conversation."
  17. code = 400
  18. class ProviderNotInitializeError(BaseHTTPException):
  19. error_code = 'provider_not_initialize'
  20. description = "No valid model provider credentials found. " \
  21. "Please go to Settings -> Model Provider to complete your provider credentials."
  22. code = 400
  23. class ProviderQuotaExceededError(BaseHTTPException):
  24. error_code = 'provider_quota_exceeded'
  25. description = "Your quota for Dify Hosted OpenAI has been exhausted. " \
  26. "Please go to Settings -> Model Provider to complete your own provider credentials."
  27. code = 400
  28. class ProviderModelCurrentlyNotSupportError(BaseHTTPException):
  29. error_code = 'model_currently_not_support'
  30. description = "Dify Hosted OpenAI trial currently not support the GPT-4 model."
  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 AppSuggestedQuestionsAfterAnswerDisabledError(BaseHTTPException):
  41. error_code = 'app_suggested_questions_after_answer_disabled'
  42. description = "The 'Suggested Questions After Answer' feature is disabled. Please refresh your page."
  43. code = 403
  44. class NoAudioUploadedError(BaseHTTPException):
  45. error_code = 'no_audio_uploaded'
  46. description = "Please upload your audio."
  47. code = 400
  48. class AudioTooLargeError(BaseHTTPException):
  49. error_code = 'audio_too_large'
  50. description = "Audio size exceeded. {message}"
  51. code = 413
  52. class UnsupportedAudioTypeError(BaseHTTPException):
  53. error_code = 'unsupported_audio_type'
  54. description = "Audio type not allowed."
  55. code = 415
  56. class ProviderNotSupportSpeechToTextError(BaseHTTPException):
  57. error_code = 'provider_not_support_speech_to_text'
  58. description = "Provider not support speech to text."
  59. code = 400
  60. class NoFileUploadedError(BaseHTTPException):
  61. error_code = 'no_file_uploaded'
  62. description = "Please upload your file."
  63. code = 400
  64. class TooManyFilesError(BaseHTTPException):
  65. error_code = 'too_many_files'
  66. description = "Only one file is allowed."
  67. code = 400
  68. class FileTooLargeError(BaseHTTPException):
  69. error_code = 'file_too_large'
  70. description = "File size exceeded. {message}"
  71. code = 413
  72. class UnsupportedFileTypeError(BaseHTTPException):
  73. error_code = 'unsupported_file_type'
  74. description = "File type not allowed."
  75. code = 415