Skip to content

Commit

Permalink
fix: 无tool导致的报错 #239
Browse files Browse the repository at this point in the history
  • Loading branch information
Soulter committed Jan 15, 2025
1 parent 9a76ce7 commit 6b5fef8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions astrbot/core/provider/sources/gemini_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand Down
4 changes: 3 additions & 1 deletion astrbot/core/provider/sources/llmtuner_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion astrbot/core/provider/sources/openai_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6b5fef8

Please sign in to comment.