mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
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:
parent
f1070de038
commit
b4c196f785
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user