mirror of
https://github.com/open-webui/open-webui
synced 2025-04-23 07:45:18 +00:00
improved error handling for deleting collections that do not exist in chromadb
This commit is contained in:
parent
f872bda19b
commit
bdd236fa3a
@ -166,12 +166,17 @@ class ChromaClient:
|
|||||||
filter: Optional[dict] = None,
|
filter: Optional[dict] = None,
|
||||||
):
|
):
|
||||||
# Delete the items from the collection based on the ids.
|
# Delete the items from the collection based on the ids.
|
||||||
collection = self.client.get_collection(name=collection_name)
|
try:
|
||||||
if collection:
|
collection = self.client.get_collection(name=collection_name)
|
||||||
if ids:
|
if collection:
|
||||||
collection.delete(ids=ids)
|
if ids:
|
||||||
elif filter:
|
collection.delete(ids=ids)
|
||||||
collection.delete(where=filter)
|
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):
|
def reset(self):
|
||||||
# Resets the database. This will delete all collections and item entries.
|
# Resets the database. This will delete all collections and item entries.
|
||||||
|
Loading…
Reference in New Issue
Block a user