Agno Mem0Tools update (#3139)
This commit is contained in:
@@ -3,7 +3,8 @@ title: Agno
|
||||
---
|
||||
<Snippet file="security-compliance.mdx" />
|
||||
|
||||
Integrate [**Mem0**](https://github.com/mem0ai/mem0) with [Agno](https://github.com/agno-agi/agno), a Python framework for building autonomous agents. This integration enables Agno agents to access persistent memory across conversations, enhancing context retention and personalization.
|
||||
|
||||
This integration of [**Mem0**](https://github.com/mem0ai/mem0) with [Agno](https://github.com/agno-agi/agno, enables persistent, multimodal memory for Agno-based agents - improving personalization, context awareness, and continuity across conversations.
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -11,6 +12,7 @@ Integrate [**Mem0**](https://github.com/mem0ai/mem0) with [Agno](https://github.
|
||||
2. Support for multimodal interactions (text and images)
|
||||
3. Semantic search for relevant past conversations
|
||||
4. Personalized responses based on user history
|
||||
5. One-line memory integration via `Mem0Tools`
|
||||
|
||||
## Prerequisites
|
||||
|
||||
@@ -18,14 +20,41 @@ Before setting up Mem0 with Agno, ensure you have:
|
||||
|
||||
1. Installed the required packages:
|
||||
```bash
|
||||
pip install agno-ai mem0ai
|
||||
pip install agno mem0ai
|
||||
```
|
||||
|
||||
2. Valid API keys:
|
||||
- [Mem0 API Key](https://app.mem0.ai/dashboard/api-keys)
|
||||
- OpenAI API Key (for the agent model)
|
||||
|
||||
## Integration Example
|
||||
## Quick Integration (Using `Mem0Tools`)
|
||||
|
||||
The simplest way to integrate Mem0 with Agno Agents is to use Mem0 as a tool using built-in `Mem0Tools`:
|
||||
|
||||
```python
|
||||
from agno.agent import Agent
|
||||
from agno.models.openai import OpenAIChat
|
||||
from agno.tools.mem0 import Mem0Tools
|
||||
|
||||
agent = Agent(
|
||||
name="Memory Agent",
|
||||
model=OpenAIChat(id="gpt-4o-mini"),
|
||||
tools=[Mem0Tools()],
|
||||
description="An assistant that remembers and personalizes using Mem0 memory."
|
||||
)
|
||||
```
|
||||
|
||||
This enables memory functionality out of the box:
|
||||
|
||||
- **Persistent memory writing**: `Mem0Tools` uses `MemoryClient.add(...)` to store messages from user-agent interactions, including optional metadata such as user ID or session.
|
||||
- **Contextual memory search**: Compatible queries use `MemoryClient.search(...)` to retrieve relevant past messages, improving contextual understanding.
|
||||
- **Multimodal support**: Both text and image inputs are supported, allowing richer memory records.
|
||||
|
||||
> `Mem0Tools` uses the `MemoryClient` under the hood and requires no additional setup. You can customize its behavior by modifying your tools list or extending it in code.
|
||||
|
||||
## Full Manual Example
|
||||
|
||||
> Note: Mem0 can also be used with Agno Agents as a separate memory layer.
|
||||
|
||||
The following example demonstrates how to create an Agno agent with Mem0 memory integration, including support for image processing:
|
||||
|
||||
@@ -39,7 +68,6 @@ from agno.media import Image
|
||||
from agno.models.openai import OpenAIChat
|
||||
from mem0 import MemoryClient
|
||||
|
||||
|
||||
# Initialize the Mem0 client
|
||||
client = MemoryClient()
|
||||
|
||||
@@ -162,6 +190,8 @@ Improve your agent's context awareness:
|
||||
|
||||
Customize the integration to your needs:
|
||||
|
||||
- **Use `Mem0Tools()`** for drop-in memory support
|
||||
- **Use `MemoryClient` directly** for advanced control
|
||||
- **User Identification**: Organize memories by user ID
|
||||
- **Memory Search**: Configure search relevance and result count
|
||||
- **Memory Formatting**: Support for various OpenAI message formats
|
||||
|
||||
Reference in New Issue
Block a user