community[patch]: implement adelete from VectorStore in Qdrant (#16005)

**Description:**
Implement `adelete` function from `VectorStore` in `Qdrant` to support
other asynchronous flows such as async indexing (`aindex`) which
requires `adelete` to be implemented. Since `Qdrant` can be passed an
async qdrant client, this can be supported easily.

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
Antonio Morales 2024-01-16 04:57:09 +01:00 committed by GitHub
parent 697a6f2c80
commit 476fb328ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1138,8 +1138,7 @@ class Qdrant(VectorStore):
**kwargs: Other keyword arguments that subclasses might use.
Returns:
Optional[bool]: True if deletion is successful,
False otherwise, None if not implemented.
True if deletion is successful, False otherwise.
"""
from qdrant_client.http import models as rest
@ -1149,6 +1148,37 @@ class Qdrant(VectorStore):
)
return result.status == rest.UpdateStatus.COMPLETED
@sync_call_fallback
async def adelete(
self, ids: Optional[List[str]] = None, **kwargs: Any
) -> Optional[bool]:
"""Delete by vector ID or other criteria.
Args:
ids: List of ids to delete.
**kwargs: Other keyword arguments that subclasses might use.
Returns:
True if deletion is successful, False otherwise.
"""
from qdrant_client.local.async_qdrant_local import AsyncQdrantLocal
if self.async_client is None or isinstance(
self.async_client._client, AsyncQdrantLocal
):
raise NotImplementedError(
"QdrantLocal cannot interoperate with sync and async clients"
)
from qdrant_client.http import models as rest
result = await self.async_client.delete(
collection_name=self.collection_name,
points_selector=ids,
)
return result.status == rest.UpdateStatus.COMPLETED
@classmethod
def from_texts(
cls: Type[Qdrant],