error.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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
  52. class NoFileUploadedError(BaseHTTPException):
  53. error_code = 'no_file_uploaded'
  54. description = "Please upload your file."
  55. code = 400
  56. class TooManyFilesError(BaseHTTPException):
  57. error_code = 'too_many_files'
  58. description = "Only one file is allowed."
  59. code = 400
  60. class DraftWorkflowNotExist(BaseHTTPException):
  61. error_code = 'draft_workflow_not_exist'
  62. description = "Draft workflow need to be initialized."
  63. code = 400
  64. class DraftWorkflowNotSync(BaseHTTPException):
  65. error_code = 'draft_workflow_not_sync'
  66. description = "Workflow graph might have been modified, please refresh and resubmit."
  67. code = 400
  68. class TracingConfigNotExist(BaseHTTPException):
  69. error_code = 'trace_config_not_exist'
  70. description = "Trace config not exist."
  71. code = 400
  72. class TracingConfigIsExist(BaseHTTPException):
  73. error_code = 'trace_config_is_exist'
  74. description = "Trace config is exist."
  75. code = 400
  76. class TracingConfigCheckError(BaseHTTPException):
  77. error_code = 'trace_config_check_error'
  78. description = "Invalid Credentials."
  79. code = 400