Skip to content

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

refactor: streamline collection handling in RAGStorage (#3097)

Lorenze Jaye544ff8ba31f
diff --git a/src/crewai/memory/storage/rag_storage.py b/src/crewai/memory/storage/rag_storage.py
index fd4c77838..995bb4a7e 100644
--- a/src/crewai/memory/storage/rag_storage.py
+++ b/src/crewai/memory/storage/rag_storage.py
@@ -71,14 +71,10 @@ class RAGStorage(BaseRAGStorage):
self.app = chroma_client
- try:
- self.collection = self.app.get_collection(
- name=self.type, embedding_function=self.embedder_config
- )
- except Exception:
- self.collection = self.app.create_collection(
- name=self.type, embedding_function=self.embedder_config
- )
+ self.collection = self.app.get_or_create_collection(
+ name=self.type, embedding_function=self.embedder_config
+ )
+ logging.info(f"Collection found or created: {self.collection}")
def _sanitize_role(self, role: str) -> str:
"""