Fix NoneType has no len() in DDG tool (#3334)

Per
46ac914daa/duckduckgo_search/ddg.py (L109),
ddg function actually returns None when there is no result.
fix_agent_callbacks
Dianliang233 1 year ago committed by GitHub
parent 2c0023393b
commit 0cf934ce7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -49,7 +49,7 @@ class DuckDuckGoSearchAPIWrapper(BaseModel):
time=self.time,
max_results=self.max_results,
)
if len(results) == 0:
if results is None or len(results) == 0:
return "No good DuckDuckGo Search Result was found"
snippets = [result["body"] for result in results]
return " ".join(snippets)
@ -77,7 +77,7 @@ class DuckDuckGoSearchAPIWrapper(BaseModel):
max_results=num_results,
)
if len(results) == 0:
if results is None or len(results) == 0:
return [{"Result": "No good DuckDuckGo Search Result was found"}]
def to_metadata(result: Dict) -> Dict:

Loading…
Cancel
Save