fix pinecone delete bug (#6816)

The implementation of delete in pinecone vector omits the namespace,
which will cause delete failed
This commit is contained in:
Ian 2023-06-28 07:50:17 +08:00 committed by GitHub
parent f1070de038
commit b4c196f785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -354,15 +354,16 @@ class Pinecone(VectorStore):
pinecone.Index(index_name), embedding.embed_query, text_key, namespace 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. """Delete by vector IDs.
Args: Args:
ids: List of ids to delete. ids: List of ids to delete.
""" """
# This is the maximum number of IDs that can be deleted # This is the maximum number of IDs that can be deleted
if namespace is None:
namespace = self._namespace
chunk_size = 1000 chunk_size = 1000
for i in range(0, len(ids), chunk_size): for i in range(0, len(ids), chunk_size):
chunk = ids[i : i + chunk_size] chunk = ids[i : i + chunk_size]
self._index.delete(ids=chunk) self._index.delete(ids=chunk, namespace=namespace)