Merge pull request #11955 from jfbloom22/dev

fix: Improve error handling in ChromaDB delete function for non-existent collections
This commit is contained in:
Timothy Jaeryang Baek 2025-03-22 12:46:01 -07:00 committed by GitHub
commit 07a15494e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -166,12 +166,17 @@ class ChromaClient:
filter: Optional[dict] = None,
):
# Delete the items from the collection based on the ids.
collection = self.client.get_collection(name=collection_name)
if collection:
if ids:
collection.delete(ids=ids)
elif filter:
collection.delete(where=filter)
try:
collection = self.client.get_collection(name=collection_name)
if collection:
if ids:
collection.delete(ids=ids)
elif filter:
collection.delete(where=filter)
except Exception as e:
# If collection doesn't exist, that's fine - nothing to delete
log.debug(f"Attempted to delete from non-existent collection {collection_name}. Ignoring.")
pass
def reset(self):
# Resets the database. This will delete all collections and item entries.