Skip to content

Commit

Permalink
fix: drop results when web search fails
Browse files Browse the repository at this point in the history
  • Loading branch information
parambharat committed Jun 13, 2024
1 parent d0ef945 commit 87e7df5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/wandbot/rag/retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from langchain.retrievers.document_compressors import CohereRerank
from langchain_core.documents import Document
from langchain_core.runnables import Runnable, RunnablePassthrough

from wandbot.rag.utils import get_web_contexts
from wandbot.retriever.base import VectorStore
from wandbot.retriever.web_search import YouSearch, YouSearchConfig
Expand All @@ -29,11 +30,14 @@ def reciprocal_rank_fusion(results: list[list[Document]], k=60):


def run_web_search(query, avoid=False) -> list:
if avoid:
try:
if avoid:
return []
yousearch = YouSearch(YouSearchConfig())
web_results = yousearch(query)
return get_web_contexts(web_results)
except Exception as e:
return []
yousearch = YouSearch(YouSearchConfig())
web_results = yousearch(query)
return get_web_contexts(web_results)


def rerank_results(
Expand Down

0 comments on commit 87e7df5

Please sign in to comment.