Skip to content

Commit

Permalink
[llama_index_docs]: Added few blocks (#2023)
Browse files Browse the repository at this point in the history
  • Loading branch information
spike-spiegel-21 authored Nov 14, 2024
1 parent 802231c commit c0b9a10
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions docs/integrations/llama-index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ memory_from_client = Mem0Memory.from_client(
)
```

Mem0 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:
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:

```python
context = {
Expand All @@ -52,6 +52,10 @@ context = {

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

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

### Setup with Mem0 OSS

Set your Mem0 OSS by providing configuration details:
Expand Down Expand Up @@ -97,11 +101,21 @@ memory_from_config = Mem0Memory.from_config(
)
```

Intilaize the LLM

```python
import os
from llama_index.llms.openai import OpenAI

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

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

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

agent = SimpleChatEngine.from_defaults(
llm=llm, memory=memory_from_client # or memory_from_config
Expand Down Expand Up @@ -146,7 +160,7 @@ from llama_index.core.agent import FunctionCallingAgent
agent = FunctionCallingAgent.from_tools(
[call_tool, email_tool],
llm=llm,
memory=memory,
memory=memory_from_client, # or memory_from_config
verbose=True,
)

Expand All @@ -163,7 +177,7 @@ from llama_index.core.agent import ReActAgent
agent = ReActAgent.from_tools(
[call_tool, email_tool],
llm=llm,
memory=memory,
memory=memory_from_client, # or memory_from_config
verbose=True,
)

Expand Down

0 comments on commit c0b9a10

Please sign in to comment.