mirror of
https://github.com/open-webui/open-webui
synced 2025-05-29 09:42:12 +00:00
refac
This commit is contained in:
parent
6751d68034
commit
64a0b28dab
@ -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"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user