Mem0 seamlessly integrates with Pipecat, providing long-term memory capabilities for conversational AI agents. This integration allows your Pipecat-powered applications to remember past conversations and provide personalized responses based on user history.
Mem0 integration is provided through the Mem0MemoryService class in Pipecat. Here’s how to configure it:
Copy
Ask AI
from pipecat.services.mem0 import Mem0MemoryServicememory = Mem0MemoryService( api_key=os.getenv("MEM0_API_KEY"), # Your Mem0 API key user_id="unique_user_id", # Unique identifier for the end user agent_id="my_agent", # Identifier for the agent using the memory run_id="session_123", # Optional: specific conversation session ID params={ # Optional: configuration parameters "search_limit": 10, # Maximum memories to retrieve per query "search_threshold": 0.1, # Relevance threshold (0.0 to 1.0) "system_prompt": "Here are your past memories:", # Custom prefix for memories "add_as_system_message": True, # Add memories as system (True) or user (False) message "position": 1, # Position in context to insert memories })
You can customize how memories are retrieved and used:
Copy
Ask AI
memory = Mem0MemoryService( api_key=os.getenv("MEM0_API_KEY"), user_id="user123", params={ "search_limit": 5, # Retrieve up to 5 memories "search_threshold": 0.2, # Higher threshold for more relevant matches "api_version": "v2", # Mem0 API version })
memory = Mem0MemoryService( api_key=os.getenv("MEM0_API_KEY"), user_id="user123", params={ "system_prompt": "Previous conversations with this user:", "add_as_system_message": True, # Add as system message instead of user message "position": 0, # Insert at the beginning of the context })