Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

make tool parameters parsing compatible with the response of glm4 model in xinference provider when function tool call integerated (#11049)

cyflhn87c831e5dd18
diff --git a/api/core/tools/tool_engine.py b/api/core/tools/tool_engine.py
index dbd97c8151e..f92b43608ed 100644
--- a/api/core/tools/tool_engine.py
+++ b/api/core/tools/tool_engine.py
@@ -61,7 +61,12 @@ class ToolEngine:
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: