2023-05-15 08:51:32 +08:00
|
|
|
from libs.exception import BaseHTTPException
|
|
|
|
|
|
|
|
|
|
|
|
class AppUnavailableError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "app_unavailable"
|
2023-05-22 17:39:28 +08:00
|
|
|
description = "App unavailable, please check your app configurations."
|
2023-05-15 08:51:32 +08:00
|
|
|
code = 400
|
|
|
|
|
|
|
|
|
|
|
|
class NotCompletionAppError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "not_completion_app"
|
2023-05-22 17:39:28 +08:00
|
|
|
description = "Please check if your Completion app mode matches the right API route."
|
2023-05-15 08:51:32 +08:00
|
|
|
code = 400
|
|
|
|
|
|
|
|
|
|
|
|
class NotChatAppError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "not_chat_app"
|
2024-04-08 18:51:46 +08:00
|
|
|
description = "Please check if your app mode matches the right API route."
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
|
|
|
|
class NotWorkflowAppError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "not_workflow_app"
|
2024-04-08 18:51:46 +08:00
|
|
|
description = "Please check if your Workflow app mode matches the right API route."
|
2023-05-15 08:51:32 +08:00
|
|
|
code = 400
|
|
|
|
|
|
|
|
|
|
|
|
class ConversationCompletedError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "conversation_completed"
|
2023-05-22 17:39:28 +08:00
|
|
|
description = "The conversation has ended. Please start a new conversation."
|
2023-05-15 08:51:32 +08:00
|
|
|
code = 400
|
|
|
|
|
|
|
|
|
|
|
|
class ProviderNotInitializeError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "provider_not_initialize"
|
|
|
|
description = (
|
|
|
|
"No valid model provider credentials found. "
|
|
|
|
"Please go to Settings -> Model Provider to complete your provider credentials."
|
|
|
|
)
|
2023-05-15 08:51:32 +08:00
|
|
|
code = 400
|
|
|
|
|
|
|
|
|
|
|
|
class ProviderQuotaExceededError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "provider_quota_exceeded"
|
|
|
|
description = (
|
|
|
|
"Your quota for Dify Hosted OpenAI has been exhausted. "
|
|
|
|
"Please go to Settings -> Model Provider to complete your own provider credentials."
|
|
|
|
)
|
2023-05-15 08:51:32 +08:00
|
|
|
code = 400
|
|
|
|
|
|
|
|
|
|
|
|
class ProviderModelCurrentlyNotSupportError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "model_currently_not_support"
|
2023-05-22 17:39:28 +08:00
|
|
|
description = "Dify Hosted OpenAI trial currently not support the GPT-4 model."
|
2023-05-15 08:51:32 +08:00
|
|
|
code = 400
|
|
|
|
|
|
|
|
|
|
|
|
class CompletionRequestError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "completion_request_error"
|
2023-05-15 08:51:32 +08:00
|
|
|
description = "Completion request failed."
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
|
|
|
|
class AppMoreLikeThisDisabledError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "app_more_like_this_disabled"
|
2023-05-22 17:39:28 +08:00
|
|
|
description = "The 'More like this' feature is disabled. Please refresh your page."
|
2023-05-15 08:51:32 +08:00
|
|
|
code = 403
|
|
|
|
|
|
|
|
|
|
|
|
class AppSuggestedQuestionsAfterAnswerDisabledError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "app_suggested_questions_after_answer_disabled"
|
2023-05-22 17:39:28 +08:00
|
|
|
description = "The 'Suggested Questions After Answer' feature is disabled. Please refresh your page."
|
2023-05-15 08:51:32 +08:00
|
|
|
code = 403
|
2023-07-07 17:50:42 +08:00
|
|
|
|
|
|
|
|
|
|
|
class NoAudioUploadedError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "no_audio_uploaded"
|
2023-07-07 17:50:42 +08:00
|
|
|
description = "Please upload your audio."
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
|
|
|
|
class AudioTooLargeError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "audio_too_large"
|
2023-07-07 17:50:42 +08:00
|
|
|
description = "Audio size exceeded. {message}"
|
|
|
|
code = 413
|
|
|
|
|
|
|
|
|
|
|
|
class UnsupportedAudioTypeError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "unsupported_audio_type"
|
2023-07-07 17:50:42 +08:00
|
|
|
description = "Audio type not allowed."
|
|
|
|
code = 415
|
|
|
|
|
|
|
|
|
|
|
|
class ProviderNotSupportSpeechToTextError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "provider_not_support_speech_to_text"
|
2023-07-07 17:50:42 +08:00
|
|
|
description = "Provider not support speech to text."
|
2023-11-13 22:05:46 +08:00
|
|
|
code = 400
|
|
|
|
|
|
|
|
|
|
|
|
class NoFileUploadedError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "no_file_uploaded"
|
2023-11-13 22:05:46 +08:00
|
|
|
description = "Please upload your file."
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
|
|
|
|
class TooManyFilesError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "too_many_files"
|
2023-11-13 22:05:46 +08:00
|
|
|
description = "Only one file is allowed."
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
|
|
|
|
class FileTooLargeError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "file_too_large"
|
2023-11-13 22:05:46 +08:00
|
|
|
description = "File size exceeded. {message}"
|
|
|
|
code = 413
|
|
|
|
|
|
|
|
|
|
|
|
class UnsupportedFileTypeError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "unsupported_file_type"
|
2023-11-13 22:05:46 +08:00
|
|
|
description = "File type not allowed."
|
|
|
|
code = 415
|
2024-05-15 16:14:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
class WebSSOAuthRequiredError(BaseHTTPException):
|
2024-08-26 15:29:10 +08:00
|
|
|
error_code = "web_sso_auth_required"
|
2024-05-15 16:14:49 +08:00
|
|
|
description = "Web SSO authentication required."
|
|
|
|
code = 401
|
2024-08-26 19:36:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
class InvokeRateLimitError(BaseHTTPException):
|
|
|
|
"""Raised when the Invoke returns rate limit error."""
|
|
|
|
|
|
|
|
error_code = "rate_limit_error"
|
|
|
|
description = "Rate Limit Error"
|
|
|
|
code = 429
|