From fb4166ba2a4a1cfaa2f339432cdff4dfd2f97fc1 Mon Sep 17 00:00:00 2001 From: luxiang Date: Wed, 10 Sep 2025 20:07:49 +0800 Subject: [PATCH] chore: compatible wit qdrant v1.7.3 --- lightrag/kg/qdrant_impl.py | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/lightrag/kg/qdrant_impl.py b/lightrag/kg/qdrant_impl.py index dad95bbc..edad8200 100644 --- a/lightrag/kg/qdrant_impl.py +++ b/lightrag/kg/qdrant_impl.py @@ -67,9 +67,22 @@ class QdrantVectorDBStorage(BaseVectorStorage): def create_collection_if_not_exist( client: QdrantClient, collection_name: str, **kwargs ): - if client.collection_exists(collection_name): - return - client.create_collection(collection_name, **kwargs) + exists = False + if hasattr(client, "collection_exists"): + try: + exists = client.collection_exists(collection_name) + except Exception: + exists = False + else: + try: + client.get_collection(collection_name) + exists = True + except Exception: + exists = False + + if not exists: + client.create_collection(collection_name, **kwargs) + def __post_init__(self): # Check for QDRANT_WORKSPACE environment variable first (higher priority) @@ -464,9 +477,23 @@ class QdrantVectorDBStorage(BaseVectorStorage): async with get_storage_lock(): try: # Delete the collection and recreate it - if self._client.collection_exists(self.final_namespace): + exists = False + if hasattr(self._client, "collection_exists"): + try: + exists = self._client.collection_exists(self.final_namespace) + except Exception: + exists = False + else: + try: + self._client.get_collection(self.final_namespace) + exists = True + except Exception: + exists = False + + if exists: self._client.delete_collection(self.final_namespace) + # Recreate the collection QdrantVectorDBStorage.create_collection_if_not_exist( self._client,