Browse Source

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

SebastjanPrachovskij 4 tháng trước cách đây
mục cha
commit
17ee731546

+ 1 - 1
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":

+ 1 - 1
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":

+ 1 - 1
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":

+ 1 - 1
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]: