mirror of
https://github.com/hwchase17/langchain.git
synced 2026-04-25 01:16:55 +00:00
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:
committed by
vowelparrot
parent
bf0bbc8f2c
commit
d80017f51f
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user