enh: allow full context mode for collections

This commit is contained in:
Timothy Jaeryang Baek
2025-07-09 01:29:49 +04:00
parent d5f9bbc7a7
commit b3c4bc6041
4 changed files with 65 additions and 19 deletions

View File

@@ -479,12 +479,38 @@ def get_sources_from_files(
"documents": [[note.data.get("content", {}).get("md", "")]],
"metadatas": [[{"file_id": note.id, "name": note.title}]],
}
elif file.get("context") == "full" and file.get("type") == "file":
# Manual Full Mode Toggle
query_result = {
"documents": [[file.get("file").get("data", {}).get("content")]],
"metadatas": [[{"file_id": file.get("id"), "name": file.get("name")}]],
}
elif file.get("context") == "full":
if file.get("type") == "file":
# Manual Full Mode Toggle
query_result = {
"documents": [[file.get("file").get("data", {}).get("content")]],
"metadatas": [
[{"file_id": file.get("id"), "name": file.get("name")}]
],
}
elif file.get("type") == "collection":
# Manual Full Mode Toggle for Collection
file_ids = file.get("data", {}).get("file_ids", [])
documents = []
metadatas = []
for file_id in file_ids:
file_object = Files.get_file_by_id(file_id)
if file_object:
documents.append(file_object.data.get("content", ""))
metadatas.append(
{
"file_id": file_id,
"name": file_object.filename,
"source": file_object.filename,
}
)
query_result = {
"documents": [documents],
"metadatas": [metadatas],
}
elif (
file.get("type") != "web_search"
and request.app.state.config.BYPASS_EMBEDDING_AND_RETRIEVAL