chore: compatible wit qdrant v1.7.3
This commit is contained in:
parent
9c9d55b697
commit
fb4166ba2a
1 changed files with 31 additions and 4 deletions
|
|
@ -67,9 +67,22 @@ class QdrantVectorDBStorage(BaseVectorStorage):
|
||||||
def create_collection_if_not_exist(
|
def create_collection_if_not_exist(
|
||||||
client: QdrantClient, collection_name: str, **kwargs
|
client: QdrantClient, collection_name: str, **kwargs
|
||||||
):
|
):
|
||||||
if client.collection_exists(collection_name):
|
exists = False
|
||||||
return
|
if hasattr(client, "collection_exists"):
|
||||||
client.create_collection(collection_name, **kwargs)
|
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):
|
def __post_init__(self):
|
||||||
# Check for QDRANT_WORKSPACE environment variable first (higher priority)
|
# Check for QDRANT_WORKSPACE environment variable first (higher priority)
|
||||||
|
|
@ -464,9 +477,23 @@ class QdrantVectorDBStorage(BaseVectorStorage):
|
||||||
async with get_storage_lock():
|
async with get_storage_lock():
|
||||||
try:
|
try:
|
||||||
# Delete the collection and recreate it
|
# 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)
|
self._client.delete_collection(self.final_namespace)
|
||||||
|
|
||||||
|
|
||||||
# Recreate the collection
|
# Recreate the collection
|
||||||
QdrantVectorDBStorage.create_collection_if_not_exist(
|
QdrantVectorDBStorage.create_collection_if_not_exist(
|
||||||
self._client,
|
self._client,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue