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: some google search result raise exception (#4567)

非法操作24576a39e56c
diff --git a/api/core/tools/provider/builtin/google/tools/google_search.py b/api/core/tools/provider/builtin/google/tools/google_search.py
index 0b1978ad3e4..b5f15464c36 100644
--- a/api/core/tools/provider/builtin/google/tools/google_search.py
+++ b/api/core/tools/provider/builtin/google/tools/google_search.py
@@ -99,8 +99,11 @@ class SerpAPI:
):
toret = res["knowledge_graph"]["description"] + "\n"
if "snippet" in res["organic_results"][0].keys():
- for item in res["organic_results"]:
- toret += "content: " + item["snippet"] + "\n" + "link: " + item["link"] + "\n"
+ toret = "\n".join(
+ f"content: {item['snippet']}\nlink: {item['link']}"
+ for item in res["organic_results"]
+ if "snippet" in item and "link" in item
+ )
if (
"images_results" in res.keys()
and "thumbnail" in res["images_results"][0].keys()