mirror of
https://github.com/hwchase17/langchain
synced 2024-11-18 09:25:54 +00:00
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:
parent
697a6f2c80
commit
476fb328ee
@ -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],
|
||||
|
Loading…
Reference in New Issue
Block a user