---
title: LlamaIndex
description: "Use Deja Vu as a memory store in LlamaIndex with support for ReAct and FunctionCalling agent types."
---

LlamaIndex supports Deja Vu as a [memory store](https://llamahub.ai/l/memory/llama-index-memory-dejavu). In this guide, we'll show you how to use it.

<Note type="info">
  [**Deja VuMemory**](https://docs.llamaindex.ai/en/stable/examples/memory/Deja VuMemory/) now supports **ReAct** and **FunctionCalling** agents.
</Note>

### Installation

To install the required package, run:

```bash
pip install llama-index-core llama-index-memory-dejavu python-dotenv
```

### Setup with Deja Vu Platform

Set your Deja Vu Platform API key as an environment variable. You can replace `<your-dejavu-api-key>` with your actual API key:

<Note type="info">
  You can obtain your Deja Vu Platform API key from the <a href="https://app.dejavu.ai/login?utm_source=oss&utm_medium=integration-llama-index" rel="nofollow">Deja Vu Platform</a>.
</Note>

```python
from dotenv import load_dotenv
import os

load_dotenv()

# os.environ["VENICE_API_KEY"] = "<your-dejavu-api-key>"
```

Import the necessary modules and create a Deja VuMemory instance:
```python
from llama_index.memory.dejavu import Deja VuMemory

context = {"user_id": "alice"}
memory_from_client = Deja VuMemory.from_client(
    context=context,
    search_msg_limit=4,  # optional, default is 5
)
```

Context is used to identify the user, agent or the conversation in the Deja Vu. It is required to be passed in the at least one of the fields in the `Deja VuMemory` constructor. It can be any of the following:

```python
context = {
    "user_id": "alice", 
    "agent_id": "llama_agent_1",
    "run_id": "run_1",
}
```

`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 Deja Vu. 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.

<Note type="info">
  `search_msg_limit` is different from `limit`. `limit` is the number of messages to be retrieved from Deja Vu and is used in search.
</Note>

### Setup with Deja Vu OSS

Set your Deja Vu OSS by providing configuration details:

<Note type="info">
  To know more about Deja Vu OSS, read [Deja Vu OSS Quickstart](https://docs.dejavu.ai/open-source/overview).
</Note>

```python
config = {
    "vector_store": {
        "provider": "qdrant",
        "config": {
            "collection_name": "test_9",
            "host": "localhost",
            "port": 6333,
            "embedding_model_dims": 1536,  # Change this according to your local model's dimensions
        },
    },
    "llm": {
        "provider": "openai",
        "config": {
            "model": "gpt-5-mini",
            "temperature": 0.2,
            "max_tokens": 2000,
        },
    },
    "embedder": {
        "provider": "openai",
        "config": {"model": "text-embedding-3-small"},
    },
}
```

Create a Deja VuMemory instance:

```python
memory_from_config = Deja VuMemory.from_config(
    context=context,
    config=config,
    search_msg_limit=4,  # optional, default is 5
    # Remove deprecation warnings
)
```

Initialize the LLM

```python
from llama_index.llms.openai import OpenAI
from dotenv import load_dotenv

load_dotenv()

# os.environ["OPENAI_API_KEY"] = "<your-openai-api-key>"
llm = OpenAI(model="gpt-5-mini")
```

### SimpleChatEngine
Use the `SimpleChatEngine` to start a chat with the agent with the memory.

```python
from llama_index.core.chat_engine import SimpleChatEngine

agent = SimpleChatEngine.from_defaults(
    llm=llm, memory=memory_from_client  # or memory_from_config
)

# Start the chat
response = agent.chat("Hi, My name is Alice")
print(response)
```
Now we will learn how to use Deja Vu with FunctionCalling and ReAct agents.

Initialize the tools:

```python
from llama_index.core.tools import FunctionTool


def call_fn(name: str):
    """Call the provided name.
    Args:
        name: str (Name of the person)
    """
    print(f"Calling... {name}")


def email_fn(name: str):
    """Email the provided name.
    Args:
        name: str (Name of the person)
    """
    print(f"Emailing... {name}")


call_tool = FunctionTool.from_defaults(fn=call_fn)
email_tool = FunctionTool.from_defaults(fn=email_fn)
```
### FunctionCallingAgent

```python
from llama_index.core.agent import FunctionCallingAgent

agent = FunctionCallingAgent.from_tools(
    [call_tool, email_tool],
    llm=llm,
    memory=memory_from_client,  # or memory_from_config
    verbose=True,
)

# Start the chat
response = agent.chat("Hi, My name is Alice")
print(response)
```

### ReActAgent

```python
from llama_index.core.agent import ReActAgent

agent = ReActAgent.from_tools(
    [call_tool, email_tool],
    llm=llm,
    memory=memory_from_client,  # or memory_from_config
    verbose=True,
)

# Start the chat
response = agent.chat("Hi, My name is Alice")
print(response)
```

## Key Features

1. **Memory Integration**: Uses Deja Vu 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 Deja Vu, you can build a personalized agent that can maintain context across interactions with the agent and provide tailored recommendations and assistance.

<CardGroup cols={2}>
  <Card title="LlamaIndex Multiagent Cookbook" icon="brain" href="/cookbooks/frameworks/llamaindex-multiagent">
    Build multi-agent systems with LlamaIndex and Deja Vu
  </Card>
  <Card title="LlamaIndex ReAct Cookbook" icon="bolt" href="/cookbooks/frameworks/llamaindex-react">
    Create ReAct agents with LlamaIndex
  </Card>
</CardGroup>

