forked from Archives/langchain
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.
This commit is contained in:
parent
2c0023393b
commit
0cf934ce7d
@ -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…
Reference in New Issue
Block a user