diff --git a/backend/open_webui/retrieval/vector/dbs/milvus_multitenancy.py b/backend/open_webui/retrieval/vector/dbs/milvus_multitenancy.py index b107c4bb51..5c80d155d3 100644 --- a/backend/open_webui/retrieval/vector/dbs/milvus_multitenancy.py +++ b/backend/open_webui/retrieval/vector/dbs/milvus_multitenancy.py @@ -62,10 +62,10 @@ class MilvusClient(VectorDBBase): def _get_collection_and_resource_id(self, collection_name: str) -> Tuple[str, str]: """ Maps the traditional collection name to multi-tenant collection and resource ID. - - WARNING: This mapping relies on current Open WebUI naming conventions for + + WARNING: This mapping relies on current Open WebUI naming conventions for collection names. If Open WebUI changes how it generates collection names - (e.g., "user-memory-" prefix, "file-" prefix, web search patterns, or hash + (e.g., "user-memory-" prefix, "file-" prefix, web search patterns, or hash formats), this mapping will break and route data to incorrect collections. POTENTIALLY CAUSING HUGE DATA CORRUPTION, DATA CONSISTENCY ISSUES AND INCORRECT DATA MAPPING INSIDE THE DATABASE. @@ -94,14 +94,10 @@ class MilvusClient(VectorDBBase): auto_id=False, max_length=36, ), - FieldSchema( - name="vector", dtype=DataType.FLOAT_VECTOR, dim=dimension - ), + FieldSchema(name="vector", dtype=DataType.FLOAT_VECTOR, dim=dimension), FieldSchema(name="text", dtype=DataType.VARCHAR, max_length=65535), FieldSchema(name="metadata", dtype=DataType.JSON), - FieldSchema( - name=RESOURCE_ID_FIELD, dtype=DataType.VARCHAR, max_length=255 - ), + FieldSchema(name=RESOURCE_ID_FIELD, dtype=DataType.VARCHAR, max_length=255), ] schema = CollectionSchema(fields, "Shared collection for multi-tenancy") collection = Collection(mt_collection_name, schema) @@ -137,9 +133,7 @@ class MilvusClient(VectorDBBase): collection = Collection(mt_collection) collection.load() - res = collection.query( - expr=f"{RESOURCE_ID_FIELD} == '{resource_id}'", limit=1 - ) + res = collection.query(expr=f"{RESOURCE_ID_FIELD} == '{resource_id}'", limit=1) return len(res) > 0 def upsert(self, collection_name: str, items: List[VectorItem]): @@ -220,18 +214,18 @@ class MilvusClient(VectorDBBase): return collection = Collection(mt_collection) - + # Build expression expr = [f"{RESOURCE_ID_FIELD} == '{resource_id}'"] if ids: # Milvus expects a string list for 'in' operator id_list_str = ", ".join([f"'{id_val}'" for id_val in ids]) expr.append(f"id in [{id_list_str}]") - + if filter: for key, value in filter.items(): - expr.append(f"metadata['{key}'] == '{value}'") - + expr.append(f"metadata['{key}'] == '{value}'") + collection.delete(" and ".join(expr)) def reset(self): @@ -245,7 +239,7 @@ class MilvusClient(VectorDBBase): ) if not utility.has_collection(mt_collection): return - + collection = Collection(mt_collection) collection.delete(f"{RESOURCE_ID_FIELD} == '{resource_id}'") diff --git a/backend/open_webui/retrieval/vector/dbs/qdrant_multitenancy.py b/backend/open_webui/retrieval/vector/dbs/qdrant_multitenancy.py index 3338341ba9..e9fa03d459 100644 --- a/backend/open_webui/retrieval/vector/dbs/qdrant_multitenancy.py +++ b/backend/open_webui/retrieval/vector/dbs/qdrant_multitenancy.py @@ -106,9 +106,9 @@ class QdrantClient(VectorDBBase): Returns: tuple: (collection_name, tenant_id) - WARNING: This mapping relies on current Open WebUI naming conventions for + WARNING: This mapping relies on current Open WebUI naming conventions for collection names. If Open WebUI changes how it generates collection names - (e.g., "user-memory-" prefix, "file-" prefix, web search patterns, or hash + (e.g., "user-memory-" prefix, "file-" prefix, web search patterns, or hash formats), this mapping will break and route data to incorrect collections. POTENTIALLY CAUSING HUGE DATA CORRUPTION, DATA CONSISTENCY ISSUES AND INCORRECT DATA MAPPING INSIDE THE DATABASE. diff --git a/backend/open_webui/retrieval/vector/factory.py b/backend/open_webui/retrieval/vector/factory.py index 8f556007b7..7888c22be8 100644 --- a/backend/open_webui/retrieval/vector/factory.py +++ b/backend/open_webui/retrieval/vector/factory.py @@ -24,7 +24,7 @@ class Vector: return MilvusClient() else: from open_webui.retrieval.vector.dbs.milvus import MilvusClient - + return MilvusClient() case VectorType.QDRANT: if ENABLE_QDRANT_MULTITENANCY_MODE: diff --git a/src/lib/components/admin/Users/Groups.svelte b/src/lib/components/admin/Users/Groups.svelte index 39dea4c4a0..3d72c96dc8 100644 --- a/src/lib/components/admin/Users/Groups.svelte +++ b/src/lib/components/admin/Users/Groups.svelte @@ -23,7 +23,11 @@ import Pencil from '$lib/components/icons/Pencil.svelte'; import GroupItem from './Groups/GroupItem.svelte'; import { createNewGroup, getGroups } from '$lib/apis/groups'; - import { getUserDefaultPermissions, getAllUsers, updateUserDefaultPermissions } from '$lib/apis/users'; + import { + getUserDefaultPermissions, + getAllUsers, + updateUserDefaultPermissions + } from '$lib/apis/users'; const i18n = getContext('i18n'); diff --git a/src/lib/components/admin/Users/Groups/Permissions.svelte b/src/lib/components/admin/Users/Groups/Permissions.svelte index c020c7c683..f9b6a75ae5 100644 --- a/src/lib/components/admin/Users/Groups/Permissions.svelte +++ b/src/lib/components/admin/Users/Groups/Permissions.svelte @@ -75,6 +75,11 @@