fix(rate_limit): differentiate between tenant plan and API Key QPS limit errors
- Add logic to detect tenant plan QPS limits and return a specific error message when triggered. - Simplify boolean check in model activation quota validation.
This commit is contained in:
@@ -108,6 +108,8 @@ def require_api_key(
|
||||
# 根据错误消息判断限流类型
|
||||
if "Daily" in error_msg:
|
||||
code = BizCode.API_KEY_DAILY_LIMIT_EXCEEDED
|
||||
elif "Tenant" in error_msg:
|
||||
code = BizCode.API_KEY_QPS_LIMIT_EXCEEDED # 租户套餐速率超限,同属 QPS 类
|
||||
elif "QPS" in error_msg:
|
||||
code = BizCode.API_KEY_QPS_LIMIT_EXCEEDED
|
||||
else:
|
||||
|
||||
@@ -488,7 +488,7 @@ def check_model_activation_quota(func: Callable) -> Callable:
|
||||
logger.warning("模型激活配额检查失败:缺少 model_id 或 model_data 参数")
|
||||
return await func(*args, **kwargs)
|
||||
|
||||
if model_data.is_active is True:
|
||||
if model_data.is_active:
|
||||
try:
|
||||
from app.services.model_service import ModelConfigService
|
||||
|
||||
@@ -522,7 +522,7 @@ def check_model_activation_quota(func: Callable) -> Callable:
|
||||
logger.warning("模型激活配额检查失败:缺少 model_id 或 model_data 参数")
|
||||
return func(*args, **kwargs)
|
||||
|
||||
if model_data.is_active is True:
|
||||
if model_data.is_active:
|
||||
try:
|
||||
from app.services.model_service import ModelConfigService
|
||||
|
||||
|
||||
Reference in New Issue
Block a user