From e98c3d8393320e9eeb8a5edd88744fcf0e68a645 Mon Sep 17 00:00:00 2001 From: Raven95676 Date: Fri, 18 Apr 2025 16:19:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Gemini=E4=BF=9D=E8=AF=81=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E9=97=B4=E7=9A=84=E4=BA=92=E6=96=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/provider/sources/gemini_source.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/astrbot/core/provider/sources/gemini_source.py b/astrbot/core/provider/sources/gemini_source.py index 7bef1f726..526e631ed 100644 --- a/astrbot/core/provider/sources/gemini_source.py +++ b/astrbot/core/provider/sources/gemini_source.py @@ -143,18 +143,18 @@ class ProviderGoogleGenAI(Provider): native_coderunner = self.provider_config.get("gm_native_coderunner", False) native_search = self.provider_config.get("gm_native_search", False) - if native_coderunner or native_search: - if tools: - logger.warning("Gemini原生工具已启用,函数工具将被忽略") - tool_list = [] - if native_coderunner: - tool_list.append(types.Tool(code_execution=types.ToolCodeExecution())) + if native_coderunner: + tool_list = [types.Tool(code_execution=types.ToolCodeExecution())] if native_search: - tool_list.append(types.Tool(google_search=types.GoogleSearch())) + logger.warning("已启用代码执行工具,搜索工具将被忽略") + if tools: + logger.warning("已启用代码执行工具,函数工具将被忽略") + elif native_search: + tool_list = [types.Tool(google_search=types.GoogleSearch())] + if tools: + logger.warning("已启用搜索工具,函数工具将被忽略") elif tools and (func_desc := tools.get_func_desc_google_genai_style()): - tool_list = [ - types.Tool(function_declarations=func_desc["function_declarations"]) - ] + tool_list = [types.Tool(function_declarations=func_desc["function_declarations"])] return types.GenerateContentConfig( system_instruction=system_instruction,