langchain[patch]: Allow async indexing code to work for vectorstores that only defined sync delete (#30869)

`aindex` function should check not only `adelete` method, but `delete`
method too

**PR title**: "core: fix async indexing issue with adelete/delete
checking"
**PR message**: Currently `langchain.indexes.aindex` checks if vector
store has overrided adelete method. But due to `adelete` default
implementation store can have just `delete` overrided to make `adelete`
working.

---------

Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
This commit is contained in:
Shkarupa Alex 2025-05-16 22:10:25 +03:00 committed by GitHub
parent bd367ba10c
commit 671e4fd114
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -646,10 +646,13 @@ async def aindex(
)
raise ValueError(msg)
if type(destination).adelete == VectorStore.adelete:
# Checking if the vectorstore has overridden the default delete method
# implementation which just raises a NotImplementedError
msg = "Vectorstore has not implemented the delete method"
if (
type(destination).adelete == VectorStore.adelete
and type(destination).delete == VectorStore.delete
):
# Checking if the vectorstore has overridden the default adelete or delete
# methods implementation which just raises a NotImplementedError
msg = "Vectorstore has not implemented the adelete or delete method"
raise ValueError(msg)
elif isinstance(destination, DocumentIndex):
pass