From f5b3d94d160beac5ebf23425d9a6a04cd452c3f3 Mon Sep 17 00:00:00 2001 From: Raven95676 Date: Fri, 2 May 2025 15:36:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3thinking=5Fconfig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/config/default.py | 8 +------- astrbot/core/provider/sources/gemini_source.py | 16 ++++++++++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index 0a27e62ce..f82dffe9d 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -569,7 +569,6 @@ CONFIG_METADATA_2 = { "dangerous_content": "BLOCK_MEDIUM_AND_ABOVE", }, "gm_thinking_config": { - "enable": False, "budget": 0, }, }, @@ -809,15 +808,10 @@ CONFIG_METADATA_2 = { "description": "Gemini思考设置", "type": "object", "items": { - "enable": { - "description": "启用思考", - "type": "bool", - "hint": "启用后,模型将在可用时输出思考过程", - }, "budget": { "description": "思考预算", "type": "int", - "hint": "模型应该生成的思考Token的数量", + "hint": "模型应该生成的思考Token的数量,设为0关闭思考。除gemini-2.5-flash外的模型会静默忽略此参数。", }, }, }, diff --git a/astrbot/core/provider/sources/gemini_source.py b/astrbot/core/provider/sources/gemini_source.py index 9a5c0235f..bf2349533 100644 --- a/astrbot/core/provider/sources/gemini_source.py +++ b/astrbot/core/provider/sources/gemini_source.py @@ -179,13 +179,17 @@ class ProviderGoogleGenAI(Provider): tools=tool_list, safety_settings=self.safety_settings if self.safety_settings else None, thinking_config=types.ThinkingConfig( - include_thoughts=self.provider_config.get("gm_thinking_config", {}).get( - "enable", False + thinking_budget=min( + int( + self.provider_config.get("gm_thinking_config", {}).get( + "budget", 0 + ) + ), + 24576, ), - thinking_budget=self.provider_config.get("gm_thinking_config", {}).get( - "budget", 0 - ), - ), + ) + if "gemini-2.5-flash" in self.get_model() + else None, automatic_function_calling=types.AutomaticFunctionCallingConfig( disable=True ),