-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Qdrant vectorstore support (#260)
* feat: Qdrant vectorstore support * chore: review changes * docs: Updated README.md
- Loading branch information
Showing
9 changed files
with
208 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from typing import Any, List, Optional, Type, cast | ||
|
||
from llama_index.vector_stores.qdrant import QdrantVectorStore as LIQdrantVectorStore | ||
|
||
from .base import LlamaIndexVectorStore | ||
|
||
|
||
class QdrantVectorStore(LlamaIndexVectorStore): | ||
_li_class: Type[LIQdrantVectorStore] = LIQdrantVectorStore | ||
|
||
def __init__( | ||
self, | ||
collection_name, | ||
url: Optional[str] = None, | ||
api_key: Optional[str] = None, | ||
client_kwargs: Optional[dict] = None, | ||
**kwargs: Any, | ||
): | ||
self._collection_name = collection_name | ||
self._url = url | ||
self._api_key = api_key | ||
self._client_kwargs = client_kwargs | ||
self._kwargs = kwargs | ||
|
||
super().__init__( | ||
collection_name=collection_name, | ||
url=url, | ||
api_key=api_key, | ||
client_kwargs=client_kwargs, | ||
**kwargs, | ||
) | ||
self._client = cast(LIQdrantVectorStore, self._client) | ||
|
||
def delete(self, ids: List[str], **kwargs): | ||
"""Delete vector embeddings from vector stores | ||
Args: | ||
ids: List of ids of the embeddings to be deleted | ||
kwargs: meant for vectorstore-specific parameters | ||
""" | ||
from qdrant_client import models | ||
|
||
self._client.client.delete( | ||
collection_name=self._collection_name, | ||
points_selector=models.PointIdsList( | ||
points=ids, | ||
), | ||
**kwargs, | ||
) | ||
|
||
def drop(self): | ||
"""Delete entire collection from vector stores""" | ||
self._client.client.delete_collection(self._collection_name) | ||
|
||
def count(self) -> int: | ||
return self._client.client.count( | ||
collection_name=self._collection_name, exact=True | ||
).count | ||
|
||
def __persist_flow__(self): | ||
return { | ||
"collection_name": self._collection_name, | ||
"url": self._url, | ||
"api_key": self._api_key, | ||
"client_kwargs": self._client_kwargs, | ||
**self._kwargs, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters