Skip to main content
LlamaIndex supports Mem0 as a memory store. In this guide, we’ll show you how to use it.
Mem0Memory now supports ReAct and FunctionCalling agents.

Installation

To install the required package, run:

Setup with Mem0 Platform

Set your Mem0 Platform API key as an environment variable. You can replace <your-mem0-api-key> with your actual API key:
You can obtain your Mem0 Platform API key from the Mem0 Platform.
Import the necessary modules and create a Mem0Memory instance:
Context is used to identify the user, agent or the conversation in the Mem0. It is required to be passed in the at least one of the fields in the Mem0Memory constructor. It can be any of the following:
search_msg_limit is optional, default is 5. It is the number of messages from the chat history to be used for memory retrieval from Mem0. More number of messages will result in more context being used for retrieval but will also increase the retrieval time and might result in some unwanted results.
search_msg_limit is different from limit. limit is the number of messages to be retrieved from Mem0 and is used in search.

Setup with Mem0 OSS

Set your Mem0 OSS by providing configuration details:
To know more about Mem0 OSS, read Mem0 OSS Quickstart.
Create a Mem0Memory instance:
Initialize the LLM

SimpleChatEngine

Use the SimpleChatEngine to start a chat with the agent with the memory.
Now we will learn how to use Mem0 with FunctionCalling and ReAct agents. Initialize the tools:

FunctionCallingAgent

ReActAgent

Key Features

  1. Memory Integration: Uses Mem0 to store and retrieve relevant information from past interactions.
  2. Personalization: Provides context-aware agent responses based on user history and preferences.
  3. Flexible Architecture: LlamaIndex allows for easy integration of the memory with the agent.
  4. Continuous Learning: Each interaction is stored, improving future responses.

Conclusion

By integrating LlamaIndex with Mem0, you can build a personalized agent that can maintain context across interactions with the agent and provide tailored recommendations and assistance.

LlamaIndex Multiagent Cookbook

Build multi-agent systems with LlamaIndex and Mem0

LlamaIndex ReAct Cookbook

Create ReAct agents with LlamaIndex
Enjoying Mem0? Star us on GitHub — it takes two seconds and helps more developers discover open-source memory.