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.

SearchApi - Return error message instead of raising a ValueError (#11083)

SebastjanPrachovskij17ee731546a8
diff --git a/api/core/tools/provider/builtin/searchapi/tools/google.py b/api/core/tools/provider/builtin/searchapi/tools/google.py
index 17e2978194c..29d36f5f232 100644
--- a/api/core/tools/provider/builtin/searchapi/tools/google.py
+++ b/api/core/tools/provider/builtin/searchapi/tools/google.py
@@ -45,7 +45,7 @@ class SearchAPI:
def _process_response(res: dict, type: str) -> str:
"""Process response from SearchAPI."""
if "error" in res:
- raise ValueError(f"Got error from SearchApi: {res['error']}")
+ return res["error"]
toret = ""
if type == "text":
diff --git a/api/core/tools/provider/builtin/searchapi/tools/google_jobs.py b/api/core/tools/provider/builtin/searchapi/tools/google_jobs.py
index c478bc108b4..de42360898b 100644
--- a/api/core/tools/provider/builtin/searchapi/tools/google_jobs.py
+++ b/api/core/tools/provider/builtin/searchapi/tools/google_jobs.py
@@ -45,7 +45,7 @@ class SearchAPI:
def _process_response(res: dict, type: str) -> str:
"""Process response from SearchAPI."""
if "error" in res:
- raise ValueError(f"Got error from SearchApi: {res['error']}")
+ return res["error"]
toret = ""
if type == "text":
diff --git a/api/core/tools/provider/builtin/searchapi/tools/google_news.py b/api/core/tools/provider/builtin/searchapi/tools/google_news.py
index 562bc01964b..c8b3ccda05e 100644
--- a/api/core/tools/provider/builtin/searchapi/tools/google_news.py
+++ b/api/core/tools/provider/builtin/searchapi/tools/google_news.py
@@ -45,7 +45,7 @@ class SearchAPI:
def _process_response(res: dict, type: str) -> str:
"""Process response from SearchAPI."""
if "error" in res:
- raise ValueError(f"Got error from SearchApi: {res['error']}")
+ return res["error"]
toret = ""
if type == "text":
diff --git a/api/core/tools/provider/builtin/searchapi/tools/youtube_transcripts.py b/api/core/tools/provider/builtin/searchapi/tools/youtube_transcripts.py
index 1867cf7be79..b14821f8312 100644
--- a/api/core/tools/provider/builtin/searchapi/tools/youtube_transcripts.py
+++ b/api/core/tools/provider/builtin/searchapi/tools/youtube_transcripts.py
@@ -45,7 +45,7 @@ class SearchAPI:
def _process_response(res: dict) -> str:
"""Process response from SearchAPI."""
if "error" in res:
- raise ValueError(f"Got error from SearchApi: {res['error']}")
+ return res["error"]
toret = ""
if "transcripts" in res and "text" in res["transcripts"][0]: