diff --git a/backend/open_webui/apps/retrieval/utils.py b/backend/open_webui/apps/retrieval/utils.py index f8c9ded5b..b796f0a75 100644 --- a/backend/open_webui/apps/retrieval/utils.py +++ b/backend/open_webui/apps/retrieval/utils.py @@ -334,7 +334,10 @@ def get_rag_context( elif file.get("collection_name"): collection_names.append(file["collection_name"]) elif file.get("id"): - collection_names.append(f"file-{file['id']}") + if file.get("legacy"): + collection_names.append(f"{file['id']}") + else: + collection_names.append(f"file-{file['id']}") collection_names = set(collection_names).difference(extracted_collections) if not collection_names: diff --git a/backend/open_webui/migrations/versions/6a39f3d8e55c_add_knowledge_table.py b/backend/open_webui/migrations/versions/6a39f3d8e55c_add_knowledge_table.py index 5521babd9..881e6ae64 100644 --- a/backend/open_webui/migrations/versions/6a39f3d8e55c_add_knowledge_table.py +++ b/backend/open_webui/migrations/versions/6a39f3d8e55c_add_knowledge_table.py @@ -65,6 +65,7 @@ def upgrade(): user_id=doc.user_id, description=doc.name, meta={ + "legacy": True, "document": True, "tags": json.loads(doc.content or "{}").get("tags", []), }, diff --git a/src/lib/components/chat/MessageInput/Commands/Knowledge.svelte b/src/lib/components/chat/MessageInput/Commands/Knowledge.svelte index ee151164a..aebcdf2e9 100644 --- a/src/lib/components/chat/MessageInput/Commands/Knowledge.svelte +++ b/src/lib/components/chat/MessageInput/Commands/Knowledge.svelte @@ -101,7 +101,12 @@ ] : []; - items = [...$knowledge, ...legacy_collections]; + items = [...$knowledge, ...legacy_collections].map((item) => { + return { + ...item, + ...{ legacy: item?.legacy ?? item?.meta?.document ?? undefined } + }; + }); fuse = new Fuse(items, { keys: ['name', 'description']