catch openai rate limit error (#7658)
This commit is contained in:
parent
7cda73f192
commit
1473083a41
7 changed files with 53 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ from controllers.web.error import (
|
|||
ProviderNotInitializeError,
|
||||
ProviderQuotaExceededError,
|
||||
)
|
||||
from controllers.web.error import InvokeRateLimitError as InvokeRateLimitHttpError
|
||||
from controllers.web.wraps import WebApiResource
|
||||
from core.app.apps.base_app_queue_manager import AppQueueManager
|
||||
from core.app.entities.app_invoke_entities import InvokeFrom
|
||||
|
|
@ -24,6 +25,7 @@ from libs import helper
|
|||
from libs.helper import uuid_value
|
||||
from models.model import AppMode
|
||||
from services.app_generate_service import AppGenerateService
|
||||
from services.errors.llm import InvokeRateLimitError
|
||||
|
||||
|
||||
# define completion api for user
|
||||
|
|
@ -120,6 +122,8 @@ class ChatApi(WebApiResource):
|
|||
raise ProviderQuotaExceededError()
|
||||
except ModelCurrentlyNotSupportError:
|
||||
raise ProviderModelCurrentlyNotSupportError()
|
||||
except InvokeRateLimitError as ex:
|
||||
raise InvokeRateLimitHttpError(ex.description)
|
||||
except InvokeError as e:
|
||||
raise CompletionRequestError(e.description)
|
||||
except ValueError as e:
|
||||
|
|
|
|||
|
|
@ -125,3 +125,11 @@ class WebSSOAuthRequiredError(BaseHTTPException):
|
|||
error_code = "web_sso_auth_required"
|
||||
description = "Web SSO authentication required."
|
||||
code = 401
|
||||
|
||||
|
||||
class InvokeRateLimitError(BaseHTTPException):
|
||||
"""Raised when the Invoke returns rate limit error."""
|
||||
|
||||
error_code = "rate_limit_error"
|
||||
description = "Rate Limit Error"
|
||||
code = 429
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue