mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
refac
This commit is contained in:
parent
0c4a1ac54d
commit
8197844ff7
1 changed files with 38 additions and 33 deletions
|
|
@ -668,46 +668,51 @@ def get_sources_from_items(
|
||||||
collection_names.append(f"file-{item['id']}")
|
collection_names.append(f"file-{item['id']}")
|
||||||
|
|
||||||
elif item.get("type") == "collection":
|
elif item.get("type") == "collection":
|
||||||
if (
|
# Manual Full Mode Toggle for Collection
|
||||||
item.get("context") == "full"
|
knowledge_base = Knowledges.get_knowledge_by_id(item.get("id"))
|
||||||
or request.app.state.config.BYPASS_EMBEDDING_AND_RETRIEVAL
|
|
||||||
|
if knowledge_base and (
|
||||||
|
user.role == "admin"
|
||||||
|
or knowledge_base.user_id == user.id
|
||||||
|
or has_access(user.id, "read", knowledge_base.access_control)
|
||||||
):
|
):
|
||||||
# Manual Full Mode Toggle for Collection
|
if (
|
||||||
knowledge_base = Knowledges.get_knowledge_by_id(item.get("id"))
|
item.get("context") == "full"
|
||||||
|
or request.app.state.config.BYPASS_EMBEDDING_AND_RETRIEVAL
|
||||||
if knowledge_base and (
|
|
||||||
user.role == "admin"
|
|
||||||
or knowledge_base.user_id == user.id
|
|
||||||
or has_access(user.id, "read", knowledge_base.access_control)
|
|
||||||
):
|
):
|
||||||
|
if knowledge_base and (
|
||||||
|
user.role == "admin"
|
||||||
|
or knowledge_base.user_id == user.id
|
||||||
|
or has_access(user.id, "read", knowledge_base.access_control)
|
||||||
|
):
|
||||||
|
|
||||||
file_ids = knowledge_base.data.get("file_ids", [])
|
file_ids = knowledge_base.data.get("file_ids", [])
|
||||||
|
|
||||||
documents = []
|
documents = []
|
||||||
metadatas = []
|
metadatas = []
|
||||||
for file_id in file_ids:
|
for file_id in file_ids:
|
||||||
file_object = Files.get_file_by_id(file_id)
|
file_object = Files.get_file_by_id(file_id)
|
||||||
|
|
||||||
if file_object:
|
if file_object:
|
||||||
documents.append(file_object.data.get("content", ""))
|
documents.append(file_object.data.get("content", ""))
|
||||||
metadatas.append(
|
metadatas.append(
|
||||||
{
|
{
|
||||||
"file_id": file_id,
|
"file_id": file_id,
|
||||||
"name": file_object.filename,
|
"name": file_object.filename,
|
||||||
"source": file_object.filename,
|
"source": file_object.filename,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
query_result = {
|
query_result = {
|
||||||
"documents": [documents],
|
"documents": [documents],
|
||||||
"metadatas": [metadatas],
|
"metadatas": [metadatas],
|
||||||
}
|
}
|
||||||
else:
|
|
||||||
# Fallback to collection names
|
|
||||||
if item.get("legacy"):
|
|
||||||
collection_names = item.get("collection_names", [])
|
|
||||||
else:
|
else:
|
||||||
collection_names.append(item["id"])
|
# Fallback to collection names
|
||||||
|
if item.get("legacy"):
|
||||||
|
collection_names = item.get("collection_names", [])
|
||||||
|
else:
|
||||||
|
collection_names.append(item["id"])
|
||||||
|
|
||||||
elif item.get("docs"):
|
elif item.get("docs"):
|
||||||
# BYPASS_WEB_SEARCH_EMBEDDING_AND_RETRIEVAL
|
# BYPASS_WEB_SEARCH_EMBEDDING_AND_RETRIEVAL
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue