Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
add Mem0 OSS support (#2429)
Parth Patel53067f8b9290
diff --git a/src/crewai/memory/storage/mem0_storage.py b/src/crewai/memory/storage/mem0_storage.pyindex be889afff..0319c6a8a 100644--- a/src/crewai/memory/storage/mem0_storage.py+++ b/src/crewai/memory/storage/mem0_storage.py@@ -1,7 +1,7 @@import osfrom typing import Any, Dict, List-from mem0 import MemoryClient+from mem0 import Memory, MemoryClientfrom crewai.memory.storage.interface import Storage@@ -32,13 +32,16 @@ class Mem0Storage(Storage):mem0_org_id = config.get("org_id")mem0_project_id = config.get("project_id")- # Initialize MemoryClient with available parameters- if mem0_org_id and mem0_project_id:- self.memory = MemoryClient(- api_key=mem0_api_key, org_id=mem0_org_id, project_id=mem0_project_id- )+ # Initialize MemoryClient or Memory based on the presence of the mem0_api_key+ if mem0_api_key:+ if mem0_org_id and mem0_project_id:+ self.memory = MemoryClient(+ api_key=mem0_api_key, org_id=mem0_org_id, project_id=mem0_project_id+ )+ else:+ self.memory = MemoryClient(api_key=mem0_api_key)else:- self.memory = MemoryClient(api_key=mem0_api_key)+ self.memory = Memory() # Fallback to Memory if no Mem0 API key is provideddef _sanitize_role(self, role: str) -> str:"""