diff --git a/docs/features.mdx b/docs/features.mdx index a233a214..178d5791 100644 --- a/docs/features.mdx +++ b/docs/features.mdx @@ -4,14 +4,16 @@ title: Features ## Core features -- **User, Session, and AI Agent Memory**: Retains information across user sessions, interactions, and AI agents, ensuring continuity and context. -- **Adaptive Personalization**: Continuously improves personalization based on user interactions and feedback. +- **User, Session, and AI Agent Memory**: Retains information across sessions and interactions for users and AI agents, ensuring continuity and context. +- **Adaptive Personalization**: Continuously updates memories based on user interactions and feedback. - **Developer-Friendly API**: Offers a straightforward API for seamless integration into various applications. - **Platform Consistency**: Ensures consistent behavior and data across different platforms and devices. - **Managed Service**: Provides a hosted solution for easy deployment and maintenance. +- **Save Costs**: Saves costs by adding relevent memories instead of complete transcripts to context window -## How Mem0 Works? + +## How does Mem0 work? Mem0 leverages a hybrid database approach to manage and retrieve long-term memories for AI agents and assistants. Each memory is associated with a unique identifier, such as a user ID or agent ID, allowing Mem0 to organize and access memories specific to an individual or context. @@ -19,18 +21,18 @@ When a message is added to the Mem0 using add() method, the system extracts rel When an AI agent or LLM needs to recall memories, it uses the search() method. Mem0 then performs search across these data stores, retrieving relevant information from each source. This information is then passed through a scoring layer, which evaluates their importance based on relevance, importance, and recency. This ensures that only the most personalized and useful context is surfaced. -The retrieved memories can then be appended to the LLM's prompt as needed, enhancing the personalization and relevance of its responses. +The retrieved memories can then be appended to the LLM's prompt as needed, making responses personalized and relevant. ## Common Use Cases -- **Personalized Learning Assistants**: Long-term memory allows learning assistants to remember user preferences, past interactions, and progress, providing a more tailored and effective learning experience. +- **Personalized Learning Assistants**: Long-term memory allows learning assistants to remember user preferences, strengths and weaknesses, and progress, providing a more tailored and effective learning experience. - **Customer Support AI Agents**: By retaining information from previous interactions, customer support bots can offer more accurate and context-aware assistance, improving customer satisfaction and reducing resolution times. - **Healthcare Assistants**: Long-term memory enables healthcare assistants to keep track of patient history, medication schedules, and treatment plans, ensuring personalized and consistent care. -- **Virtual Companions**: Virtual companions can use long-term memory to build deeper relationships with users by remembering personal details, preferences, and past conversations, making interactions more meaningful. +- **Virtual Companions**: Virtual companions can use long-term memory to build deeper relationships with users by remembering personal details, preferences, and past conversations, making interactions more delightful. - **Productivity Tools**: Long-term memory helps productivity tools remember user habits, frequently used documents, and task history, streamlining workflows and enhancing efficiency. @@ -42,7 +44,7 @@ Mem0's memory implementation for Large Language Models (LLMs) offers several adv - **Entity Relationships**: Mem0 can understand and relate entities across different interactions, unlike RAG which retrieves information from static documents. This leads to a deeper understanding of context and relationships. -- **Recency, Relevancy, and Decay**: Mem0 prioritizes recent interactions and gradually forgets outdated information, ensuring the memory remains relevant and up-to-date for more accurate responses. +- **Recency, Relevancy, and Decay**: Mem0 uses custom search algorithms to prioritize recent interactions and gradually forgets outdated information, ensuring the memory remains relevant and up-to-date for more accurate responses. - **Contextual Continuity**: Mem0 retains information across sessions, maintaining continuity in conversations and interactions, which is essential for long-term engagement applications like virtual companions or personalized learning assistants. diff --git a/docs/images/playground/pg-add-memory.png b/docs/images/playground/pg-add-memory.png new file mode 100644 index 00000000..09593abb Binary files /dev/null and b/docs/images/playground/pg-add-memory.png differ diff --git a/docs/images/playground/pg-retrieve-memory.png b/docs/images/playground/pg-retrieve-memory.png new file mode 100644 index 00000000..044c8c71 Binary files /dev/null and b/docs/images/playground/pg-retrieve-memory.png differ diff --git a/docs/mint.json b/docs/mint.json index 93ea5cd7..481b7928 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -52,6 +52,8 @@ "group": "Get Started", "pages": [ "overview", + "quickstart", + "playground", "features" ] }, diff --git a/docs/open-source/graph_memory/features.mdx b/docs/open-source/graph_memory/features.mdx index e865b753..dd2cc3e3 100644 --- a/docs/open-source/graph_memory/features.mdx +++ b/docs/open-source/graph_memory/features.mdx @@ -33,6 +33,6 @@ config = { m = Memory.from_config(config_dict=config) ``` -If you want to use a managed version of Mem0, please check out [Mem0](https://app.mem0.ai). If you have any questions, please feel free to reach out to us using one of the following methods: +If you want to use a managed version of Mem0, please check out [Mem0](https://mem0.dev/pd). If you have any questions, please feel free to reach out to us using one of the following methods: diff --git a/docs/open-source/graph_memory/overview.mdx b/docs/open-source/graph_memory/overview.mdx index 1912729e..75bf94bf 100644 --- a/docs/open-source/graph_memory/overview.mdx +++ b/docs/open-source/graph_memory/overview.mdx @@ -299,6 +299,6 @@ m.search("Who is spiderman?", user_id="alice123") > **Note:** The Graph Memory implementation is not standalone. You will be adding/retrieving memories to the vector store and the graph store simultaneously. -If you want to use a managed version of Mem0, please check out [Mem0](https://app.mem0.ai). If you have any questions, please feel free to reach out to us using one of the following methods: +If you want to use a managed version of Mem0, please check out [Mem0](https://mem0.dev/pd). If you have any questions, please feel free to reach out to us using one of the following methods: \ No newline at end of file diff --git a/docs/open-source/quickstart.mdx b/docs/open-source/quickstart.mdx index fb414001..f62060f3 100644 --- a/docs/open-source/quickstart.mdx +++ b/docs/open-source/quickstart.mdx @@ -1,5 +1,5 @@ --- -title: Quickstart +title: Guide description: 'Get started with Mem0 quickly!' --- diff --git a/docs/overview.mdx b/docs/overview.mdx index cb3c80a7..2206c9df 100644 --- a/docs/overview.mdx +++ b/docs/overview.mdx @@ -2,317 +2,29 @@ title: Overview --- -[Mem0](https://mem0.ai) (pronounced "mem-zero") enhances AI assistants and agents with an intelligent memory layer, enabling personalized AI interactions. Mem0 remembers user preferences, adapts to individual needs, and continuously improves over time, making it ideal for customer support chatbots, AI assistants, and autonomous systems. +[Mem0](https://mem0.dev/wd) (pronounced "mem-zero") enhances AI assistants and agents with an intelligent memory layer, enabling personalized AI interactions. Mem0 remembers user preferences and traits and continuously updates over time, making it ideal for applications like customer support chatbots and AI assistants. -Mem0 offers two powerful ways to leverage our technology: [our managed Platform](#mem0-platform-managed-solution) and [our open source solution](#mem0-open-source). +Mem0 offers two powerful ways to leverage our technology: our [managed platform](/platform/overview) and our [open source solution](/open-source/quickstart). +## Getting Started - - - Better, faster, fully managed, and hassle free solution. + + + Integrate Mem0 in a few lines of code - - Self hosted, fully customizable, and open source. + + Mem0 in action + + + See what you can build with Mem0 - - -## Mem0 Platform (Managed Solution) - -Our fully managed platform provides a hassle-free way to integrate Mem0's capabilities into your AI agents and assistants. Sign up for Mem0 platform [here](https://app.mem0.ai). - -Follow the steps below to get started with Mem0 Platform: - -1. [Install Mem0](#1-install-mem0) -2. [Add Memories](#2-add-memories) -3. [Retrieve Memories](#3-retrieve-memories) - -### 1. Install Mem0 - - - - -```bash pip -pip install mem0ai -``` - -```bash npm -npm install mem0ai -``` - - - - -1. Sign in to [Mem0 Platform](https://app.mem0.ai/dashboard/api-keys) -2. Copy your API Key from the dashboard - -![Get API Key from Mem0 Platform](/images/platform/api-key.png) - - - - -### 2. Add Memories - - - - -```python Python -from mem0 import MemoryClient -client = MemoryClient(api_key="your-api-key") -``` - -```javascript JavaScript -const MemoryClient = require('mem0ai'); -const client = new MemoryClient('your-api-key'); -``` - - - - - -```python Python -messages = [ - {"role": "user", "content": "Hi, I'm Alex. I'm a vegetarian and I'm allergic to nuts."}, - {"role": "assistant", "content": "Hello Alex! I've noted that you're a vegetarian and have a nut allergy. I'll keep this in mind for any food-related recommendations or discussions."} -] -client.add(messages, user_id="alex") -``` - -```javascript JavaScript -const messages = [ - {"role": "user", "content": "Hi, I'm Alex. I'm a vegetarian and I'm allergic to nuts."}, - {"role": "assistant", "content": "Hello Alex! I've noted that you're a vegetarian and have a nut allergy. I'll keep this in mind for any food-related recommendations or discussions."} -]; -client.add(messages, { user_id: "alex" }) - .then(response => console.log(response)) - .catch(error => console.error(error)); -``` - -```bash cURL -curl -X POST "https://api.mem0.ai/v1/memories/" \ - -H "Authorization: Token your-api-key" \ - -H "Content-Type: application/json" \ - -d '{ - "messages": [ - {"role": "user", "content": "Hi, I'm Alex. I'm a vegetarian and I'm allergic to nuts."}, - {"role": "assistant", "content": "Hello Alex! I've noted that you're a vegetarian and have a nut allergy. I'll keep this in mind for any food-related recommendations or discussions."} - ], - "user_id": "alex" - }' -``` - -```json Output -{'message': 'ok'} -``` - - - - -### 3. Retrieve Memories - - - - - -```python Python -query = "What do you know about me?" -client.search(query, user_id="alex") -``` - -```javascript JavaScript -const query = "What do you know about me?"; -client.search(query, { user_id: "alex" }) - .then(results => console.log(results)) - .catch(error => console.error(error)); -``` - -```bash cURL -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?", - "user_id": "alex" - }' -``` - -```json Output -[ - { - "id": "7f165f7e-b411-4afe-b7e5-35789b72c4a5", - "memory": "Name: Alex. Vegetarian. Allergic to nuts.", - "input": [ - { - "role": "user", - "content": "Hi, I'm Alex. I'm a vegetarian and I'm allergic to nuts." - }, - { - "role": "assistant", - "content": "Hello Alex! I've noted that you're a vegetarian and have a nut allergy. I'll keep this in mind for any food-related recommendations or discussions." - } - ], - "user_id": "alex", - "hash": "9ee7e1455e84d1dab700ed8749aed75a", - "metadata": null, - "created_at": "2024-07-20T01:30:36.275141-07:00", - "updated_at": "2024-07-20T01:30:36.275172-07:00" - } -] -``` - - - - - - - -```python Python -user_memories = client.get_all(user_id="alex") -``` - -```javascript JavaScript -client.getAll({ user_id: "alex" }) - .then(memories => console.log(memories)) - .catch(error => console.error(error)); -``` - -```bash cURL -curl -X GET "https://api.mem0.ai/v1/memories/?user_id=alex" \ - -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" - } -] -``` - - - - - - Learn more about Mem0 platform - - -## Mem0 Open Source - -Our open-source version is available for those who prefer full control and customization. You can self-host Mem0 on your infrastructure and integrate it with your AI agents and assistants. Checkout the [GitHub repository](https://github.com/mem0ai/mem0) - -Follow the steps below to get started with Mem0 Open Source: - -1. [Install Mem0 Open Source](#1-install-mem0-open-source) -2. [Add Memories](#2-add-memories-open-source) -3. [Retrieve Memories](#3-retrieve-memories-open-source) - -### 1. Install Mem0 Open Source - - - -```bash -pip install mem0ai -``` - - - -### 2. Add Memories - - - -```python Python -from mem0 import Memory -m = Memory() -``` - - - -```python Code -# For a user -result = m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) -``` - -```json Output -{'message': 'ok'} -``` - - - - -### 3. Retrieve Memories - - - - -```python Code -related_memories = m.search(query="What are Alice's hobbies?", user_id="alice") -``` - -```json Output -[ - { - "id":"ea925981-272f-40dd-b576-be64e4871429", - "memory":"Likes to play cricket and plays cricket on weekends.", - "hash":"c8809002-25c1-4c97-a3a2-227ce9c20c53", - "metadata":{ - "category":"hobbies" - }, - "score":0.32116443111457704, - "created_at":"2024-07-26T10:29:36.630547-07:00", - "updated_at":"None", - "user_id":"alice" - } -] -``` - - - - -```python Code -# Get all memories -all_memories = m.get_all() -``` - -```json Output -[ - { - "id":"13efe83b-a8df-4ec0-814e-428d6e8451eb", - "memory":"Likes to play cricket on weekends", - "hash":"87bcddeb-fe45-4353-bc22-15a841c50308", - "metadata":"None", - "created_at":"2024-07-26T08:44:41.039788-07:00", - "updated_at":"None", - "user_id":"alice" - } -] -``` - - - - - - Learn more about Mem0 open source - - ## Key Features - OpenAI-compatible API: Easily switch between OpenAI and Mem0 -- Advanced memory management: Efficient handling of long-term context +- Advanced memory management: Save costs by efficiently handling long-term context - Flexible deployment: Choose between managed platform or self-hosted solution + + ## Need help? diff --git a/docs/platform/overview.mdx b/docs/platform/overview.mdx index e5e0a97e..8822f5d0 100644 --- a/docs/platform/overview.mdx +++ b/docs/platform/overview.mdx @@ -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! diff --git a/docs/platform/quickstart.mdx b/docs/platform/quickstart.mdx index efbee6f2..b307e23f 100644 --- a/docs/platform/quickstart.mdx +++ b/docs/platform/quickstart.mdx @@ -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. + ```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. + ```python Python @@ -134,23 +136,24 @@ curl -X POST "https://api.mem0.ai/v1/memories/" \ #### Long-term memory for agents +Add a memory layer for the assistants and agents so that their responses remain consistent across sessions. ```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/" \ ``` -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. ```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. @@ -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 - - -```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" - } -] -``` - - -#### Get all memories of user +#### Get all memories of a user @@ -544,7 +509,50 @@ curl -X GET "https://api.mem0.ai/v1/memories/?user_id=alex" \ ``` -#### Get short-term memories for a session + +#### Get all memories of an AI Agent + + +```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" + } +] +``` + + +#### Get the short-term memories for a session @@ -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. @@ -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. @@ -787,7 +795,7 @@ curl -X DELETE "https://api.mem0.ai/v1/memories/memory-id-here" \ ``` -Delete all memories of a user: +Delete all memories of a user. @@ -811,7 +819,7 @@ curl -X DELETE "https://api.mem0.ai/v1/memories/?user_id=alex" \ ``` -Delete all users: +Delete all users. diff --git a/docs/playground.mdx b/docs/playground.mdx new file mode 100644 index 00000000..4a5f505b --- /dev/null +++ b/docs/playground.mdx @@ -0,0 +1,25 @@ +--- +title: Interactive Playground +--- +Watch Mem0 in action with our Playground tool. + + + + You'll need to create a free Mem0 account to use the playground – this helps ensure responses are more tailored to you by associating interactions with an individual profile. + + + + + + + + + Chat with the assistant to start adding memories. + ![Add memories to playground](/images/playground/pg-add-memory.png) + + + Memories are stored in context for all future conversations, creating truly personal AI. + ![Retrieve memories in playground](/images/playground/pg-retrieve-memory.png) + + + diff --git a/docs/quickstart.mdx b/docs/quickstart.mdx new file mode 100644 index 00000000..15da2162 --- /dev/null +++ b/docs/quickstart.mdx @@ -0,0 +1,306 @@ +--- +title: Quickstart +--- +Mem0 offers two powerful ways to leverage our technology: [our managed platform](#mem0-platform-managed-solution) and [our open source solution](#mem0-open-source). + + + + Better, faster, fully managed, and hassle free solution. + + + Self hosted, fully customizable, and open source. + + + + +## Mem0 Platform (Managed Solution) + +Our fully managed platform provides a hassle-free way to integrate Mem0's capabilities into your AI agents and assistants. Sign up for Mem0 platform [here](https://mem0.dev/pd). + +Follow the steps below to get started with Mem0 Platform: + +1. [Install Mem0](#1-install-mem0) +2. [Add Memories](#2-add-memories) +3. [Retrieve Memories](#3-retrieve-memories) + +### 1. Install Mem0 + + + + +```bash pip +pip install mem0ai +``` + +```bash npm +npm install mem0ai +``` + + + + +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) + + + + +### 2. Add Memories + + + + +```python Python +from mem0 import MemoryClient +client = MemoryClient(api_key="your-api-key") +``` + +```javascript JavaScript +const MemoryClient = require('mem0ai'); +const client = new MemoryClient('your-api-key'); +``` + + + + + +```python Python +messages = [ + {"role": "user", "content": "Hi, I'm Alex. I'm a vegetarian and I'm allergic to nuts."}, + {"role": "assistant", "content": "Hello Alex! I've noted that you're a vegetarian and have a nut allergy. I'll keep this in mind for any food-related recommendations or discussions."} +] +client.add(messages, user_id="alex") +``` + +```javascript JavaScript +const messages = [ + {"role": "user", "content": "Hi, I'm Alex. I'm a vegetarian and I'm allergic to nuts."}, + {"role": "assistant", "content": "Hello Alex! I've noted that you're a vegetarian and have a nut allergy. I'll keep this in mind for any food-related recommendations or discussions."} +]; +client.add(messages, { user_id: "alex" }) + .then(response => console.log(response)) + .catch(error => console.error(error)); +``` + +```bash cURL +curl -X POST "https://api.mem0.ai/v1/memories/" \ + -H "Authorization: Token your-api-key" \ + -H "Content-Type: application/json" \ + -d '{ + "messages": [ + {"role": "user", "content": "Hi, I'm Alex. I'm a vegetarian and I'm allergic to nuts."}, + {"role": "assistant", "content": "Hello Alex! I've noted that you're a vegetarian and have a nut allergy. I'll keep this in mind for any food-related recommendations or discussions."} + ], + "user_id": "alex" + }' +``` + +```json Output +{'message': 'ok'} +``` + + + + +### 3. Retrieve Memories + + + + + +```python Python +query = "What can I cook for dinner tonight?" +client.search(query, user_id="alex") +``` + +```javascript JavaScript +const query = "What can I cook for dinner tonight?"; +client.search(query, { user_id: "alex" }) + .then(results => console.log(results)) + .catch(error => console.error(error)); +``` + +```bash cURL +curl -X POST "https://api.mem0.ai/v1/memories/search/" \ + -H "Authorization: Token your-api-key" \ + -H "Content-Type: application/json" \ + -d '{ + "query": "What can I cook for dinner tonight?", + "user_id": "alex" + }' +``` + +```json Output +[ + { + "id": "7f165f7e-b411-4afe-b7e5-35789b72c4a5", + "memory": "Name: Alex. Vegetarian. Allergic to nuts.", + "input": [ + { + "role": "user", + "content": "Hi, I'm Alex. I'm a vegetarian and I'm allergic to nuts." + }, + { + "role": "assistant", + "content": "Hello Alex! I've noted that you're a vegetarian and have a nut allergy. I'll keep this in mind for any food-related recommendations or discussions." + } + ], + "user_id": "alex", + "hash": "9ee7e1455e84d1dab700ed8749aed75a", + "metadata": null, + "created_at": "2024-07-20T01:30:36.275141-07:00", + "updated_at": "2024-07-20T01:30:36.275172-07:00" + } +] +``` + + + + + + + +```python Python +user_memories = client.get_all(user_id="alex") +``` + +```javascript JavaScript +client.getAll({ user_id: "alex" }) + .then(memories => console.log(memories)) + .catch(error => console.error(error)); +``` + +```bash cURL +curl -X GET "https://api.mem0.ai/v1/memories/?user_id=alex" \ + -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" + } +] +``` + + + + + + Learn more about Mem0 platform + + +## Mem0 Open Source + +Our open-source version is available for those who prefer full control and customization. You can self-host Mem0 on your infrastructure and integrate it with your AI agents and assistants. Checkout our [GitHub repository](https://mem0.dev/gd) + +Follow the steps below to get started with Mem0 Open Source: + +1. [Install Mem0 Open Source](#1-install-mem0-open-source) +2. [Add Memories](#2-add-memories-open-source) +3. [Retrieve Memories](#3-retrieve-memories-open-source) + +### 1. Install Mem0 Open Source + + + +```bash +pip install mem0ai +``` + + + +### 2. Add Memories + + + +```python Python +from mem0 import Memory +m = Memory() +``` + + + +```python Code +# For a user +result = m.add("I like to take long walks on weekends.", user_id="alice", metadata={"category": "hobbies"}) +``` + +```json Output +{'message': 'ok'} +``` + + + + +### 3. Retrieve Memories + + + + +```python Code +related_memories = m.search(query="Help me plan my weekend.", user_id="alice") +``` + +```json Output +[ + { + "id":"ea925981-272f-40dd-b576-be64e4871429", + "memory":"Likes to take long walks on weekends.", + "hash":"c8809002-25c1-4c97-a3a2-227ce9c20c53", + "metadata":{ + "category":"hobbies" + }, + "score":0.32116443111457704, + "created_at":"2024-07-26T10:29:36.630547-07:00", + "updated_at":"None", + "user_id":"alice" + } +] +``` + + + + +```python Code +# Get all memories +all_memories = m.get_all(user_id="alice") +``` + +```json Output +[ + { + "id":"13efe83b-a8df-4ec0-814e-428d6e8451eb", + "memory":"Likes to take long walks on weekends", + "hash":"87bcddeb-fe45-4353-bc22-15a841c50308", + "metadata":"None", + "created_at":"2024-07-26T08:44:41.039788-07:00", + "updated_at":"None", + "user_id":"alice" + } +] +``` + + + + + + Learn more about Mem0 open source +