This commit is contained in:
Timothy Jaeryang Baek 2025-04-06 15:23:40 -07:00
parent 6751d68034
commit 64a0b28dab

View File

@ -409,13 +409,29 @@ async def chat_web_search_handler(
} }
) )
elif results.get("docs"): elif results.get("docs"):
for doc_idx, doc in enumerate(results["docs"]): # Invoked when bypass embedding and retrieval is set to True
docs = results["docs"]
if len(docs) == len(results["filenames"]):
# the number of docs and filenames (urls) should be the same
for doc_idx, doc in enumerate(docs):
files.append(
{
"docs": [doc],
"name": searchQuery,
"type": "web_search",
"urls": [results["filenames"][doc_idx]],
}
)
else:
# edge case when the number of docs and filenames (urls) are not the same
# this should not happen, but if it does, we will just append the docs
files.append( files.append(
{ {
"docs": [doc], "docs": results.get("docs", []),
"name": searchQuery, "name": searchQuery,
"type": "web_search", "type": "web_search",
"urls": [results["filenames"][doc_idx]], "urls": results["filenames"],
} }
) )