Skip to content

Commit

Permalink
fix: zhipu ai web_search not work (langgenius#9058)
Browse files Browse the repository at this point in the history
  • Loading branch information
hjlarry authored and JunXu01 committed Nov 9, 2024
1 parent 56a3742 commit f4d2c31
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/core/model_runtime/model_providers/zhipuai/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,16 @@ def _generate(
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:
Expand Down

0 comments on commit f4d2c31

Please sign in to comment.