error.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 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 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