From cc3c324d470000117c7c1245020dd5228948b894 Mon Sep 17 00:00:00 2001 From: magisk317 <93979778+magisk317@users.noreply.github.com> Date: Thu, 23 Oct 2025 17:41:13 +0800 Subject: [PATCH] Update src/llm_models/utils_model.py Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- src/llm_models/utils_model.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/llm_models/utils_model.py b/src/llm_models/utils_model.py index b6118090..2da1b56a 100644 --- a/src/llm_models/utils_model.py +++ b/src/llm_models/utils_model.py @@ -283,8 +283,9 @@ class LLMRequest: except RespNotOkException as e: # 针对鉴权/限流错误,尝试轮换API Key if e.status_code in {401, 403, 429}: - rotated_key = api_provider.rotate_api_key(exclude=tried_api_keys) - if rotated_key: + if rotated_key := api_provider.rotate_api_key( + exclude=tried_api_keys + ): logger.warning( f"模型 '{model_info.name}' 在提供商 '{api_provider.name}' 上触发 {e.status_code},已切换至新的API Key。" )