From 575c12f80c469bf0e888af3dc05e496aa68e529f Mon Sep 17 00:00:00 2001 From: Athanasios Oikonomou Date: Tue, 15 Apr 2025 01:35:39 +0300 Subject: [PATCH] feat: add QDRANT_ON_DISK configuration option for Qdrant integration This commit will allow configuring the on_disk client parameter, to reduce the memory usage. https://qdrant.tech/documentation/concepts/storage/?q=mmap#configuring-memmap-storage Default is false, keeping vectors in memory. --- backend/open_webui/config.py | 1 + backend/open_webui/retrieval/vector/dbs/qdrant.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index 3b40977f2..55d3e8260 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -1693,6 +1693,7 @@ MILVUS_TOKEN = os.environ.get("MILVUS_TOKEN", None) # Qdrant QDRANT_URI = os.environ.get("QDRANT_URI", None) QDRANT_API_KEY = os.environ.get("QDRANT_API_KEY", None) +QDRANT_ON_DISK = os.environ.get("QDRANT_ON_DISK", "false").lower() == "true" # OpenSearch OPENSEARCH_URI = os.environ.get("OPENSEARCH_URI", "https://localhost:9200") diff --git a/backend/open_webui/retrieval/vector/dbs/qdrant.py b/backend/open_webui/retrieval/vector/dbs/qdrant.py index be0df6c6a..895098e29 100644 --- a/backend/open_webui/retrieval/vector/dbs/qdrant.py +++ b/backend/open_webui/retrieval/vector/dbs/qdrant.py @@ -6,7 +6,7 @@ from qdrant_client.http.models import PointStruct from qdrant_client.models import models from open_webui.retrieval.vector.main import VectorItem, SearchResult, GetResult -from open_webui.config import QDRANT_URI, QDRANT_API_KEY +from open_webui.config import QDRANT_URI, QDRANT_API_KEY, QDRANT_ON_DISK from open_webui.env import SRC_LOG_LEVELS NO_LIMIT = 999999999 @@ -20,6 +20,7 @@ class QdrantClient: self.collection_prefix = "open-webui" self.QDRANT_URI = QDRANT_URI self.QDRANT_API_KEY = QDRANT_API_KEY + self.QDRANT_ON_DISK = QDRANT_ON_DISK self.client = ( Qclient(url=self.QDRANT_URI, api_key=self.QDRANT_API_KEY) if self.QDRANT_URI @@ -50,7 +51,7 @@ class QdrantClient: self.client.create_collection( collection_name=collection_name_with_prefix, vectors_config=models.VectorParams( - size=dimension, distance=models.Distance.COSINE + size=dimension, distance=models.Distance.COSINE, on_disk=self.QDRANT_ON_DISK ), )