Skip to content

Commit

Permalink
fix: extract tool calls correctly while arguments is empty (#6503)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinomoe authored Jul 21, 2024
1 parent f38034e commit dfb6f4f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions api/core/agent/fc_agent_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,14 @@ def extract_tool_calls(self, llm_result_chunk: LLMResultChunk) -> Union[None, li
"""
tool_calls = []
for prompt_message in llm_result_chunk.delta.message.tool_calls:
args = {}
if prompt_message.function.arguments != '':
args = json.loads(prompt_message.function.arguments)

tool_calls.append((
prompt_message.id,
prompt_message.function.name,
json.loads(prompt_message.function.arguments),
args,
))

return tool_calls
Expand All @@ -359,10 +363,14 @@ def extract_blocking_tool_calls(self, llm_result: LLMResult) -> Union[None, list
"""
tool_calls = []
for prompt_message in llm_result.message.tool_calls:
args = {}
if prompt_message.function.arguments != '':
args = json.loads(prompt_message.function.arguments)

tool_calls.append((
prompt_message.id,
prompt_message.function.name,
json.loads(prompt_message.function.arguments),
args,
))

return tool_calls
Expand Down

0 comments on commit dfb6f4f

Please sign in to comment.