From 671e4fd114b3663241891e2aace811dee7385ae4 Mon Sep 17 00:00:00 2001 From: Shkarupa Alex Date: Fri, 16 May 2025 22:10:25 +0300 Subject: [PATCH] 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 --- libs/core/langchain_core/indexing/api.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libs/core/langchain_core/indexing/api.py b/libs/core/langchain_core/indexing/api.py index 66c4343bb65..7e7b2c3debf 100644 --- a/libs/core/langchain_core/indexing/api.py +++ b/libs/core/langchain_core/indexing/api.py @@ -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