enh: vector db delete filter support

This commit is contained in:
Timothy J. Baek committed 2024-10-03 06:43:50 -07:00
1 parent 351b1dbf31
commit 325ca98773
2 files changed
+34 -7

No files matched your search

@@ -111,11 +111,19 @@ class ChromaClient:
ids=ids, documents=documents, embeddings=embeddings, metadatas=metadatas
)
def delete(self, collection_name: str, ids: list[str]):
def delete(
self,
collection_name: str,
ids: Optional[list[str]] = None,
filter: Optional[dict] = None,
):
# Delete the items from the collection based on the ids.
collection = self.client.get_collection(name=collection_name)
if collection:
collection.delete(ids=ids)
if ids:
collection.delete(ids=ids)
elif filter:
collection.delete(where=filter)
def reset(self):
# Resets the database. This will delete all collections and item entries.