Update src/llm_models/utils_model.py

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
pull/1313/head
magisk317 2025-10-23 17:41:13 +08:00 committed by GitHub
parent f4829f166d
commit cc3c324d47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -283,8 +283,9 @@ class LLMRequest:
except RespNotOkException as e: except RespNotOkException as e:
# 针对鉴权/限流错误尝试轮换API Key # 针对鉴权/限流错误尝试轮换API Key
if e.status_code in {401, 403, 429}: if e.status_code in {401, 403, 429}:
rotated_key = api_provider.rotate_api_key(exclude=tried_api_keys) if rotated_key := api_provider.rotate_api_key(
if rotated_key: exclude=tried_api_keys
):
logger.warning( logger.warning(
f"模型 '{model_info.name}' 在提供商 '{api_provider.name}' 上触发 {e.status_code}已切换至新的API Key。" f"模型 '{model_info.name}' 在提供商 '{api_provider.name}' 上触发 {e.status_code}已切换至新的API Key。"
) )