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.

fix: zhipu ai web_search not work (#9058)

非法操作966e65bb6620
diff --git a/api/core/model_runtime/model_providers/zhipuai/llm/llm.py b/api/core/model_runtime/model_providers/zhipuai/llm/llm.py
index ea331701abb..e0c49805230 100644
--- a/api/core/model_runtime/model_providers/zhipuai/llm/llm.py
+++ b/api/core/model_runtime/model_providers/zhipuai/llm/llm.py
@@ -223,6 +223,16 @@ class ZhipuAILargeLanguageModel(_CommonZhipuaiAI, LargeLanguageModel):
else:
new_prompt_messages.append(copy_prompt_message)
+ # zhipuai moved web_search param to tools
+ if "web_search" in model_parameters:
+ enable_web_search = model_parameters.get("web_search")
+ model_parameters.pop("web_search")
+ web_search_params = {"type": "web_search", "web_search": {"enable": enable_web_search}}
+ if "tools" in model_parameters:
+ model_parameters["tools"].append(web_search_params)
+ else:
+ model_parameters["tools"] = [web_search_params]
+
if model in {"glm-4v", "glm-4v-plus"}:
params = self._construct_glm_4v_parameter(model, new_prompt_messages, model_parameters)
else: