error.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 AppMoreLikeThisDisabledError(BaseHTTPException):
  38. error_code = 'app_more_like_this_disabled'
  39. description = "The 'More like this' feature is disabled. Please refresh your page."
  40. code = 403
  41. class AppSuggestedQuestionsAfterAnswerDisabledError(BaseHTTPException):
  42. error_code = 'app_suggested_questions_after_answer_disabled'
  43. description = "The 'Suggested Questions After Answer' feature is disabled. Please refresh your page."
  44. code = 403