pull/1261/head
foxplaying 2025-09-24 13:30:51 +08:00 committed by GitHub
parent bdb7a2d145
commit 0a8f7a96fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 6 deletions

View File

@ -369,7 +369,7 @@ class GeminiClient(BaseClient):
) # 这里和openai不一样gemini会自己决定自己是否需要retry
@staticmethod
def clamp_thinking_budget(tb: int, model_id: str) -> int:
def clamp_thinking_budget(extra_params: dict[str, Any] | None, model_id: str) -> int:
"""
按模型限制思考预算范围仅支持指定的模型支持带数字后缀的新版本
"""
@ -382,10 +382,8 @@ class GeminiClient(BaseClient):
tb = int(extra_params["thinking_budget"])
except (ValueError, TypeError):
logger.warning(
f"无效的 thinking_budget 值 {extra_params['thinking_budget']}"
f"将使用模型自动预算模式 {THINKING_BUDGET_AUTO}"
f"无效的 thinking_budget 值 {extra_params['thinking_budget']},将使用模型自动预算模式 {tb}"
)
tb = THINKING_BUDGET_AUTO
# 优先尝试精确匹配
if model_id in THINKING_BUDGET_LIMITS:
@ -470,7 +468,7 @@ class GeminiClient(BaseClient):
# 将tool_options转换为Gemini API所需的格式
tools = _convert_tool_options(tool_options) if tool_options else None
# 解析并裁剪 thinking_budget
tb = resolve_thinking_budget(extra_params, model_info.model_identifier)
tb = self.clamp_thinking_budget(extra_params, model_info.model_identifier)
# 将response_format转换为Gemini API所需的格式
generation_config_dict = {
@ -609,7 +607,7 @@ class GeminiClient(BaseClient):
:return: 转录响应
"""
# 解析并裁剪 thinking_budget
tb = resolve_thinking_budget(extra_params, model_info.model_identifier)
tb = self.clamp_thinking_budget(extra_params, model_info.model_identifier)
# 构造 prompt + 音频输入
prompt = "Generate a transcript of the speech. The language of the transcript should **match the language of the speech**."