🔐 Mem0 is now SOC 2 and HIPAA compliant! We're committed to the highest standards of data security and privacy, enabling secure memory for enterprises, healthcare, and beyond. Learn more
Build an AI system that combines CrewAI’s agent-based architecture with Mem0’s memory capabilities. This integration enables persistent memory across agent interactions and personalized task execution based on user history.
Set up initial conversation and preferences storage:
Copy
Ask AI
def store_user_preferences(user_id: str, conversation: list): """Store user preferences from conversation history""" client.add(conversation, user_id=user_id)# Example conversation storagemessages = [ { "role": "user", "content": "Hi there! I'm planning a vacation and could use some advice.", }, { "role": "assistant", "content": "Hello! I'd be happy to help with your vacation planning. What kind of destination do you prefer?", }, {"role": "user", "content": "I am more of a beach person than a mountain person."}, { "role": "assistant", "content": "That's interesting. Do you like hotels or airbnb?", }, {"role": "user", "content": "I like airbnb more."},]store_user_preferences("crew_user_1", messages)
def create_travel_agent(): """Create a travel planning agent with search capabilities""" search_tool = SerperDevTool() return Agent( role="Personalized Travel Planner Agent", goal="Plan personalized travel itineraries", backstory="""You are a seasoned travel planner, known for your meticulous attention to detail.""", allow_delegation=False, memory=True, tools=[search_tool], )
def create_planning_task(agent, destination: str): """Create a travel planning task""" return Task( description=f"""Find places to live, eat, and visit in {destination}.""", expected_output=f"A detailed list of places to live, eat, and visit in {destination}.", agent=agent, )
By combining CrewAI with Mem0, you can create sophisticated AI systems that maintain context and provide personalized experiences while leveraging the power of autonomous agents.