Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[llama_index_docs]: Added few blocks #2023

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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