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,7 +409,12 @@ async def chat_web_search_handler(
|
||||
}
|
||||
)
|
||||
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],
|
||||
@ -418,6 +423,17 @@ async def chat_web_search_handler(
|
||||
"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(
|
||||
{
|
||||
"docs": results.get("docs", []),
|
||||
"name": searchQuery,
|
||||
"type": "web_search",
|
||||
"urls": results["filenames"],
|
||||
}
|
||||
)
|
||||
|
||||
form_data["files"] = files
|
||||
except Exception as e:
|
||||
|
Loading…
Reference in New Issue
Block a user