error.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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