diff --git a/astrbot/core/provider/sources/gemini_source.py b/astrbot/core/provider/sources/gemini_source.py index ac37e98..522a191 100644 --- a/astrbot/core/provider/sources/gemini_source.py +++ b/astrbot/core/provider/sources/gemini_source.py @@ -130,6 +130,8 @@ async def _query(self, payloads: dict, tools: FuncCall) -> LLMResponse: 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 743999f..7ac718a 100644 --- a/astrbot/core/provider/sources/llmtuner_source.py +++ b/astrbot/core/provider/sources/llmtuner_source.py @@ -83,7 +83,9 @@ async def text_chat( "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 7e601e9..c679579 100644 --- a/astrbot/core/provider/sources/openai_source.py +++ b/astrbot/core/provider/sources/openai_source.py @@ -99,7 +99,9 @@ async def pop_record(self, session_id: str, pop_system_prompt: bool = False): 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,