Skip to content

Commit

Permalink
make tool parameters parsing compatible with the response of glm4 mod…
Browse files Browse the repository at this point in the history
…el in xinference provider when function tool call integerated (#11049)
  • Loading branch information
cyflhn authored Nov 25, 2024
1 parent 40a5f1c commit 87c831e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion api/core/tools/tool_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ def agent_invoke(
if parameters and len(parameters) == 1:
tool_parameters = {parameters[0].name: tool_parameters}
else:
raise ValueError(f"tool_parameters should be a dict, but got a string: {tool_parameters}")
try:
tool_parameters = json.loads(tool_parameters)
except Exception as e:
pass
if not isinstance(tool_parameters, dict):
raise ValueError(f"tool_parameters should be a dict, but got a string: {tool_parameters}")

# invoke the tool
try:
Expand Down

0 comments on commit 87c831e

Please sign in to comment.