From b4c196f7854bebeb07e5ea578cfc6f5098a884e6 Mon Sep 17 00:00:00 2001 From: Ian Date: Wed, 28 Jun 2023 07:50:17 +0800 Subject: [PATCH] fix pinecone delete bug (#6816) The implementation of delete in pinecone vector omits the namespace, which will cause delete failed --- langchain/vectorstores/pinecone.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/langchain/vectorstores/pinecone.py b/langchain/vectorstores/pinecone.py index 84dfa02bd1..3d4e12c6b2 100644 --- a/langchain/vectorstores/pinecone.py +++ b/langchain/vectorstores/pinecone.py @@ -354,15 +354,16 @@ class Pinecone(VectorStore): pinecone.Index(index_name), embedding.embed_query, text_key, namespace ) - def delete(self, ids: List[str]) -> None: + def delete(self, ids: List[str], namespace: Optional[str] = None) -> None: """Delete by vector IDs. - Args: ids: List of ids to delete. """ # This is the maximum number of IDs that can be deleted + if namespace is None: + namespace = self._namespace chunk_size = 1000 for i in range(0, len(ids), chunk_size): chunk = ids[i : i + chunk_size] - self._index.delete(ids=chunk) + self._index.delete(ids=chunk, namespace=namespace)