Skip to content

armgit / mem0

Public Imported from GitHub
0

The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.

[Bug Fix] Fix issue with chromadb not working with 0.6.0 and onwards (#2279)

Deshraj Yadav32ebdaef2f67
diff --git a/mem0/vector_stores/chroma.py b/mem0/vector_stores/chroma.py
index efb9fddb9..96cc7440f 100644
--- a/mem0/vector_stores/chroma.py
+++ b/mem0/vector_stores/chroma.py
@@ -105,10 +105,10 @@ class ChromaDB(VectorStoreBase):
chromadb.Collection: The created or retrieved collection.
"""
# Skip creating collection if already exists
- collections = self.list_cols()
- for collection in collections:
- if collection.name == name:
- logging.debug(f"Collection {name} already exists. Skipping creation.")
+ collection_info = self.client.get_collection(name=name)
+ if collection_info:
+ logging.debug(f"Collection {name} already exists. Skipping creation.")
+ return collection_info
collection = self.client.get_or_create_collection(
name=name,