The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Python agentic-memoryagentic-memory-systemagentsaiai-agentschatgptgenaillmlong-term-memorymemorymemory-managementpythonragstate-management
Improve docs and readme (#1663)
Taranjeet Singh874c2e96ca9e
diff --git a/README.md b/README.mdindex 509e4162e..c9e2ae229 100644--- a/README.md+++ b/README.md@@ -3,7 +3,7 @@<img src="docs/images/banner-sm.png" width="800px" alt="Mem0 - The Memory Layer for Personalized AI"></a><p align="center">- <a href="https://mem0.ai/discord">Learn more</a>+ <a href="https://mem0.ai">Learn more</a>·<a href="https://mem0.ai/discord">Join Discord</a></p>@@ -23,11 +23,9 @@# Introduction-* [Mem0](https://mem0.ai) enhances AI assistants and agents with an intelligent memory layer, enabling personalized AI interactions.+[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 remembers user preferences, adapts to individual needs, and continuously improves over time, making it ideal for customer support chatbots, AI assistants, and autonomous systems.--Use cases enabled by Mem0 include:+Mem0 empowers organizations and individuals to enhance:- **AI Assistants and agents**: Seamless conversations with a touch of déjà vu- **Personalized Learning**: Tailored content recommendations and progress tracking@@ -55,21 +53,25 @@ Alternatively, you can use Mem0 with one click on the hosted platform [here](htt### Basic Usage-Mem0 supports a variety of LLMs, with details available in our [Supported LLMs documentation](https://docs.mem0.ai/llms). By default, Mem0 comes equipped with `gpt-4o`. To use it, simply set the keys in the environment variables.+Mem0 requires an LLM to function, with `gpt-4o` from OpenAI as the default. However, it supports a variety of LLMs; for details, refer to our [Supported LLMs documentation](https://docs.mem0.ai/llms).+First step is to instantiate the memory:```python-import os-os.environ["OPENAI_API_KEY"] = "sk-xxx"+from mem0 import Memory++m = Memory()```-Now, you can initialize the memory:+<details>+<summary>How to set OPENAI_API_KEY</summary>```python-from mem0 import Memory--m = Memory()+import os+os.environ["OPENAI_API_KEY"] = "sk-xxx"```+</details>+You can perform the following task on the memory:@@ -131,33 +133,6 @@ history = m.history(memory_id=<memory_id_1>)For detailed usage instructions and API reference, visit our documentation at [docs.mem0.ai](https://docs.mem0.ai). Here, you can find more information on both the open-source version and the hosted [Mem0 Platform](https://app.mem0.ai).-## Advanced Usage--For production environments, you can use Qdrant as a vector store:--```python-from mem0 import Memory--config = {- "vector_store": {- "provider": "qdrant",- "config": {- "host": "localhost",- "port": 6333,- }- },-}--m = Memory.from_config(config)-```--## Roadmap--- Integration with various LLM providers-- Support for LLM frameworks-- Integration with AI Agents frameworks-- Customizable memory creation/update rules-## Star History[](https://star-history.com/#mem0ai/mem0&Date)@@ -167,10 +142,8 @@ m = Memory.from_config(config)Join our community for support and discussions. If you have any questions, feel free to reach out to us using one of the following methods:- [Join our Discord](https://mem0.ai/discord)-- [Join our Slack](https://mem0.ai/slack)-- [Join our newsletter](https://mem0.ai/email)- [Follow us on Twitter](https://x.com/mem0ai)-- [Email us](mailto:[email protected])+- [Email founders](mailto:[email protected])## Contributorsdiff --git a/docs/components/llms.mdx b/docs/components/llms.mdxindex 2c27228a6..fbb9b5a65 100644--- a/docs/components/llms.mdx+++ b/docs/components/llms.mdx@@ -1,5 +1,5 @@----title: 🤖 LLMs+title: Supported LLMs---## Overviewdiff --git a/docs/components/vectordb.mdx b/docs/components/vectordb.mdxindex dd17e1f8b..f7aa6ded9 100644--- a/docs/components/vectordb.mdx+++ b/docs/components/vectordb.mdx@@ -1,5 +1,5 @@----title: 🗄 Vector Databases+title: Supported Vector Databases---## Overviewdiff --git a/docs/get-started/concepts.mdx b/docs/get-started/concepts.mdxnew file mode 100644index 000000000..e69de29bbdiff --git a/docs/get-started/features.mdx b/docs/get-started/features.mdxnew file mode 100644index 000000000..e69de29bbdiff --git a/docs/mint.json b/docs/mint.jsonindex 1ed6b5f44..06eba4010 100644--- a/docs/mint.json+++ b/docs/mint.json@@ -16,24 +16,14 @@"light": "/logo/light.svg","href": "https://github.com/mem0ai/mem0"},- "tabs": [- {- "name": "💡 Examples",- "url": "examples"- },- {- "name": "🖥️ Platform",- "url": "platform"- }- ],"topbarCtaButton": {- "name": "Your Memory Dashboard",+ "name": "Your Dashboard","url": "https://app.mem0.ai"},"anchors": [{- "name": "Your Memory Dashboard",- "icon": "discord",+ "name": "Your Dashboard",+ "icon": "chart-simple","url": "https://app.mem0.ai"},{@@ -56,27 +46,32 @@{"group": "Get Started","pages": [- "overview",- "quickstart"+ "overview"]},{- "group": "Components",+ "group": "Platform","pages": [- "components/llms",- "components/vectordb"- ]- },- {- "group": "Features",- "pages":[- "features/openai_compatibility"+ "platform/overview",+ "platform/quickstart"]},{- "group": "Integrations",+ "group": "Open Source","pages": [- "integrations/multion"+ "open-source/quickstart",+ {+ "group": "LLMs",+ "pages": ["components/llms"]+ },+ {+ "group": "Vector Database",+ "pages": ["components/vectordb"]+ },+ {+ "group": "Features",+ "pages": ["features/openai_compatibility"]+ }]},{@@ -89,12 +84,12 @@]},{- "group": "🖥️ Platform",+ "group": "Integrations","pages": [- "platform/overview",- "platform/quickstart"+ "integrations/multion"]}+],"footerSocials": {"discord": "https://mem0.ai/discord",diff --git a/docs/quickstart.mdx b/docs/open-source/quickstart.mdxsimilarity index 99%rename from docs/quickstart.mdxrename to docs/open-source/quickstart.mdxindex de48e1d6f..e2a447d9f 100644--- a/docs/quickstart.mdx+++ b/docs/open-source/quickstart.mdx@@ -1,5 +1,5 @@----title: 🚀 Quickstart+title: Quickstartdescription: 'Get started with Mem0 quickly!'---diff --git a/docs/overview.mdx b/docs/overview.mdxindex 317d09644..4bf692072 100644--- a/docs/overview.mdx+++ b/docs/overview.mdx@@ -1,62 +1,321 @@----title: 📚 Overview-description: 'Welcome to the Mem0 docs!'+title: Overview----> Mem0 provides a smart, self-improving memory layer for Large Language Models, enabling personalized AI experiences across applications.+[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.-## 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.-- **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.--If you are looking to quick start, jump to one of the following links:+Mem0 offers two powerful ways to leverage our technology: [our managed Platform](#mem0-platform-managed-solution) and [our Open Source solution](#mem0-open-source).<CardGroup cols={2}>- <Card title="Open Source Quickstart" icon="square-1" href="/quickstart/">- Get started with Mem0 open source- </Card>- <Card title="Mem0 Platform Quickstart" icon="square-2" href="/platform/quickstart/">- Begin with Mem0 Platform+ <Card title="Mem0 Platform" icon="chart-simple" href="#mem0-platform-managed-solution">+ Better, faster and fully managed, hassle free solution.</Card>- <Card title="Examples" icon="square-3" href="/examples/overview/">- Explore practical use cases+ <Card title="Mem0 Open Source" icon="code-branch" href="#mem0-open-source">+ Self hosted, fully customizable and open source.</Card></CardGroup>-## 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.+## 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++<AccordionGroup>+<Accordion title="Install package">+<CodeGroup>+```bash pip+pip install mem0ai+```++```bash npm+npm install mem0ai+```+</CodeGroup>+</Accordion>+<Accordion title="Get API Key">++1. Sign in to [Mem0 Platform](https://app.mem0.ai/dashboard/api-keys)+2. Copy your API Key from the dashboard++++</Accordion>+</AccordionGroup>++### 2. Add Memories++<AccordionGroup>+<Accordion title="Instantiate client">+<CodeGroup>+```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');+```+</CodeGroup>+</Accordion>+<Accordion title="Add memories">+<CodeGroup>++```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'}+```+</CodeGroup>+</Accordion>+</AccordionGroup>++### 3. Retrieve Memories++<AccordionGroup>+<Accordion title="Search for relevant memories">+<CodeGroup>++```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"+ }+]+```+</CodeGroup>++</Accordion>+<Accordion title="Get all memories of a user">++<CodeGroup>++```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"+ }+]+```+</CodeGroup>+</Accordion>+</AccordionGroup>++<Card title="Mem0 Platform" icon="chart-simple" href="/platform/overview">+ Learn more about Mem0 platform+</Card>++## 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)-- **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.+### 1. Install Mem0 Open Source-- **Healthcare Assistants**: Long-term memory enables healthcare assistants to keep track of patient history, medication schedules, and treatment plans, ensuring personalized and consistent care.+<AccordionGroup>+<Accordion title="Install package">+```bash+pip install mem0ai+```+</Accordion>+</AccordionGroup>-- **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.+### 2. Add Memories <a name="2-add-memories-open-source"></a>-- **Productivity Tools**: Long-term memory helps productivity tools remember user habits, frequently used documents, and task history, streamlining workflows and enhancing efficiency.+<AccordionGroup>+<Accordion title="Instantiate client">+```python Python+from mem0 import Memory+m = Memory()+```+</Accordion>+<Accordion title="Add memories">+<CodeGroup>+```python Code+# For a user+result = m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"})+```-- **Gaming AI**: In gaming, AI with long-term memory can create more immersive experiences by remembering player choices, strategies, and progress, adapting the game environment accordingly.+```json Output+{'message': 'ok'}+```+</CodeGroup>+</Accordion>+</AccordionGroup>-## How is Mem0 different from RAG?+### 3. Retrieve Memories <a name="3-retrieve-memories-open-source"></a>-Mem0's memory implementation for Large Language Models (LLMs) offers several advantages over Retrieval-Augmented Generation (RAG):+<AccordionGroup>+<Accordion title="Search for relevant memories">+<CodeGroup>+```python Code+related_memories = m.search(query="What are Alice's hobbies?", user_id="alice")+```-- **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.+```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"+ }+]+```+</CodeGroup>+</Accordion>+<Accordion title="Get all memories of a user">+<CodeGroup>+```python Code+# Get all memories+all_memories = m.get_all()+```-- **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.+```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"+ }+]+```+</CodeGroup>+</Accordion>+</AccordionGroup>-- **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.+<Card title="Mem0 Open source" icon="code-branch" href="/open-source/overview">+ Learn more about Mem0 open source+</Card>-- **Adaptive Learning**: Mem0 improves its personalization based on user interactions and feedback, making the memory more accurate and tailored to individual users over time.+## Key Features-- **Dynamic Updates**: Mem0 can dynamically update its memory with new information and interactions, unlike RAG which relies on static data. This allows for real-time adjustments and improvements, enhancing the user experience.+- OpenAI-compatible API: Easily switch between OpenAI and Mem0+- Advanced memory management: Efficient handling of long-term context+- Flexible deployment: Choose between managed platform or self-hosted solution-These advanced memory capabilities make Mem0 a powerful tool for developers aiming to create personalized and context-aware AI applications.+Discover all features →-If you have any questions, please feel free to reach out to us using one of the following methods:+## Need help?-<Snippet file="get-help.mdx" />\ No newline at end of file+<Snippet file="get-help.mdx"/>\ No newline at end of file