error.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # -*- coding:utf-8 -*-
  2. from libs.exception import BaseHTTPException
  3. class AppUnavailableError(BaseHTTPException):
  4. error_code = 'app_unavailable'
  5. description = "App unavailable, please check your app configurations."
  6. code = 400
  7. class NotCompletionAppError(BaseHTTPException):
  8. error_code = 'not_completion_app'
  9. description = "Please check if your Completion app mode matches the right API route."
  10. code = 400
  11. class NotChatAppError(BaseHTTPException):
  12. error_code = 'not_chat_app'
  13. description = "Please check if your Chat app mode matches the right API route."
  14. code = 400
  15. class ConversationCompletedError(BaseHTTPException):
  16. error_code = 'conversation_completed'
  17. description = "The conversation has ended. Please start a new conversation."
  18. code = 400
  19. class ProviderNotInitializeError(BaseHTTPException):
  20. error_code = 'provider_not_initialize'
  21. description = "No valid model provider credentials found. " \
  22. "Please go to Settings -> Model Provider to complete your provider credentials."
  23. code = 400
  24. class ProviderQuotaExceededError(BaseHTTPException):
  25. error_code = 'provider_quota_exceeded'
  26. description = "Your quota for Dify Hosted OpenAI has been exhausted. " \
  27. "Please go to Settings -> Model Provider to complete your own provider credentials."
  28. code = 400
  29. class ProviderModelCurrentlyNotSupportError(BaseHTTPException):
  30. error_code = 'model_currently_not_support'
  31. description = "Dify Hosted OpenAI trial currently not support the GPT-4 model."
  32. code = 400
  33. class CompletionRequestError(BaseHTTPException):
  34. error_code = 'completion_request_error'
  35. description = "Completion request failed."
  36. code = 400
  37. class NoAudioUploadedError(BaseHTTPException):
  38. error_code = 'no_audio_uploaded'
  39. description = "Please upload your audio."
  40. code = 400
  41. class AudioTooLargeError(BaseHTTPException):
  42. error_code = 'audio_too_large'
  43. description = "Audio size exceeded. {message}"
  44. code = 413
  45. class UnsupportedAudioTypeError(BaseHTTPException):
  46. error_code = 'unsupported_audio_type'
  47. description = "Audio type not allowed."
  48. code = 415
  49. class ProviderNotSupportSpeechToTextError(BaseHTTPException):
  50. error_code = 'provider_not_support_speech_to_text'
  51. description = "Provider not support speech to text."
  52. code = 400