From 2ee4b431d41c5edf015bfe8900d10bdd57613b49 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Wed, 15 Jan 2025 11:16:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=97=A0tool=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E6=8A=A5=E9=94=99=20#239?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/provider/sources/gemini_source.py | 2 ++ astrbot/core/provider/sources/llmtuner_source.py | 4 +++- astrbot/core/provider/sources/openai_source.py | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/astrbot/core/provider/sources/gemini_source.py b/astrbot/core/provider/sources/gemini_source.py index ac37e989b..522a19111 100644 --- a/astrbot/core/provider/sources/gemini_source.py +++ b/astrbot/core/provider/sources/gemini_source.py @@ -130,6 +130,8 @@ class ProviderGoogleGenAI(Provider): tool = None if tools: tool = tools.get_func_desc_google_genai_style() + if not tool: + tool = None system_instruction = "" for message in payloads["messages"]: diff --git a/astrbot/core/provider/sources/llmtuner_source.py b/astrbot/core/provider/sources/llmtuner_source.py index 743999fd0..7ac718a7a 100644 --- a/astrbot/core/provider/sources/llmtuner_source.py +++ b/astrbot/core/provider/sources/llmtuner_source.py @@ -83,7 +83,9 @@ class LLMTunerModelLoader(Provider): "system": system_prompt, } if func_tool: - conf["tools"] = func_tool + tool_list = func_tool.get_func_desc_openai_style() + if tool_list: + conf['tools'] = tool_list responses = await self.model.achat(**conf) diff --git a/astrbot/core/provider/sources/openai_source.py b/astrbot/core/provider/sources/openai_source.py index 7e601e958..c679579b8 100644 --- a/astrbot/core/provider/sources/openai_source.py +++ b/astrbot/core/provider/sources/openai_source.py @@ -99,7 +99,9 @@ class ProviderOpenAIOfficial(Provider): async def _query(self, payloads: dict, tools: FuncCall) -> LLMResponse: if tools: - payloads["tools"] = tools.get_func_desc_openai_style() + tool_list = tools.get_func_desc_openai_style() + if tool_list: + payloads['tools'] = tool_list completion = await self.client.chat.completions.create( **payloads,