improved docs (#1834)

This commit is contained in:
Shlok Khemani
2024-09-09 15:59:12 +05:30
committed by GitHub
parent 7170edd13f
commit f01e8a083e
12 changed files with 448 additions and 401 deletions

View File

@@ -5,36 +5,28 @@ description: 'Empower your AI applications with long-term memory and personaliza
## Welcome to Mem0 Platform
Mem0 Platform is a managed service that revolutionizes the way AI applications handle memory. By providing a smart, self-improving memory layer for Large Language Models (LLMs), we enable developers to create personalized AI experiences that evolve with each user interaction.
The Mem0 Platform is a managed service and the easiest way to add our powerful memory layer to your applications.
## Why Choose Mem0 Platform?
1. **Enhanced User Experience**: Deliver tailored interactions that make your AI applications truly stand out.
2. **Simplified Development**: Our API-first approach streamlines integration, allowing you to focus on building great features.
3. **Scalable Solution**: Designed to grow with your application, from prototypes to production-ready systems.
Mem0 Platform offers a powerful, user-centric solution for AI memory management with a few key features:
## Key Features
1. **Simplified Development**: Integrate comprehensive memory capabilities with just 4 lines of code. Our API-first approach allows you to focus on building great features while we handle the complexities of memory management.
- **Comprehensive Memory Management**: Easily manage long-term, short-term, semantic, and episodic memories for individual users, agents, and sessions through our robust APIs.
- **Self-Improving Memory**: Our adaptive system continuously learns from user interactions, refining its understanding over time.
- **Cross-Platform Consistency**: Ensure a unified user experience across various AI platforms and applications.
- **Centralized Memory Control**: Store, update, and delete memories effortlessly, taking away the hassle of memory management.
2. **Scalable Solution**: Whether you're working on a prototype or a production-ready system, Mem0 is designed to grow with your application. Our platform effortlessly scales to meet your evolving needs.
## Common Use Cases
3. **Enhanced Performance**: Experience lightning-fast response times with sub-50ms latency, ensuring smooth and responsive user interactions in your AI applications.
4. **Insightful Dashboard**: Gain valuable insights and maintain full control over your AI's memory through our intuitive dashboard. Easily manage memories and access key user insights.
- Personalized Learning Assistants
- Customer Support AI Agents
- Healthcare Assistants
- Virtual Companions
- Productivity Tools
- Gaming AI
## Getting Started
Check out our [Quickstart Guide](/platform/quickstart) to start using Mem0 quickly.
Check out our [Platform Guide](/platform/guide) to start using Mem0 platform quickly.
## Next Steps
- Join our [discord](https://mem0.ai/discord) or [slack](https://mem0.ai/slack) with other developers and get support.
- Sign up to the [Mem0 Platform](https://mem0.dev/pd)
- Join our [Discord](https://mem0.dev/Did) or [Slack](https://mem0.ai/slack) with other developers and get support.
We're excited to see what you'll build with Mem0 Platform. Let's create smarter, more personalized AI experiences together!

View File

@@ -1,5 +1,5 @@
---
title: Quickstart
title: Guide
description: 'Get started with Mem0 Platform in minutes'
---
@@ -18,7 +18,7 @@ npm install mem0ai
## 2. API Key Setup
1. Sign in to [Mem0 Platform](https://app.mem0.ai/dashboard/api-keys)
1. Sign in to [Mem0 Platform](https://mem0.dev/pd-api)
2. Copy your API Key from the dashboard
![Get API Key from Mem0 Platform](/images/platform/api-key.png)
@@ -44,10 +44,10 @@ Mem0 provides a simple and customizable interface for performing CRUD operations
### 4.1 Create Memories
You can create long-term and short-term memories for your users, AI Agents, etc. Here are some examples:
#### Long-term memory for a user
These memory instances persist across multiple sessions. Ideal for maintaining memory over long time spans.
<CodeGroup>
```python Python
@@ -88,6 +88,8 @@ curl -X POST "https://api.mem0.ai/v1/memories/" \
#### Short-term memory for a user session
These memory instances persist only for the duration of a user session. Ideal for non-repetitive interactions and managing context windows efficiently.
<CodeGroup>
```python Python
@@ -134,23 +136,24 @@ curl -X POST "https://api.mem0.ai/v1/memories/" \
</CodeGroup>
#### Long-term memory for agents
Add a memory layer for the assistants and agents so that their responses remain consistent across sessions.
<CodeGroup>
```python Python
messages = [
{"role": "system", "content": "You are a personalized travel assistant. Remember user preferences and provide tailored recommendations."},
{"role": "assistant", "content": "Understood. I'll maintain personalized travel preferences for each user and provide customized recommendations based on their dietary restrictions, interests, and past interactions."}
{"role": "system", "content": "You are an AI tutor with a personality. Give yourself a name for the user."},
{"role": "assistant", "content": "Understood. I'm an AI tutor with a personality. My name is Alice."}
]
client.add(messages, agent_id="travel-assistant")
client.add(messages, agent_id="ai-tutor")
```
```javascript JavaScript
const messages = [
{"role": "system", "content": "You are a personalized travel assistant. Remember user preferences and provide tailored recommendations."},
{"role": "assistant", "content": "Understood. I'll maintain personalized travel preferences for each user and provide customized recommendations based on their dietary restrictions, interests, and past interactions."}
{"role": "system", "content": "You are an AI tutor with a personality. Give yourself a name for the user."},
{"role": "assistant", "content": "Understood. I'm an AI tutor with a personality. My name is Alice."}
];
client.add(messages, { agent_id: "travel-assistant" })
client.add(messages, { agent_id: "ai-tutor" })
.then(response => console.log(response))
.catch(error => console.error(error));
```
@@ -161,10 +164,10 @@ curl -X POST "https://api.mem0.ai/v1/memories/" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "system", "content": "You are a personalized travel assistant. Remember user preferences and provide tailored recommendations."},
{"role": "assistant", "content": "Understood. I'll maintain personalized travel preferences for each user and provide customized recommendations based on their dietary restrictions, interests, and past interactions."}
{"role": "system", "content": "You are an AI tutor with a personality. Give yourself a name for the user."},
{"role": "assistant", "content": "Understood. I'm an AI tutor with a personality. My name is Alice."}
],
"agent_id": "travel-assistant"
"agent_id": "ai-tutor"
}'
```
@@ -173,23 +176,27 @@ curl -X POST "https://api.mem0.ai/v1/memories/" \
```
</CodeGroup>
You can monitor memory operations on the platform:
#### Monitor Memories
You can monitor memory operations on the platform dashboard:
![Mem0 Platform Activity](/images/platform/activity.png)
### 4.2 Search Relevant Memories
### 4.2 Search Memories
You can also get related memories for a given natural language question using our search method.
#### General Memory Search
Pass user messages, interactions, and queries into our search method to retrieve relevant memories.
<CodeGroup>
```python Python
query = "What do you know about me?"
query = "What should I cook for dinner today?"
client.search(query, user_id="alex")
```
```javascript JavaScript
const query = "What do you know about me?";
const query = "What should I cook for dinner today?";
client.search(query, { user_id: "alex" })
.then(results => console.log(results))
.catch(error => console.error(error));
@@ -200,7 +207,7 @@ curl -X POST "https://api.mem0.ai/v1/memories/search/" \
-H "Authorization: Token your-api-key" \
-H "Content-Type: application/json" \
-d '{
"query": "What do you know about me?",
"query": "What should I cook for dinner today?",
"user_id": "alex"
}'
```
@@ -209,7 +216,7 @@ curl -X POST "https://api.mem0.ai/v1/memories/search/" \
[
{
"id": "7f165f7e-b411-4afe-b7e5-35789b72c4a5",
"memory": "Name: Alex. Vegetarian. Allergic to nuts.",
"memory": "Vegetarian. Allergic to nuts.",
"input": [
{
"role": "user",
@@ -232,7 +239,7 @@ curl -X POST "https://api.mem0.ai/v1/memories/search/" \
#### Search using custom filters
You can also search for memories using custom filters along with user_id, agent_id, app_id, etc.
Our advanced search allows you to set custom search filters. You can filter by user_id, agent_id, app_id, date, and more.
Here you need to define `version` as `v2` in the search method.
@@ -405,7 +412,7 @@ curl -X POST "https://api.mem0.ai/v1/memories/search/?version=v2" \
### 4.3 Get All Users
Get all users, agents, and sessions for which memories exist.
Get all users, agents, and sessions which have memories associated with them.
<CodeGroup>
@@ -430,7 +437,7 @@ curl -X GET "https://api.mem0.ai/v1/entities/" \
{
"id": "1",
"name": "user123",
"created_at": "2024-07-17T16:47:23.899900-07:00",
"created_2024-07-17T16:47:23.899900-07:00",
"updated_at": "2024-07-17T16:47:23.899918-07:00",
"total_memories": 5,
"owner": "alex",
@@ -459,49 +466,7 @@ curl -X GET "https://api.mem0.ai/v1/entities/" \
Fetch all memories for a user, agent, or session using the getAll() method.
#### Get all memories of an AI Agent
<CodeGroup>
```python Python
client.get_all(agent_id="travel-assistant")
```
```javascript JavaScript
client.getAll({ agent_id: "travel-assistant" })
.then(memories => console.log(memories))
.catch(error => console.error(error));
```
```bash cURL
curl -X GET "https://api.mem0.ai/v1/memories/?agent_id=travel-assistant" \
-H "Authorization: Token your-api-key"
```
```json Output
[
{
"id":"f38b689d-6b24-45b7-bced-17fbb4d8bac7",
"memory":"是素食主义者,对坚果过敏。",
"agent_id":"travel-assistant",
"hash":"62bc074f56d1f909f1b4c2b639f56f6a",
"metadata":"None",
"created_at":"2024-07-25T23:57:00.108347-07:00",
"updated_at":"2024-07-25T23:57:00.108367-07:00"
},
{
"id":"0a14d8f0-e364-4f5c-b305-10da1f0d0878",
"memory":"Will maintain personalized travel preferences for each user. Provide customized recommendations based on dietary restrictions, interests, and past interactions.",
"agent_id":"travel-assistant",
"hash":"35a305373d639b0bffc6c2a3e2eb4244",
"metadata":"None",
"created_at":"2024-07-26T00:31:03.543759-07:00",
"updated_at":"2024-07-26T00:31:03.543778-07:00"
}
]
```
</CodeGroup>
#### Get all memories of user
#### Get all memories of a user
<CodeGroup>
@@ -544,7 +509,50 @@ curl -X GET "https://api.mem0.ai/v1/memories/?user_id=alex" \
```
</CodeGroup>
#### Get short-term memories for a session
#### Get all memories of an AI Agent
<CodeGroup>
```python Python
client.get_all(agent_id="ai-tutor")
```
```javascript JavaScript
client.getAll({ agent_id: "ai-tutor" })
.then(memories => console.log(memories))
.catch(error => console.error(error));
```
```bash cURL
curl -X GET "https://api.mem0.ai/v1/memories/?agent_id=travel-assistant" \
-H "Authorization: Token your-api-key"
```
```json Output
[
{
"id":"f38b689d-6b24-45b7-bced-17fbb4d8bac7",
"memory":"是素食主义者,对坚果过敏。",
"agent_id":"ai-tutor",
"hash":"62bc074f56d1f909f1b4c2b639f56f6a",
"metadata":"None",
"created_at":"2024-07-25T23:57:00.108347-07:00",
"updated_at":"2024-07-25T23:57:00.108367-07:00"
},
{
"id":"0a14d8f0-e364-4f5c-b305-10da1f0d0878",
"memory":"My name is Alice.",
"agent_id":"ai-tutor",
"hash":"35a305373d639b0bffc6c2a3e2eb4244",
"metadata":"None",
"created_at":"2024-07-26T00:31:03.543759-07:00",
"updated_at":"2024-07-26T00:31:03.543778-07:00"
}
]
```
</CodeGroup>
#### Get the short-term memories for a session
<CodeGroup>
@@ -630,7 +638,7 @@ curl -X GET "https://api.mem0.ai/v1/memories/582bbe6d-506b-48c6-a4c6-5df3b1e6342
### 4.5 Memory History
Get history of how a memory has changed over time
Get history of how a memory has changed over time.
<CodeGroup>
@@ -763,7 +771,7 @@ curl -X PUT "https://api.mem0.ai/v1/memories/memory-id-here" \
### 4.7 Delete Memory
Delete specific memory:
Delete specific memory.
<CodeGroup>
@@ -787,7 +795,7 @@ curl -X DELETE "https://api.mem0.ai/v1/memories/memory-id-here" \
```
</CodeGroup>
Delete all memories of a user:
Delete all memories of a user.
<CodeGroup>
@@ -811,7 +819,7 @@ curl -X DELETE "https://api.mem0.ai/v1/memories/?user_id=alex" \
```
</CodeGroup>
Delete all users:
Delete all users.
<CodeGroup>