mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
Fix web research retriever for unknown links in results (#9115)
Fixes an issue with web research retriever for unknown links in results. This is currently making the retrieve crash sometimes. @rlancemartin
This commit is contained in:
parent
31cfc00845
commit
926c64da60
@ -179,15 +179,16 @@ class WebResearchRetriever(BaseRetriever):
|
|||||||
logger.info(f"Questions for Google Search: {questions}")
|
logger.info(f"Questions for Google Search: {questions}")
|
||||||
|
|
||||||
# Get urls
|
# Get urls
|
||||||
logger.info("Searching for relevat urls ...")
|
logger.info("Searching for relevant urls...")
|
||||||
urls_to_look = []
|
urls_to_look = []
|
||||||
for query in questions:
|
for query in questions:
|
||||||
# Google search
|
# Google search
|
||||||
search_results = self.search_tool(query, self.num_search_results)
|
search_results = self.search_tool(query, self.num_search_results)
|
||||||
logger.info("Searching for relevat urls ...")
|
logger.info("Searching for relevant urls...")
|
||||||
logger.info(f"Search results: {search_results}")
|
logger.info(f"Search results: {search_results}")
|
||||||
for res in search_results:
|
for res in search_results:
|
||||||
urls_to_look.append(res["link"])
|
if res.get("link", None):
|
||||||
|
urls_to_look.append(res["link"])
|
||||||
|
|
||||||
# Relevant urls
|
# Relevant urls
|
||||||
urls = set(urls_to_look)
|
urls = set(urls_to_look)
|
||||||
|
Loading…
Reference in New Issue
Block a user