Compare commits
75 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 052d31939d | |||
| 1c44b675d9 | |||
| a1c9a63074 | |||
| 931df14e25 | |||
| 1b0d8bdd2e | |||
| 5c67a5e6bc | |||
| 267e5b13ea | |||
| a22287a3ba | |||
| da59412150 | |||
| c41719ff9a | |||
| f51b39db91 | |||
| 8d61d73d2f | |||
| 10acf78618 | |||
| caeae60dda | |||
| d7b8497b24 | |||
| a96e1d58f7 | |||
| 0d895b28ae | |||
| 84910b40da | |||
| 0e7c34f541 | |||
| 2b58775c17 | |||
| 326f33757b | |||
| c01221d4aa | |||
| 73d9ccac69 | |||
| 5bbd0d9ca9 | |||
| 641be2878d | |||
| eb7f5a774c | |||
| 6e9f8cf218 | |||
| 02a2b59555 | |||
| ec1d7a45d3 | |||
| 725a1aa114 | |||
| d41f19b9ce | |||
| a0fe9ca5b2 | |||
| c81e2efbb0 | |||
| e9f5a882f5 | |||
| 7117a94fbf | |||
| 63e22382de | |||
| 7b3abd06d0 | |||
| e056acb6a8 | |||
| c09dfc3646 | |||
| 6a1ece13dc | |||
| b74cd9162f | |||
| 42c98e5717 | |||
| ad98f542f8 | |||
| 0fce700e65 | |||
| 393a4fd5a6 | |||
| 6d13e83001 | |||
| 1d916c9dd1 | |||
| 07ddd7cb4b | |||
| f412f8bb0d | |||
| 64c3d34deb | |||
| ff6ae478f1 | |||
| cc5686bd0d | |||
| c958664185 | |||
| d43ca06992 | |||
| ba2e479902 | |||
| cd5c3035ab | |||
| 09ac3618a8 | |||
| 3ee4768c14 | |||
| 78912928bc | |||
| 8bd0d2dc24 | |||
| f0bdd2c341 | |||
| bf0c4adc0c | |||
| 2cca50db80 | |||
| b8e4d0980a | |||
| 3613e2f14a | |||
| 541030d69c | |||
| f77a084d1b | |||
| 33abf772ce | |||
| c3c9205ffa | |||
| 9f204dc557 | |||
| 0e98773efb | |||
| 4431bd7d51 | |||
| 0354ab0d6b | |||
| 6dfc193296 | |||
| 9be6850b9d |
@@ -59,6 +59,10 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: make install_all
|
||||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
|
||||
- name: Run Formatting
|
||||
run: |
|
||||
mkdir -p mem0/.ruff_cache && chmod -R 777 mem0/.ruff_cache
|
||||
cd mem0 && poetry run ruff check . --select F
|
||||
- name: Run tests and generate coverage report
|
||||
run: make test
|
||||
|
||||
@@ -90,6 +94,10 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: cd embedchain && make install_all
|
||||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
|
||||
- name: Run Formatting
|
||||
run: |
|
||||
mkdir -p embedchain/.ruff_cache && chmod -R 777 embedchain/.ruff_cache
|
||||
cd embedchain && poetry run ruff check . --select F
|
||||
- name: Lint with ruff
|
||||
run: cd embedchain && make lint
|
||||
- name: Run tests and generate coverage report
|
||||
|
||||
@@ -12,9 +12,9 @@ install:
|
||||
|
||||
install_all:
|
||||
poetry install
|
||||
poetry run pip install groq together boto3 litellm ollama chromadb weaviate weaviate-client sentence_transformers vertexai \
|
||||
poetry run pip install ruff==0.6.9 groq together boto3 litellm ollama chromadb weaviate weaviate-client sentence_transformers vertexai \
|
||||
google-generativeai elasticsearch opensearch-py vecs pinecone pinecone-text faiss-cpu langchain-community \
|
||||
upstash-vector azure-search-documents
|
||||
upstash-vector azure-search-documents langchain-memgraph
|
||||
|
||||
# Format code with ruff
|
||||
format:
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
<p align="center">
|
||||
<a href="https://github.com/mem0ai/mem0">
|
||||
<img src="docs/images/banner-sm.png" width="800px" alt="Mem0 - The Memory Layer for Personalized AI">
|
||||
<img src="docs/images/banner-sm.png" width="800px" alt="Mem0 - The Memory Layer for Personalized AI">
|
||||
</a>
|
||||
</p>
|
||||
<p align="center" style="display: flex; justify-content: center; gap: 20px; align-items: center;">
|
||||
<a href="https://trendshift.io/repositories/11194" target="_blank">
|
||||
<img src="https://trendshift.io/api/badge/repositories/11194" alt="mem0ai%2Fmem0 | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/>
|
||||
</a>
|
||||
<a href="https://www.ycombinator.com/launches/LpA-mem0-open-source-memory-layer-for-ai-apps" target="_blank">
|
||||
<img alt="Launch YC: Mem0 - Open Source Memory Layer for AI Apps" src="https://www.ycombinator.com/launches/LpA-mem0-open-source-memory-layer-for-ai-apps/upvote_embed.svg"/>
|
||||
<a href="https://trendshift.io/repositories/11194" target="blank">
|
||||
<img src="https://trendshift.io/api/badge/repositories/11194" alt="mem0ai%2Fmem0 | Trendshift" width="250" height="55"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
|
||||
<p align="center">
|
||||
<a href="https://mem0.ai">Learn more</a>
|
||||
·
|
||||
<a href="https://mem0.dev/DiG">Join Discord</a>
|
||||
·
|
||||
<a href="https://mem0.dev/demo">Demo</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://mem0.ai">Learn more</a>
|
||||
·
|
||||
<a href="https://mem0.dev/DiG">Join Discord</a>
|
||||
·
|
||||
<a href="https://mem0.dev/demo">Demo</a>
|
||||
·
|
||||
<a href="https://mem0.dev/openmemory">OpenMemory</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -26,62 +24,78 @@
|
||||
<img src="https://dcbadge.vercel.app/api/server/6PzXDgEjG5?style=flat" alt="Mem0 Discord">
|
||||
</a>
|
||||
<a href="https://pepy.tech/project/mem0ai">
|
||||
<img src="https://img.shields.io/pypi/dm/mem0ai" alt="Mem0 PyPI - Downloads" >
|
||||
<img src="https://img.shields.io/pypi/dm/mem0ai" alt="Mem0 PyPI - Downloads">
|
||||
</a>
|
||||
<a href="https://github.com/mem0ai/mem0">
|
||||
<img src="https://img.shields.io/github/commit-activity/m/mem0ai/mem0?style=flat-square" alt="GitHub commit activity">
|
||||
</a>
|
||||
<a href="https://pypi.org/project/mem0ai" target="_blank">
|
||||
<img src="https://img.shields.io/pypi/v/mem0ai?color=%2334D058&label=pypi%20package" alt="Package version">
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/package/mem0ai" target="_blank">
|
||||
<img src="https://img.shields.io/npm/v/mem0ai" alt="Npm package">
|
||||
</a>
|
||||
<a href="https://pypi.org/project/mem0ai" target="blank">
|
||||
<img src="https://img.shields.io/pypi/v/mem0ai?color=%2334D058&label=pypi%20package" alt="Package version">
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/package/mem0ai" target="blank">
|
||||
<img src="https://img.shields.io/npm/v/mem0ai" alt="Npm package">
|
||||
</a>
|
||||
<a href="https://www.ycombinator.com/companies/mem0">
|
||||
<img src="https://img.shields.io/badge/Y%20Combinator-S24-orange?style=flat-square" alt="Y Combinator S24">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://mem0.ai/research"><strong>📄 Building Production-Ready AI Agents with Scalable Long-Term Memory →</strong></a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<strong>⚡ +26% Accuracy vs. OpenAI Memory • 🚀 91% Faster • 💰 90% Fewer Tokens</strong>
|
||||
</p>
|
||||
|
||||
## 🔥 Research Highlights
|
||||
- **+26% Accuracy** over OpenAI Memory on the LOCOMO benchmark
|
||||
- **91% Faster Responses** than full-context, ensuring low-latency at scale
|
||||
- **90% Lower Token Usage** than full-context, cutting costs without compromise
|
||||
- [Read the full paper](https://mem0.ai/research)
|
||||
|
||||
# Introduction
|
||||
|
||||
[Mem0](https://mem0.ai) (pronounced as "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.ai) ("mem-zero") enhances AI assistants and agents with an intelligent memory layer, enabling personalized AI interactions. It remembers user preferences, adapts to individual needs, and continuously learns over time—ideal for customer support chatbots, AI assistants, and autonomous systems.
|
||||
|
||||
### Features & Use Cases
|
||||
### Key Features & Use Cases
|
||||
|
||||
Core Capabilities:
|
||||
- **Multi-Level Memory**: User, Session, and AI Agent memory retention with adaptive personalization
|
||||
- **Developer-Friendly**: Simple API integration, cross-platform consistency, and hassle-free managed service
|
||||
**Core Capabilities:**
|
||||
- **Multi-Level Memory**: Seamlessly retains User, Session, and Agent state with adaptive personalization
|
||||
- **Developer-Friendly**: Intuitive API, cross-platform SDKs, and a fully managed service option
|
||||
|
||||
Applications:
|
||||
- **AI Assistants**: Seamless conversations with context and personalization
|
||||
- **Learning & Support**: Tailored content recommendations and context-aware customer assistance
|
||||
- **Healthcare & Companions**: Patient history tracking and deeper relationship building
|
||||
- **Productivity & Gaming**: Streamlined workflows and adaptive environments based on user behavior
|
||||
**Applications:**
|
||||
- **AI Assistants**: Consistent, context-rich conversations
|
||||
- **Customer Support**: Recall past tickets and user history for tailored help
|
||||
- **Healthcare**: Track patient preferences and history for personalized care
|
||||
- **Productivity & Gaming**: Adaptive workflows and environments based on user behavior
|
||||
|
||||
## Get Started
|
||||
## 🚀 Quickstart Guide <a name="quickstart"></a>
|
||||
|
||||
Get started quickly with [Mem0 Platform](https://app.mem0.ai) - our fully managed solution that provides automatic updates, advanced analytics, enterprise security, and dedicated support. [Create a free account](https://app.mem0.ai) to begin.
|
||||
Choose between our hosted platform or self-hosted package:
|
||||
|
||||
For complete control, you can self-host Mem0 using our open-source package. See the [Quickstart guide](#quickstart) below to set up your own instance.
|
||||
### Hosted Platform
|
||||
|
||||
## Quickstart Guide <a name="quickstart"></a>
|
||||
Get up and running in minutes with automatic updates, analytics, and enterprise security.
|
||||
|
||||
Install the Mem0 package via pip:
|
||||
1. Sign up on [Mem0 Platform](https://app.mem0.ai)
|
||||
2. Embed the memory layer via SDK or API keys
|
||||
|
||||
### Self-Hosted (Open Source)
|
||||
|
||||
Install the sdk via pip:
|
||||
|
||||
```bash
|
||||
pip install mem0ai
|
||||
```
|
||||
|
||||
Install the Mem0 package via npm:
|
||||
|
||||
Install sdk via npm:
|
||||
```bash
|
||||
npm install mem0ai
|
||||
```
|
||||
|
||||
### Basic Usage
|
||||
|
||||
Mem0 requires an LLM to function, with `gpt-4o-mini` 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).
|
||||
Mem0 requires an LLM to function, with `gpt-4o-mini` from OpenAI as the default. However, it supports a variety of LLMs; for details, refer to our [Supported LLMs documentation](https://docs.mem0.ai/components/llms/overview).
|
||||
|
||||
First step is to instantiate the memory:
|
||||
|
||||
@@ -96,7 +110,7 @@ def chat_with_memories(message: str, user_id: str = "default_user") -> str:
|
||||
# Retrieve relevant memories
|
||||
relevant_memories = memory.search(query=message, user_id=user_id, limit=3)
|
||||
memories_str = "\n".join(f"- {entry['memory']}" for entry in relevant_memories["results"])
|
||||
|
||||
|
||||
# Generate Assistant response
|
||||
system_prompt = f"You are a helpful AI. Answer the question based on query and memories.\nUser Memories:\n{memories_str}"
|
||||
messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": message}]
|
||||
@@ -122,68 +136,34 @@ if __name__ == "__main__":
|
||||
main()
|
||||
```
|
||||
|
||||
See the example for [Node.js](https://docs.mem0.ai/examples/ai_companion_js).
|
||||
For detailed integration steps, see the [Quickstart](https://docs.mem0.ai/quickstart) and [API Reference](https://docs.mem0.ai/api-reference).
|
||||
|
||||
For more advanced usage and API documentation, visit our [documentation](https://docs.mem0.ai).
|
||||
## 🔗 Integrations & Demos
|
||||
|
||||
> [!TIP]
|
||||
> For a hassle-free experience, try our [hosted platform](https://app.mem0.ai) with automatic updates and enterprise features.
|
||||
- **ChatGPT with Memory**: Personalized chat powered by Mem0 ([Live Demo](https://mem0.dev/demo))
|
||||
- **Browser Extension**: Store memories across ChatGPT, Perplexity, and Claude ([Chrome Extension](https://chromewebstore.google.com/detail/onihkkbipkfeijkadecaafbgagkhglop?utm_source=item-share-cb))
|
||||
- **Langgraph Support**: Build a customer bot with Langgraph + Mem0 ([Guide](https://docs.mem0.ai/integrations/langgraph))
|
||||
- **CrewAI Integration**: Tailor CrewAI outputs with Mem0 ([Example](https://docs.mem0.ai/integrations/crewai))
|
||||
|
||||
## Demos
|
||||
## 📚 Documentation & Support
|
||||
|
||||
- Mem0 - ChatGPT with Memory: A personalized AI chat app powered by Mem0 that remembers your preferences, facts, and memories.
|
||||
- Full docs: https://docs.mem0.ai
|
||||
- Community: [Discord](https://mem0.dev/DiG) · [Twitter](https://x.com/mem0ai)
|
||||
- Contact: founders@mem0.ai
|
||||
|
||||
[Mem0 - ChatGPT with Memory](https://github.com/user-attachments/assets/cebc4f8e-bdb9-4837-868d-13c5ab7bb433)
|
||||
## Citation
|
||||
|
||||
Try live [demo](https://mem0.dev/demo/)
|
||||
We now have a paper you can cite:
|
||||
|
||||
<br/><br/>
|
||||
```bibtex
|
||||
@article{mem0,
|
||||
title={Mem0: Building Production-Ready AI Agents with Scalable Long-Term Memory},
|
||||
author={Chhikara, Prateek and Khant, Dev and Aryan, Saket and Singh, Taranjeet and Yadav, Deshraj},
|
||||
journal={arXiv preprint arXiv:2504.19413},
|
||||
year={2025}
|
||||
}
|
||||
```
|
||||
|
||||
- AI Companion: Experience personalized conversations with an AI that remembers your preferences and past interactions
|
||||
## ⚖️ License
|
||||
|
||||
[AI Companion Demo](https://github.com/user-attachments/assets/3fc72023-a72c-4593-8be0-3cee3ba744da)
|
||||
|
||||
<br/><br/>
|
||||
|
||||
- Enhance your AI interactions by storing memories across ChatGPT, Perplexity, and Claude using our browser extension. Get [chrome extension](https://chromewebstore.google.com/detail/mem0/onihkkbipkfeijkadecaafbgagkhglop?hl=en).
|
||||
|
||||
|
||||
[Chrome Extension Demo](https://github.com/user-attachments/assets/ca92e40b-c453-4ff6-b25e-739fb18a8650)
|
||||
|
||||
<br/><br/>
|
||||
|
||||
- Customer support bot using <strong>Langgraph and Mem0</strong>. Get the complete code from [here](https://docs.mem0.ai/integrations/langgraph)
|
||||
|
||||
|
||||
[Langgraph: Customer Bot](https://github.com/user-attachments/assets/ca6b482e-7f46-42c8-aa08-f88d1d93a5f4)
|
||||
|
||||
<br/><br/>
|
||||
|
||||
- Use Mem0 with CrewAI to get personalized results. Full example [here](https://docs.mem0.ai/integrations/crewai)
|
||||
|
||||
[CrewAI Demo](https://github.com/user-attachments/assets/69172a79-ccb9-4340-91f1-caa7d2dd4213)
|
||||
|
||||
|
||||
|
||||
## Documentation
|
||||
|
||||
For detailed usage instructions and API reference, visit our [documentation](https://docs.mem0.ai). You'll find:
|
||||
- Complete API reference
|
||||
- Integration guides
|
||||
- Advanced configuration options
|
||||
- Best practices and examples
|
||||
- More details about:
|
||||
- Open-source version
|
||||
- [Hosted Mem0 Platform](https://app.mem0.ai)
|
||||
|
||||
## Support
|
||||
|
||||
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.dev/DiG)
|
||||
- [Follow us on Twitter](https://x.com/mem0ai)
|
||||
- [Email founders](mailto:founders@mem0.ai)
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.
|
||||
Apache 2.0 — see the [LICENSE](LICENSE) file for details.
|
||||
@@ -7,10 +7,12 @@
|
||||
# forked from autogen.agentchat.contrib.capabilities.teachability.Teachability
|
||||
|
||||
from typing import Dict, Optional, Union
|
||||
|
||||
from autogen.agentchat.assistant_agent import ConversableAgent
|
||||
from autogen.agentchat.contrib.capabilities.agent_capability import AgentCapability
|
||||
from autogen.agentchat.contrib.text_analyzer_agent import TextAnalyzerAgent
|
||||
from termcolor import colored
|
||||
|
||||
from mem0 import Memory
|
||||
|
||||
|
||||
|
||||
+259
-259
@@ -1,42 +1,116 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "1e8a980a2e0b9a85",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%pip install --upgrade pip\n",
|
||||
"%pip install mem0ai pyautogen flaml"
|
||||
],
|
||||
"id": "1e8a980a2e0b9a85",
|
||||
"outputs": [],
|
||||
"execution_count": null
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"id": "d437544fe259dd1b",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-09-25T20:29:52.443024Z",
|
||||
"start_time": "2024-09-25T20:29:52.440046Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Set up ENV Vars\n",
|
||||
"import os\n",
|
||||
"os.environ['OPENAI_API_KEY'] = \"sk-xxx\"\n"
|
||||
],
|
||||
"id": "d437544fe259dd1b",
|
||||
"outputs": [],
|
||||
"execution_count": 11
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"id": "initial_id",
|
||||
"metadata": {
|
||||
"collapsed": true,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-09-25T20:30:03.914245Z",
|
||||
"start_time": "2024-09-25T20:29:53.236601Z"
|
||||
}
|
||||
},
|
||||
"collapsed": true
|
||||
},
|
||||
"cell_type": "code",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"WARNING:autogen.agentchat.contrib.gpt_assistant_agent:OpenAI client config of GPTAssistantAgent(assistant) - model: gpt-4o\n",
|
||||
"WARNING:autogen.agentchat.contrib.gpt_assistant_agent:Matching assistant found, using the first matching assistant: {'id': 'asst_PpOJ2mJC8QeysR54I6DEdi4E', 'created_at': 1726444855, 'description': None, 'instructions': 'You are a helpful AI assistant.\\nSolve tasks using your coding and language skills.\\nIn the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute.\\n 1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself.\\n 2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly.\\nSolve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill.\\nWhen using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can\\'t modify your code. So do not suggest incomplete code which requires users to modify. Don\\'t use a code block if it\\'s not intended to be executed by the user.\\nIf you want the user to save the code in a file before executing it, put # filename: <filename> inside the code block as the first line. Don\\'t include multiple code blocks in one response. Do not ask users to copy and paste the result. Instead, use \\'print\\' function for the output when relevant. Check the execution result returned by the user.\\nIf the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can\\'t be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.\\nWhen you find an answer, verify the answer carefully. Include verifiable evidence in your response if possible.\\nReply \"TERMINATE\" in the end when everything is done.\\n ', 'metadata': {}, 'model': 'gpt-4o', 'name': 'assistant', 'object': 'assistant', 'tools': [], 'response_format': 'auto', 'temperature': 1.0, 'tool_resources': ToolResources(code_interpreter=None, file_search=None), 'top_p': 1.0}\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001b[33muser_proxy\u001b[0m (to assistant):\n",
|
||||
"\n",
|
||||
"Write a Python function that reverses a string.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"Sure! Here is the Python code for a function that takes a string as input and returns the reversed string.\n",
|
||||
"\n",
|
||||
"```python\n",
|
||||
"def reverse_string(s):\n",
|
||||
" return s[::-1]\n",
|
||||
"\n",
|
||||
"# Example usage\n",
|
||||
"if __name__ == \"__main__\":\n",
|
||||
" example_string = \"Hello, world!\"\n",
|
||||
" reversed_string = reverse_string(example_string)\n",
|
||||
" print(f\"Original string: {example_string}\")\n",
|
||||
" print(f\"Reversed string: {reversed_string}\")\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"When you run this code, it will print the original string and the reversed string. You can replace `example_string` with any string you want to reverse.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[31m\n",
|
||||
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to assistant):\n",
|
||||
"\n",
|
||||
"exitcode: 0 (execution succeeded)\n",
|
||||
"Code output: \n",
|
||||
"Original string: Hello, world!\n",
|
||||
"Reversed string: !dlrow ,olleH\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"Great, the function worked as expected! The original string \"Hello, world!\" was correctly reversed to \"!dlrow ,olleH\".\n",
|
||||
"\n",
|
||||
"If you have any other tasks or need further assistance, let me know! \n",
|
||||
"\n",
|
||||
"TERMINATE\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"ChatResult(chat_id=None, chat_history=[{'content': 'Write a Python function that reverses a string.', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'Sure! Here is the Python code for a function that takes a string as input and returns the reversed string.\\n\\n```python\\ndef reverse_string(s):\\n return s[::-1]\\n\\n# Example usage\\nif __name__ == \"__main__\":\\n example_string = \"Hello, world!\"\\n reversed_string = reverse_string(example_string)\\n print(f\"Original string: {example_string}\")\\n print(f\"Reversed string: {reversed_string}\")\\n```\\n\\nWhen you run this code, it will print the original string and the reversed string. You can replace `example_string` with any string you want to reverse.\\n', 'role': 'user', 'name': 'assistant'}, {'content': 'exitcode: 0 (execution succeeded)\\nCode output: \\nOriginal string: Hello, world!\\nReversed string: !dlrow ,olleH\\n', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'Great, the function worked as expected! The original string \"Hello, world!\" was correctly reversed to \"!dlrow ,olleH\".\\n\\nIf you have any other tasks or need further assistance, let me know! \\n\\nTERMINATE\\n', 'role': 'user', 'name': 'assistant'}], summary='Great, the function worked as expected! The original string \"Hello, world!\" was correctly reversed to \"!dlrow ,olleH\".\\n\\nIf you have any other tasks or need further assistance, let me know! \\n\\n\\n', cost={'usage_including_cached_inference': {'total_cost': 0}, 'usage_excluding_cached_inference': {'total_cost': 0}}, human_input=[])"
|
||||
]
|
||||
},
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# AutoGen GPTAssistantAgent Capabilities:\n",
|
||||
"# - Generates code based on user requirements and preferences.\n",
|
||||
@@ -93,90 +167,40 @@
|
||||
"user_query = \"Write a Python function that reverses a string.\"\n",
|
||||
"# Initiate Chat w/o Memory\n",
|
||||
"user_proxy.initiate_chat(gpt_assistant, message=user_query)"
|
||||
],
|
||||
"id": "initial_id",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"WARNING:autogen.agentchat.contrib.gpt_assistant_agent:OpenAI client config of GPTAssistantAgent(assistant) - model: gpt-4o\n",
|
||||
"WARNING:autogen.agentchat.contrib.gpt_assistant_agent:Matching assistant found, using the first matching assistant: {'id': 'asst_PpOJ2mJC8QeysR54I6DEdi4E', 'created_at': 1726444855, 'description': None, 'instructions': 'You are a helpful AI assistant.\\nSolve tasks using your coding and language skills.\\nIn the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute.\\n 1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself.\\n 2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly.\\nSolve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill.\\nWhen using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can\\'t modify your code. So do not suggest incomplete code which requires users to modify. Don\\'t use a code block if it\\'s not intended to be executed by the user.\\nIf you want the user to save the code in a file before executing it, put # filename: <filename> inside the code block as the first line. Don\\'t include multiple code blocks in one response. Do not ask users to copy and paste the result. Instead, use \\'print\\' function for the output when relevant. Check the execution result returned by the user.\\nIf the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can\\'t be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.\\nWhen you find an answer, verify the answer carefully. Include verifiable evidence in your response if possible.\\nReply \"TERMINATE\" in the end when everything is done.\\n ', 'metadata': {}, 'model': 'gpt-4o', 'name': 'assistant', 'object': 'assistant', 'tools': [], 'response_format': 'auto', 'temperature': 1.0, 'tool_resources': ToolResources(code_interpreter=None, file_search=None), 'top_p': 1.0}\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001B[33muser_proxy\u001B[0m (to assistant):\n",
|
||||
"\n",
|
||||
"Write a Python function that reverses a string.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33massistant\u001B[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"Sure! Here is the Python code for a function that takes a string as input and returns the reversed string.\n",
|
||||
"\n",
|
||||
"```python\n",
|
||||
"def reverse_string(s):\n",
|
||||
" return s[::-1]\n",
|
||||
"\n",
|
||||
"# Example usage\n",
|
||||
"if __name__ == \"__main__\":\n",
|
||||
" example_string = \"Hello, world!\"\n",
|
||||
" reversed_string = reverse_string(example_string)\n",
|
||||
" print(f\"Original string: {example_string}\")\n",
|
||||
" print(f\"Reversed string: {reversed_string}\")\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"When you run this code, it will print the original string and the reversed string. You can replace `example_string` with any string you want to reverse.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[31m\n",
|
||||
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001B[0m\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to assistant):\n",
|
||||
"\n",
|
||||
"exitcode: 0 (execution succeeded)\n",
|
||||
"Code output: \n",
|
||||
"Original string: Hello, world!\n",
|
||||
"Reversed string: !dlrow ,olleH\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33massistant\u001B[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"Great, the function worked as expected! The original string \"Hello, world!\" was correctly reversed to \"!dlrow ,olleH\".\n",
|
||||
"\n",
|
||||
"If you have any other tasks or need further assistance, let me know! \n",
|
||||
"\n",
|
||||
"TERMINATE\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"ChatResult(chat_id=None, chat_history=[{'content': 'Write a Python function that reverses a string.', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'Sure! Here is the Python code for a function that takes a string as input and returns the reversed string.\\n\\n```python\\ndef reverse_string(s):\\n return s[::-1]\\n\\n# Example usage\\nif __name__ == \"__main__\":\\n example_string = \"Hello, world!\"\\n reversed_string = reverse_string(example_string)\\n print(f\"Original string: {example_string}\")\\n print(f\"Reversed string: {reversed_string}\")\\n```\\n\\nWhen you run this code, it will print the original string and the reversed string. You can replace `example_string` with any string you want to reverse.\\n', 'role': 'user', 'name': 'assistant'}, {'content': 'exitcode: 0 (execution succeeded)\\nCode output: \\nOriginal string: Hello, world!\\nReversed string: !dlrow ,olleH\\n', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'Great, the function worked as expected! The original string \"Hello, world!\" was correctly reversed to \"!dlrow ,olleH\".\\n\\nIf you have any other tasks or need further assistance, let me know! \\n\\nTERMINATE\\n', 'role': 'user', 'name': 'assistant'}], summary='Great, the function worked as expected! The original string \"Hello, world!\" was correctly reversed to \"!dlrow ,olleH\".\\n\\nIf you have any other tasks or need further assistance, let me know! \\n\\n\\n', cost={'usage_including_cached_inference': {'total_cost': 0}, 'usage_excluding_cached_inference': {'total_cost': 0}}, human_input=[])"
|
||||
]
|
||||
},
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"execution_count": 12
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"id": "c2fe6fd02324be37",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-09-25T20:31:40.536369Z",
|
||||
"start_time": "2024-09-25T20:31:31.078911Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/var/folders/z6/3w4ng1lj3mn4vmhplgc4y0580000gn/T/ipykernel_77647/3850691550.py:28: DeprecationWarning: The current add API output format is deprecated. To use the latest format, set `api_version='v1.1'`. The current format will be removed in mem0ai 1.1.0 and later versions.\n",
|
||||
" MEM0_MEMORY_CLIENT.add(MEMORY_DATA, user_id=USER_ID)\n",
|
||||
"/var/folders/z6/3w4ng1lj3mn4vmhplgc4y0580000gn/T/ipykernel_77647/3850691550.py:29: DeprecationWarning: The current add API output format is deprecated. To use the latest format, set `api_version='v1.1'`. The current format will be removed in mem0ai 1.1.0 and later versions.\n",
|
||||
" MEM0_MEMORY_CLIENT.add(MEMORY_DATA, agent_id=AGENT_ID)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'message': 'ok'}"
|
||||
]
|
||||
},
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Benefits of Preference Memory in AutoGen Agents:\n",
|
||||
"# - Personalization: Tailors responses to individual user or team preferences.\n",
|
||||
@@ -207,61 +231,28 @@
|
||||
"# Add preference data to memory\n",
|
||||
"MEM0_MEMORY_CLIENT.add(MEMORY_DATA, user_id=USER_ID)\n",
|
||||
"MEM0_MEMORY_CLIENT.add(MEMORY_DATA, agent_id=AGENT_ID)"
|
||||
],
|
||||
"id": "c2fe6fd02324be37",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/var/folders/z6/3w4ng1lj3mn4vmhplgc4y0580000gn/T/ipykernel_77647/3850691550.py:28: DeprecationWarning: The current add API output format is deprecated. To use the latest format, set `api_version='v1.1'`. The current format will be removed in mem0ai 1.1.0 and later versions.\n",
|
||||
" MEM0_MEMORY_CLIENT.add(MEMORY_DATA, user_id=USER_ID)\n",
|
||||
"/var/folders/z6/3w4ng1lj3mn4vmhplgc4y0580000gn/T/ipykernel_77647/3850691550.py:29: DeprecationWarning: The current add API output format is deprecated. To use the latest format, set `api_version='v1.1'`. The current format will be removed in mem0ai 1.1.0 and later versions.\n",
|
||||
" MEM0_MEMORY_CLIENT.add(MEMORY_DATA, agent_id=AGENT_ID)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'message': 'ok'}"
|
||||
]
|
||||
},
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"execution_count": 16
|
||||
]
|
||||
},
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"id": "fb6d6a8f36aedfd6",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Option 1: \n",
|
||||
"Using Direct Prompt Injection:\n",
|
||||
"`user memory example`"
|
||||
],
|
||||
"id": "fb6d6a8f36aedfd6"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"id": "29be484c69093371",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-09-25T20:31:52.411604Z",
|
||||
"start_time": "2024-09-25T20:31:40.611497Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# Retrieve the memory\n",
|
||||
"relevant_memories = MEM0_MEMORY_CLIENT.search(user_query, user_id=USER_ID, limit=3)\n",
|
||||
"relevant_memories_text = '\\n'.join(mem['memory'] for mem in relevant_memories)\n",
|
||||
"print(f\"Relevant memories:\")\n",
|
||||
"print(relevant_memories_text)\n",
|
||||
"\n",
|
||||
"prompt = f\"{user_query}\\n Coding Preferences: \\n{relevant_memories_text}\"\n",
|
||||
"browse_result = user_proxy.initiate_chat(gpt_assistant, message=prompt)"
|
||||
],
|
||||
"id": "29be484c69093371",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
@@ -280,7 +271,7 @@
|
||||
"Prefers functions to have a descriptive docstring\n",
|
||||
"Prefers camelCase for variable names\n",
|
||||
"Prefers code to be explicitly written with clear variable names\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to assistant):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to assistant):\n",
|
||||
"\n",
|
||||
"Write a Python function that reverses a string.\n",
|
||||
" Coding Preferences: \n",
|
||||
@@ -289,7 +280,7 @@
|
||||
"Prefers code to be explicitly written with clear variable names\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33massistant\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"Sure, I will write a Python function that reverses a given string with clear and descriptive variable names, along with a descriptive docstring.\n",
|
||||
"\n",
|
||||
@@ -324,9 +315,9 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[31m\n",
|
||||
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001B[0m\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to assistant):\n",
|
||||
"\u001b[31m\n",
|
||||
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to assistant):\n",
|
||||
"\n",
|
||||
"exitcode: 0 (execution succeeded)\n",
|
||||
"Code output: \n",
|
||||
@@ -335,7 +326,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33massistant\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"Great! It looks like the code executed successfully and produced the correct output, reversing the string \"Hello World!\" to \"!dlroW olleH\".\n",
|
||||
"\n",
|
||||
@@ -354,26 +345,38 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 17
|
||||
"source": [
|
||||
"# Retrieve the memory\n",
|
||||
"relevant_memories = MEM0_MEMORY_CLIENT.search(user_query, user_id=USER_ID, limit=3)\n",
|
||||
"relevant_memories_text = '\\n'.join(mem['memory'] for mem in relevant_memories)\n",
|
||||
"print(\"Relevant memories:\")\n",
|
||||
"print(relevant_memories_text)\n",
|
||||
"\n",
|
||||
"prompt = f\"{user_query}\\n Coding Preferences: \\n{relevant_memories_text}\"\n",
|
||||
"browse_result = user_proxy.initiate_chat(gpt_assistant, message=prompt)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"id": "fc0ae72d0ef7f6de",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Option 2:\n",
|
||||
"Using UserProxyAgent: \n",
|
||||
"`agent memory example`"
|
||||
],
|
||||
"id": "fc0ae72d0ef7f6de"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"id": "bfd9342cf2096ca5",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-09-25T20:31:52.421965Z",
|
||||
"start_time": "2024-09-25T20:31:52.418762Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# UserProxyAgent in AutoGen:\n",
|
||||
"# - Acts as intermediary between humans and AI agents in the AutoGen framework.\n",
|
||||
@@ -405,39 +408,24 @@
|
||||
" self.memory.add(MEMORY_DATA, agent_id=self.agent_id)\n",
|
||||
" return response\n",
|
||||
" "
|
||||
],
|
||||
"id": "bfd9342cf2096ca5",
|
||||
"outputs": [],
|
||||
"execution_count": 18
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"id": "6d2a757d1cf65881",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-09-25T20:32:20.269222Z",
|
||||
"start_time": "2024-09-25T20:32:07.485051Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"mem0_user_proxy = Mem0ProxyCoderAgent(\n",
|
||||
" name=AGENT_ID,\n",
|
||||
" code_execution_config={\n",
|
||||
" \"work_dir\": \"coding\",\n",
|
||||
" \"use_docker\": False,\n",
|
||||
" }, # Please set use_docker=True if docker is available to run the generated code. Using docker is safer than running the generated code directly.\n",
|
||||
" is_termination_msg=lambda msg: \"TERMINATE\" in msg[\"content\"],\n",
|
||||
" human_input_mode=\"NEVER\",\n",
|
||||
" max_consecutive_auto_reply=1,\n",
|
||||
")\n",
|
||||
"code_result = mem0_user_proxy.initiate_chat(gpt_assistant, message=user_query)"
|
||||
],
|
||||
"id": "6d2a757d1cf65881",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001B[33mchicory.ai\u001B[0m (to assistant):\n",
|
||||
"\u001b[33mchicory.ai\u001b[0m (to assistant):\n",
|
||||
"\n",
|
||||
"Write a Python function that reverses a string.\n",
|
||||
" Coding Preferences: \n",
|
||||
@@ -460,7 +448,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001B[33massistant\u001B[0m (to chicory.ai):\n",
|
||||
"\u001b[33massistant\u001b[0m (to chicory.ai):\n",
|
||||
"\n",
|
||||
"Sure, I'll write a Python function that reverses a string following your coding preferences.\n",
|
||||
"\n",
|
||||
@@ -487,9 +475,9 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[31m\n",
|
||||
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001B[0m\n",
|
||||
"\u001B[33mchicory.ai\u001B[0m (to assistant):\n",
|
||||
"\u001b[31m\n",
|
||||
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n",
|
||||
"\u001b[33mchicory.ai\u001b[0m (to assistant):\n",
|
||||
"\n",
|
||||
"exitcode: 0 (execution succeeded)\n",
|
||||
"Code output: \n",
|
||||
@@ -497,7 +485,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33massistant\u001B[0m (to chicory.ai):\n",
|
||||
"\u001b[33massistant\u001b[0m (to chicory.ai):\n",
|
||||
"\n",
|
||||
"Great! The function has successfully reversed the string as expected.\n",
|
||||
"\n",
|
||||
@@ -518,26 +506,41 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 19
|
||||
"source": [
|
||||
"mem0_user_proxy = Mem0ProxyCoderAgent(\n",
|
||||
" name=AGENT_ID,\n",
|
||||
" code_execution_config={\n",
|
||||
" \"work_dir\": \"coding\",\n",
|
||||
" \"use_docker\": False,\n",
|
||||
" }, # Please set use_docker=True if docker is available to run the generated code. Using docker is safer than running the generated code directly.\n",
|
||||
" is_termination_msg=lambda msg: \"TERMINATE\" in msg[\"content\"],\n",
|
||||
" human_input_mode=\"NEVER\",\n",
|
||||
" max_consecutive_auto_reply=1,\n",
|
||||
")\n",
|
||||
"code_result = mem0_user_proxy.initiate_chat(gpt_assistant, message=user_query)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"id": "7706c06216ca4374",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Option 3:\n",
|
||||
"Using Teachability:\n",
|
||||
"`agent memory example`"
|
||||
],
|
||||
"id": "7706c06216ca4374"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"id": "ae6bb87061877645",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-09-25T20:33:17.737146Z",
|
||||
"start_time": "2024-09-25T20:33:17.713250Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# building on top of existing Teachability package from autogen\n",
|
||||
"# from autogen.agentchat.contrib.capabilities.teachability import Teachability\n",
|
||||
@@ -564,24 +567,18 @@
|
||||
" memory_client = MEM0_MEMORY_CLIENT,\n",
|
||||
" )\n",
|
||||
"teachability.add_to_agent(user_proxy)"
|
||||
],
|
||||
"id": "ae6bb87061877645",
|
||||
"outputs": [],
|
||||
"execution_count": 20
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"id": "36c9bcbedcd406b4",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-09-25T20:33:46.616261Z",
|
||||
"start_time": "2024-09-25T20:33:19.719999Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# Initiate Chat w/ Teachability + Memory\n",
|
||||
"user_proxy.initiate_chat(gpt_assistant, message=user_query)"
|
||||
],
|
||||
"id": "36c9bcbedcd406b4",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
@@ -594,12 +591,12 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001B[33muser_proxy\u001B[0m (to assistant):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to assistant):\n",
|
||||
"\n",
|
||||
"Write a Python function that reverses a string.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33massistant\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"Sure, I'll provide you with a Python function that takes a string as input and returns the reversed string. Here is the complete code:\n",
|
||||
"\n",
|
||||
@@ -626,9 +623,9 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[93m\n",
|
||||
"LOOK FOR RELEVANT MEMOS, AS QUESTION-ANSWER PAIRS\u001B[0m\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[93m\n",
|
||||
"LOOK FOR RELEVANT MEMOS, AS QUESTION-ANSWER PAIRS\u001b[0m\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Sure, I'll provide you with a Python function that takes a string as input and returns the reversed string. Here is the complete code:\n",
|
||||
"\n",
|
||||
@@ -655,19 +652,19 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Does any part of the TEXT ask the agent to perform a task or solve a problem? Answer with just one word, yes or no.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"Yes\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[93m\n",
|
||||
"LOOK FOR RELEVANT MEMOS, AS TASK-ADVICE PAIRS\u001B[0m\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[93m\n",
|
||||
"LOOK FOR RELEVANT MEMOS, AS TASK-ADVICE PAIRS\u001b[0m\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Sure, I'll provide you with a Python function that takes a string as input and returns the reversed string. Here is the complete code:\n",
|
||||
"\n",
|
||||
@@ -694,32 +691,32 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Copy just the task from the TEXT, then stop. Don't solve it, and don't include any advice.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"Save the above code in a file named `reverse_string.py`, then execute it. This script defines the `reverse_string` function and demonstrates its usage by reversing the string \"Hello, World!\". It will print both the original and reversed strings.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Save the above code in a file named `reverse_string.py`, then execute it. This script defines the `reverse_string` function and demonstrates its usage by reversing the string \"Hello, World!\". It will print both the original and reversed strings.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Summarize very briefly, in general terms, the type of task described in the TEXT. Leave out details that might not appear in a similar problem.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"The task involves saving a script to a file, executing it, and demonstrating a function that reverses a string.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[93m\n",
|
||||
"\u001b[93m\n",
|
||||
"MEMOS APPENDED TO LAST MESSAGE...\n",
|
||||
"\n",
|
||||
"# Memories that might help\n",
|
||||
@@ -728,8 +725,8 @@
|
||||
"- Prefers comments explaining each step\n",
|
||||
"- Prefers code to be explicitly written with clear variable names\n",
|
||||
"\n",
|
||||
"\u001B[0m\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[0m\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Sure, I'll provide you with a Python function that takes a string as input and returns the reversed string. Here is the complete code:\n",
|
||||
"\n",
|
||||
@@ -756,17 +753,17 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Does any part of the TEXT ask the agent to perform a task or solve a problem? Answer with just one word, yes or no.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"Yes\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Sure, I'll provide you with a Python function that takes a string as input and returns the reversed string. Here is the complete code:\n",
|
||||
"\n",
|
||||
@@ -793,17 +790,17 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Briefly copy any advice from the TEXT that may be useful for a similar but different task in the future. But if no advice is present, just respond with 'none'.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"Save the above code in a file named `reverse_string.py`, then execute it.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Sure, I'll provide you with a Python function that takes a string as input and returns the reversed string. Here is the complete code:\n",
|
||||
"\n",
|
||||
@@ -830,34 +827,34 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Briefly copy just the task from the TEXT, then stop. Don't solve it, and don't include any advice.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"Save the above code in a file named `reverse_string.py`, then execute it. This script defines the `reverse_string` function and demonstrates its usage by reversing the string \"Hello, World!\". It will print both the original and reversed strings.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Save the above code in a file named `reverse_string.py`, then execute it. This script defines the `reverse_string` function and demonstrates its usage by reversing the string \"Hello, World!\". It will print both the original and reversed strings.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Summarize very briefly, in general terms, the type of task described in the TEXT. Leave out details that might not appear in a similar problem.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"The task involves saving a script to a file, executing it, and demonstrating a function that reverses a string.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[93m\n",
|
||||
"REMEMBER THIS TASK-ADVICE PAIR\u001B[0m\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[93m\n",
|
||||
"REMEMBER THIS TASK-ADVICE PAIR\u001b[0m\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Sure, I'll provide you with a Python function that takes a string as input and returns the reversed string. Here is the complete code:\n",
|
||||
"\n",
|
||||
@@ -884,17 +881,17 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Does the TEXT contain information that could be committed to memory? Answer with just one word, yes or no.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"Yes\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Sure, I'll provide you with a Python function that takes a string as input and returns the reversed string. Here is the complete code:\n",
|
||||
"\n",
|
||||
@@ -921,17 +918,17 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Imagine that the user forgot this information in the TEXT. How would they ask you for this information? Include no other text in your response.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"How do I reverse a string in Python?\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Sure, I'll provide you with a Python function that takes a string as input and returns the reversed string. Here is the complete code:\n",
|
||||
"\n",
|
||||
@@ -958,12 +955,12 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Copy the information from the TEXT that should be committed to memory. Add no explanation.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"```python\n",
|
||||
"# filename: reverse_string.py\n",
|
||||
@@ -985,11 +982,11 @@
|
||||
"```\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[93m\n",
|
||||
"REMEMBER THIS QUESTION-ANSWER PAIR\u001B[0m\n",
|
||||
"\u001B[31m\n",
|
||||
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001B[0m\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to assistant):\n",
|
||||
"\u001b[93m\n",
|
||||
"REMEMBER THIS QUESTION-ANSWER PAIR\u001b[0m\n",
|
||||
"\u001b[31m\n",
|
||||
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to assistant):\n",
|
||||
"\n",
|
||||
"exitcode: 0 (execution succeeded)\n",
|
||||
"Code output: \n",
|
||||
@@ -998,7 +995,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33massistant\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"The code executed successfully, and the output is correct. The string \"Hello, World!\" was successfully reversed to \"!dlroW ,olleH\".\n",
|
||||
"\n",
|
||||
@@ -1008,9 +1005,9 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[93m\n",
|
||||
"LOOK FOR RELEVANT MEMOS, AS QUESTION-ANSWER PAIRS\u001B[0m\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[93m\n",
|
||||
"LOOK FOR RELEVANT MEMOS, AS QUESTION-ANSWER PAIRS\u001b[0m\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"The code executed successfully, and the output is correct. The string \"Hello, World!\" was successfully reversed to \"!dlroW ,olleH\".\n",
|
||||
"\n",
|
||||
@@ -1020,19 +1017,19 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Does any part of the TEXT ask the agent to perform a task or solve a problem? Answer with just one word, yes or no.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"Yes\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[93m\n",
|
||||
"LOOK FOR RELEVANT MEMOS, AS TASK-ADVICE PAIRS\u001B[0m\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[93m\n",
|
||||
"LOOK FOR RELEVANT MEMOS, AS TASK-ADVICE PAIRS\u001b[0m\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"The code executed successfully, and the output is correct. The string \"Hello, World!\" was successfully reversed to \"!dlroW ,olleH\".\n",
|
||||
"\n",
|
||||
@@ -1042,32 +1039,32 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Copy just the task from the TEXT, then stop. Don't solve it, and don't include any advice.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"If you have any other tasks or need further assistance, feel free to ask.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"If you have any other tasks or need further assistance, feel free to ask.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Summarize very briefly, in general terms, the type of task described in the TEXT. Leave out details that might not appear in a similar problem.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"The task described in the TEXT involves offering help or assistance with various tasks.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[93m\n",
|
||||
"\u001b[93m\n",
|
||||
"MEMOS APPENDED TO LAST MESSAGE...\n",
|
||||
"\n",
|
||||
"# Memories that might help\n",
|
||||
@@ -1078,8 +1075,8 @@
|
||||
"- Code should be saved in a file named 'reverse_string.py'\n",
|
||||
"- Prefers camelCase for variable names\n",
|
||||
"\n",
|
||||
"\u001B[0m\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[0m\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"The code executed successfully, and the output is correct. The string \"Hello, World!\" was successfully reversed to \"!dlroW ,olleH\".\n",
|
||||
"\n",
|
||||
@@ -1089,17 +1086,17 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Does any part of the TEXT ask the agent to perform a task or solve a problem? Answer with just one word, yes or no.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"Yes\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"The code executed successfully, and the output is correct. The string \"Hello, World!\" was successfully reversed to \"!dlroW ,olleH\".\n",
|
||||
"\n",
|
||||
@@ -1109,17 +1106,17 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Briefly copy any advice from the TEXT that may be useful for a similar but different task in the future. But if no advice is present, just respond with 'none'.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"none\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"The code executed successfully, and the output is correct. The string \"Hello, World!\" was successfully reversed to \"!dlroW ,olleH\".\n",
|
||||
"\n",
|
||||
@@ -1129,17 +1126,17 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Does the TEXT contain information that could be committed to memory? Answer with just one word, yes or no.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"Yes\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"The code executed successfully, and the output is correct. The string \"Hello, World!\" was successfully reversed to \"!dlroW ,olleH\".\n",
|
||||
"\n",
|
||||
@@ -1149,17 +1146,17 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Imagine that the user forgot this information in the TEXT. How would they ask you for this information? Include no other text in your response.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"What was the original string that was reversed to \"!dlroW ,olleH\"?\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"The code executed successfully, and the output is correct. The string \"Hello, World!\" was successfully reversed to \"!dlroW ,olleH\".\n",
|
||||
"\n",
|
||||
@@ -1169,18 +1166,18 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33muser_proxy\u001B[0m (to analyzer):\n",
|
||||
"\u001b[33muser_proxy\u001b[0m (to analyzer):\n",
|
||||
"\n",
|
||||
"Copy the information from the TEXT that should be committed to memory. Add no explanation.\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[33manalyzer\u001B[0m (to user_proxy):\n",
|
||||
"\u001b[33manalyzer\u001b[0m (to user_proxy):\n",
|
||||
"\n",
|
||||
"The string \"Hello, World!\" was successfully reversed to \"!dlroW ,olleH\".\n",
|
||||
"\n",
|
||||
"--------------------------------------------------------------------------------\n",
|
||||
"\u001B[93m\n",
|
||||
"REMEMBER THIS QUESTION-ANSWER PAIR\u001B[0m\n"
|
||||
"\u001b[93m\n",
|
||||
"REMEMBER THIS QUESTION-ANSWER PAIR\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1194,7 +1191,10 @@
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"execution_count": 21
|
||||
"source": [
|
||||
"# Initiate Chat w/ Teachability + Memory\n",
|
||||
"user_proxy.initiate_chat(gpt_assistant, message=user_query)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<Note type="info">
|
||||
📢 Announcing our research paper: Mem0 achieves <strong>26%</strong> higher accuracy than OpenAI Memory, <strong>91%</strong> lower latency, and <strong>90%</strong> token savings! [Read the paper](https://mem0.ai/research) to learn how we're revolutionizing AI agent memory.
|
||||
</Note>
|
||||
@@ -4,6 +4,8 @@ icon: "info"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Mem0 provides a powerful set of APIs that allow you to integrate advanced memory management capabilities into your applications. Our APIs are designed to be intuitive, efficient, and scalable, enabling you to create, retrieve, update, and delete memories across various entities such as users, agents, apps, and runs.
|
||||
|
||||
## Key Features
|
||||
@@ -14,11 +14,11 @@ The v2 search API is powerful and flexible, allowing for more precise memory ret
|
||||
|
||||
<CodeGroup>
|
||||
```python Code
|
||||
related_memories = m.vsearch(
|
||||
related_memories = m.search(
|
||||
query="What are Alice's hobbies?",
|
||||
version="v2",
|
||||
filters={
|
||||
"AND": [
|
||||
"OR": [
|
||||
{
|
||||
"user_id": "alice"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,508 @@
|
||||
---
|
||||
title: "Product Updates"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
<Tabs>
|
||||
<Tab title="Python">
|
||||
|
||||
<Update label="2025-04-26" description="v0.1.94">
|
||||
|
||||
**New Features:**
|
||||
- **Integrations:** Added Memgraph integration
|
||||
- **Memory:** Added timestamp support
|
||||
- **Vector Stores:** Added reset function for VectorDBs
|
||||
|
||||
**Improvements:**
|
||||
- **Documentation:**
|
||||
- Updated timestamp and expiration_date documentation
|
||||
- Fixed v2 search documentation
|
||||
- Added "memory" in EC "Custom config" section
|
||||
- Fixed typos in the json config sample
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-21" description="v0.1.93">
|
||||
|
||||
**Improvements:**
|
||||
- **Vector Stores:** Initialized embedding_model_dims in all vectordbs
|
||||
|
||||
**Bug Fixes:**
|
||||
- **Documentation:** Fixed agno link
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-18" description="v0.1.92">
|
||||
|
||||
**New Features:**
|
||||
- **Memory:** Added Memory Reset functionality
|
||||
- **Client:** Added support for Custom Instructions
|
||||
- **Examples:** Added Fitness Checker powered by memory
|
||||
|
||||
**Improvements:**
|
||||
- **Core:** Updated capture_event
|
||||
- **Documentation:** Fixed curl for v2 get_all
|
||||
|
||||
**Bug Fixes:**
|
||||
- **Vector Store:** Fixed user_id functionality
|
||||
- **Client:** Various client improvements
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-16" description="v0.1.91">
|
||||
|
||||
**New Features:**
|
||||
- **LLM Integrations:** Added Azure OpenAI Embedding Model
|
||||
- **Examples:**
|
||||
- Added movie recommendation using grok3
|
||||
- Added Voice Assistant using Elevenlabs
|
||||
|
||||
**Improvements:**
|
||||
- **Documentation:**
|
||||
- Added keywords AI
|
||||
- Reformatted navbar page URLs
|
||||
- Updated changelog
|
||||
- Updated openai.mdx
|
||||
- **FAISS:** Silenced FAISS info logs
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-11" description="v0.1.90">
|
||||
|
||||
**New Features:**
|
||||
- **LLM Integrations:** Added Mistral AI as LLM provider
|
||||
|
||||
**Improvements:**
|
||||
- **Documentation:**
|
||||
- Updated changelog
|
||||
- Fixed memory exclusion example
|
||||
- Updated xAI documentation
|
||||
- Updated YouTube Chrome extension example documentation
|
||||
|
||||
**Bug Fixes:**
|
||||
- **Core:** Fixed EmbedderFactory.create() in GraphMemory
|
||||
- **Azure OpenAI:** Added patch to fix Azure OpenAI
|
||||
- **Telemetry:** Fixed telemetry issue
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-11" description="v0.1.89">
|
||||
|
||||
**New Features:**
|
||||
- **Langchain Integration:** Added support for Langchain VectorStores
|
||||
- **Examples:**
|
||||
- Added personal assistant example
|
||||
- Added personal study buddy example
|
||||
- Added YouTube assistant Chrome extension example
|
||||
- Added agno example
|
||||
- Updated OpenAI Responses API examples
|
||||
- **Vector Store:** Added capability to store user_id in vector database
|
||||
- **Async Memory:** Added async support for OSS
|
||||
|
||||
**Improvements:**
|
||||
- **Documentation:** Updated formatting and examples
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-09" description="v0.1.87">
|
||||
|
||||
**New Features:**
|
||||
- **Upstash Vector:** Added support for Upstash Vector store
|
||||
|
||||
**Improvements:**
|
||||
- **Code Quality:** Removed redundant code lines
|
||||
- **Build:** Updated MAKEFILE
|
||||
- **Documentation:** Updated memory export documentation
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-07" description="v0.1.86">
|
||||
|
||||
**Improvements:**
|
||||
- **FAISS:** Added embedding_dims parameter to FAISS vector store
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-07" description="v0.1.84">
|
||||
|
||||
**New Features:**
|
||||
- **Langchain Embedder:** Added Langchain embedder integration
|
||||
|
||||
**Improvements:**
|
||||
- **Langchain LLM:** Updated Langchain LLM integration to directly pass the Langchain object LLM
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-07" description="v0.1.83">
|
||||
|
||||
**Bug Fixes:**
|
||||
- **Langchain LLM:** Fixed issues with Langchain LLM integration
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-07" description="v0.1.82">
|
||||
|
||||
**New Features:**
|
||||
- **LLM Integrations:** Added support for Langchain LLMs, Google as new LLM and embedder
|
||||
- **Development:** Added development docker compose
|
||||
|
||||
**Improvements:**
|
||||
- **Output Format:** Set output_format='v1.1' and updated documentation
|
||||
|
||||
**Documentation:**
|
||||
- **Integrations:** Added LMStudio and Together.ai documentation
|
||||
- **API Reference:** Updated output_format documentation
|
||||
- **Integrations:** Added PipeCat integration documentation
|
||||
- **Integrations:** Added Flowise integration documentation for Mem0 memory setup
|
||||
|
||||
**Bug Fixes:**
|
||||
- **Tests:** Fixed failing unit tests
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-02" description="v0.1.79">
|
||||
|
||||
**New Features:**
|
||||
- **FAISS Support:** Added FAISS vector store support
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-02" description="v0.1.78">
|
||||
|
||||
**New Features:**
|
||||
- **Livekit Integration:** Added Mem0 livekit example
|
||||
- **Evaluation:** Added evaluation framework and tools
|
||||
|
||||
**Documentation:**
|
||||
- **Multimodal:** Updated multimodal documentation
|
||||
- **Examples:** Added examples for email processing
|
||||
- **API Reference:** Updated API reference section
|
||||
- **Elevenlabs:** Added Elevenlabs integration example
|
||||
|
||||
**Bug Fixes:**
|
||||
- **OpenAI Environment Variables:** Fixed issues with OpenAI environment variables
|
||||
- **Deployment Errors:** Added `package.json` file to fix deployment errors
|
||||
- **Tools:** Fixed tools issues and improved formatting
|
||||
- **Docs:** Updated API reference section for `expiration date`
|
||||
</Update>
|
||||
|
||||
<Update label="2025-03-26" description="v0.1.77">
|
||||
|
||||
**Bug Fixes:**
|
||||
- **OpenAI Environment Variables:** Fixed issues with OpenAI environment variables
|
||||
- **Deployment Errors:** Added `package.json` file to fix deployment errors
|
||||
- **Tools:** Fixed tools issues and improved formatting
|
||||
- **Docs:** Updated API reference section for `expiration date`
|
||||
</Update>
|
||||
|
||||
<Update label="2025-03-19" description="v0.1.76">
|
||||
**New Features:**
|
||||
- **Supabase Vector Store:** Added support for Supabase Vector Store
|
||||
- **Supabase History DB:** Added Supabase History DB to run Mem0 OSS on Serverless
|
||||
- **Feedback Method:** Added feedback method to client
|
||||
|
||||
**Bug Fixes:**
|
||||
- **Azure OpenAI:** Fixed issues with Azure OpenAI
|
||||
- **Azure AI Search:** Fixed test cases for Azure AI Search
|
||||
</Update>
|
||||
|
||||
</Tab>
|
||||
|
||||
<Tab title="TypeScript">
|
||||
|
||||
<Update label="2025-05-08" description="v2.1.25">
|
||||
**Improvements:**
|
||||
- **Client:** Improved error handling in client.
|
||||
</Update>
|
||||
|
||||
<Update label="2025-05-06" description="v2.1.24">
|
||||
**New Features:**
|
||||
- **Client:** Added new param `output_format` to match Python SDK.
|
||||
- **Client:** Added new enum `OutputFormat` for `v1.0` and `v1.1`
|
||||
</Update>
|
||||
|
||||
<Update label="2025-05-05" description="v2.1.23">
|
||||
**New Features:**
|
||||
- **Client:** Updated `deleteUsers` to use `v2` API.
|
||||
- **Client:** Deprecated `deleteUser` and added deprecation warning.
|
||||
</Update>
|
||||
|
||||
<Update label="2025-05-02" description="v2.1.22">
|
||||
**New Features:**
|
||||
- **Client:** Updated `deleteUser` to use `entity_id` and `entity_type`
|
||||
</Update>
|
||||
|
||||
<Update label="2025-05-01" description="v2.1.21">
|
||||
**Improvements:**
|
||||
- **OSS SDK:** Bumped version of `@anthropic-ai/sdk` to `0.40.1`
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-28" description="v2.1.20">
|
||||
**Improvements:**
|
||||
- **Client:** Fixed `organizationId` and `projectId` being asssigned to default in `ping` method
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-22" description="v2.1.19">
|
||||
**Improvements:**
|
||||
- **Client:** Added support for `timestamps`
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-17" description="v2.1.18">
|
||||
**Improvements:**
|
||||
- **Client:** Added support for custom instructions
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-15" description="v2.1.17">
|
||||
**New Features:**
|
||||
- **OSS SDK:** Added support for Langchain LLM
|
||||
- **OSS SDK:** Added support for Langchain Embedder
|
||||
- **OSS SDK:** Added support for Langchain Vector Store
|
||||
- **OSS SDK:** Added support for Azure OpenAI Embedder
|
||||
|
||||
|
||||
**Improvements:**
|
||||
- **OSS SDK:** Changed `model` in LLM and Embedder to use type any from `string` to use langchain llm models
|
||||
- **OSS SDK:** Added client to vector store config for langchain vector store
|
||||
- **OSS SDK:** - Updated Azure OpenAI to use new OpenAI SDK
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-11" description="v2.1.16-patch.1">
|
||||
**Bug Fixes:**
|
||||
- **Azure OpenAI:** Fixed issues with Azure OpenAI
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-11" description="v2.1.16">
|
||||
**New Features:**
|
||||
- **Azure OpenAI:** Added support for Azure OpenAI
|
||||
- **Mistral LLM:** Added Mistral LLM integration in OSS
|
||||
|
||||
**Improvements:**
|
||||
- **Zod:** Updated Zod to 3.24.1 to avoid conflicts with other packages
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-09" description="v2.1.15">
|
||||
**Improvements:**
|
||||
- **Client:** Added support for Mem0 to work with Chrome Extensions
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-01" description="v2.1.14">
|
||||
**New Features:**
|
||||
- **Mastra Example:** Added Mastra example
|
||||
- **Integrations:** Added Flowise integration documentation for Mem0 memory setup
|
||||
|
||||
**Improvements:**
|
||||
- **Demo:** Updated Demo Mem0AI
|
||||
- **Client:** Enhanced Ping method in Mem0 Client
|
||||
- **AI SDK:** Updated AI SDK implementation
|
||||
</Update>
|
||||
|
||||
<Update label="2025-03-29" description="v2.1.13">
|
||||
**Improvements:**
|
||||
- **Introuced `ping` method to check if API key is valid and populate org/project id**
|
||||
</Update>
|
||||
|
||||
<Update label="2025-03-29" description="AI SDK v1.0.0">
|
||||
**New Features:**
|
||||
- **Vercel AI SDK Update:** Support threshold and rerank
|
||||
|
||||
**Improvements:**
|
||||
- **Made add calls async to avoid blocking**
|
||||
- **Bump `mem0ai` to use `2.1.12`**
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-03-26" description="v2.1.12">
|
||||
**New Features:**
|
||||
- **Mem0 OSS:** Support infer param
|
||||
|
||||
**Improvements:**
|
||||
- **Updated Supabase TS Docs**
|
||||
- **Made package size smaller**
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-03-19" description="v2.1.11">
|
||||
**New Features:**
|
||||
- **Supabase Vector Store Integration**
|
||||
- **Feedback Method**
|
||||
</Update>
|
||||
|
||||
</Tab>
|
||||
|
||||
<Tab title="Platform">
|
||||
|
||||
<Update label="2025-04-26" description="">
|
||||
|
||||
**Improvements:**
|
||||
- **Performance:** Parallelized embedding calls
|
||||
- **Monitoring:** Added timing for LLM calls
|
||||
- **Search:** Added category checking in Search V2
|
||||
- **Bug Fixes:** Fixed issues with ADD filters
|
||||
- **Graph:** Implemented new graph updates
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-25" description="">
|
||||
|
||||
**Improvements:**
|
||||
- **Memory:** Fixed memory export functionality
|
||||
- **Analytics:** Added logging for project
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-24" description="">
|
||||
|
||||
**Improvements:**
|
||||
- **Output:** Added memory_type display for ADD output
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-23" description="">
|
||||
|
||||
**New Features:**
|
||||
- **UI:** Added new Pricing Component
|
||||
- **Memory:** Implemented Long/Short term memory categorization
|
||||
- **Output:** Modified serializer to hide memory_type
|
||||
|
||||
**Documentation:**
|
||||
- Updated README for deployment
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-22" description="">
|
||||
|
||||
**New Features:**
|
||||
- **Memory:** Added timestamp to ADD call
|
||||
|
||||
**Bug Fixes:**
|
||||
- Fixed issues with coreV2
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-21" description="">
|
||||
|
||||
**New Features:**
|
||||
- **Memory:** Implemented backdating with migrations and backfilling script
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-17" description="">
|
||||
|
||||
**New Features:**
|
||||
- **Billing:** Integrated Stripe Billing Dashboard
|
||||
- **Admin:** Added webhook creation functionality
|
||||
|
||||
**Bug Fixes:**
|
||||
- Fixed Users Page issues
|
||||
- Fixed Custom Categories
|
||||
- Fixed Table components
|
||||
- Updated Stripe configuration
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-16" description="">
|
||||
|
||||
**Improvements:**
|
||||
- **Performance:** Made Admin panel and Memory Page faster
|
||||
- **Security:** Implemented active session cancellation
|
||||
- **Analytics:** Added Stripe customer ID capture
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-12" description="">
|
||||
|
||||
**New Features:**
|
||||
- **Memory Management:**
|
||||
- Added ability to delete memories from Project level with filters
|
||||
- Added delete memories capability on Memories Page
|
||||
- **Memory Visualization:** Released V1 Graph Memory Visualization
|
||||
- **Graph Playground:** Enabled for @mem0.ai users
|
||||
- **Notifications:** Added email alerts to organization owners when new members join
|
||||
- **Memory Export:** Added date support for filtering memory exports
|
||||
|
||||
**Improvements:**
|
||||
- **Performance:**
|
||||
- Optimized graph for better performance
|
||||
- Optimized database calls in ADD method
|
||||
- **Analytics:** Added flagging of paid users in Posthog
|
||||
- **CI/CD:** Improved CI pipeline and fixed lint issues
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-10" description="">
|
||||
|
||||
**New Features:**
|
||||
- **Notifications:** Implemented email notifications for organization owners when new members join
|
||||
|
||||
**Improvements:**
|
||||
- **CI/CD:** Fixed Dockerfile for CI tests
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-09" description="">
|
||||
|
||||
**Improvements:**
|
||||
- **Integrations:** Updated chat model for Together Qwen
|
||||
- **Platform:** Removed older platforms
|
||||
- **Bug Fixes:** Fixed FILTER_MAPPING
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-03" description="">
|
||||
|
||||
**New Features:**
|
||||
- **Memory:** Added implicit memory capabilities
|
||||
- **API:** Improved implicit lambda and get_all v2 functionality
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-02" description="">
|
||||
|
||||
**New Features:**
|
||||
- **Integrations:** Added Clay integration
|
||||
|
||||
**Improvements:**
|
||||
- **Integrations:** Removed deepseek coder from Together
|
||||
- **API:** Added custom instructions for add v2
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-03-31" description="">
|
||||
|
||||
**Security:**
|
||||
- **Validation:** Added key validation in messages
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-03-28" description="">
|
||||
- **Updated Playground Prompt**
|
||||
- **Send Email on User Addition to Org/Proj**
|
||||
- **Fix Search Entity**
|
||||
</Update>
|
||||
|
||||
<Update label="2025-03-19" description="">
|
||||
- **General Stability & Performance Improvements**
|
||||
</Update>
|
||||
|
||||
</Tab>
|
||||
|
||||
<Tab title="Vercel AI SDK">
|
||||
|
||||
<Update label="2025-05-10" description="v1.0.4">
|
||||
**New Features:**
|
||||
- **Vercel AI SDK:** Added support for new param `output_format`.
|
||||
</Update>
|
||||
|
||||
<Update label="2025-05-08" description="v1.0.3">
|
||||
**Improvements:**
|
||||
- **Vercel AI SDK:** Added support for graceful failure in cases services are down.
|
||||
</Update>
|
||||
|
||||
<Update label="2025-05-01" description="v1.0.1">
|
||||
**New Features:**
|
||||
- **Vercel AI SDK:** Added support for graph memories
|
||||
</Update>
|
||||
|
||||
</Tab>
|
||||
|
||||
</Tabs>
|
||||
|
||||
@@ -1,207 +0,0 @@
|
||||
---
|
||||
title: "Product Updates"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
<Tabs>
|
||||
<Tab title="Python">
|
||||
|
||||
<Update label="2025-04-11" description="v0.1.89">
|
||||
|
||||
**New Features:**
|
||||
- **Langchain Integration:** Added support for Langchain VectorStores
|
||||
- **Examples:**
|
||||
- Added personal assistant example
|
||||
- Added personal study buddy example
|
||||
- Added YouTube assistant Chrome extension example
|
||||
- Added agno example
|
||||
- Updated OpenAI Responses API examples
|
||||
- **Vector Store:** Added capability to store user_id in vector database
|
||||
- **Async Memory:** Added async support for OSS
|
||||
|
||||
**Improvements:**
|
||||
- **Documentation:** Updated formatting and examples
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-09" description="v0.1.87">
|
||||
|
||||
**New Features:**
|
||||
- **Upstash Vector:** Added support for Upstash Vector store
|
||||
|
||||
**Improvements:**
|
||||
- **Code Quality:** Removed redundant code lines
|
||||
- **Build:** Updated MAKEFILE
|
||||
- **Documentation:** Updated memory export documentation
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-07" description="v0.1.86">
|
||||
|
||||
**Improvements:**
|
||||
- **FAISS:** Added embedding_dims parameter to FAISS vector store
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-07" description="v0.1.84">
|
||||
|
||||
**New Features:**
|
||||
- **Langchain Embedder:** Added Langchain embedder integration
|
||||
|
||||
**Improvements:**
|
||||
- **Langchain LLM:** Updated Langchain LLM integration to directly pass the Langchain object LLM
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-07" description="v0.1.83">
|
||||
|
||||
**Bug Fixes:**
|
||||
- **Langchain LLM:** Fixed issues with Langchain LLM integration
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-07" description="v0.1.82">
|
||||
|
||||
**New Features:**
|
||||
- **LLM Integrations:** Added support for Langchain LLMs, Google as new LLM and embedder
|
||||
- **Development:** Added development docker compose
|
||||
|
||||
**Improvements:**
|
||||
- **Output Format:** Set output_format='v1.1' and updated documentation
|
||||
|
||||
**Documentation:**
|
||||
- **Integrations:** Added LMStudio and Together.ai documentation
|
||||
- **API Reference:** Updated output_format documentation
|
||||
- **Integrations:** Added PipeCat integration documentation
|
||||
- **Integrations:** Added Flowise integration documentation for Mem0 memory setup
|
||||
|
||||
**Bug Fixes:**
|
||||
- **Tests:** Fixed failing unit tests
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-02" description="v0.1.79">
|
||||
|
||||
**New Features:**
|
||||
- **FAISS Support:** Added FAISS vector store support
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-02" description="v0.1.78">
|
||||
|
||||
**New Features:**
|
||||
- **Livekit Integration:** Added Mem0 livekit example
|
||||
- **Evaluation:** Added evaluation framework and tools
|
||||
|
||||
**Documentation:**
|
||||
- **Multimodal:** Updated multimodal documentation
|
||||
- **Examples:** Added examples for email processing
|
||||
- **API Reference:** Updated API reference section
|
||||
- **Elevenlabs:** Added Elevenlabs integration example
|
||||
|
||||
**Bug Fixes:**
|
||||
- **OpenAI Environment Variables:** Fixed issues with OpenAI environment variables
|
||||
- **Deployment Errors:** Added `package.json` file to fix deployment errors
|
||||
- **Tools:** Fixed tools issues and improved formatting
|
||||
- **Docs:** Updated API reference section for `expiration date`
|
||||
</Update>
|
||||
|
||||
<Update label="2025-03-26" description="v0.1.77">
|
||||
|
||||
**Bug Fixes:**
|
||||
- **OpenAI Environment Variables:** Fixed issues with OpenAI environment variables
|
||||
- **Deployment Errors:** Added `package.json` file to fix deployment errors
|
||||
- **Tools:** Fixed tools issues and improved formatting
|
||||
- **Docs:** Updated API reference section for `expiration date`
|
||||
</Update>
|
||||
|
||||
<Update label="2025-03-19" description="v0.1.76">
|
||||
**New Features:**
|
||||
- **Supabase Vector Store:** Added support for Supabase Vector Store
|
||||
- **Supabase History DB:** Added Supabase History DB to run Mem0 OSS on Serverless
|
||||
- **Feedback Method:** Added feedback method to client
|
||||
|
||||
**Bug Fixes:**
|
||||
- **Azure OpenAI:** Fixed issues with Azure OpenAI
|
||||
- **Azure AI Search:** Fixed test cases for Azure AI Search
|
||||
</Update>
|
||||
|
||||
</Tab>
|
||||
|
||||
<Tab title="TypeScript">
|
||||
|
||||
<Update label="2025-04-11" description="v2.1.16-patch.1">
|
||||
**Bug Fixes:**
|
||||
- **Azure OpenAI:** Fixed issues with Azure OpenAI
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-11" description="v2.1.16">
|
||||
**New Features:**
|
||||
- **Azure OpenAI:** Added support for Azure OpenAI
|
||||
- **Mistral LLM:** Added Mistral LLM integration in OSS
|
||||
|
||||
**Improvements:**
|
||||
- **Zod:** Updated Zod to 3.24.1 to avoid conflicts with other packages
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-09" description="v2.1.15">
|
||||
**Improvements:**
|
||||
- **Client:** Added support for Mem0 to work with Chrome Extensions
|
||||
</Update>
|
||||
|
||||
<Update label="2025-04-01" description="v2.1.14">
|
||||
**New Features:**
|
||||
- **Mastra Example:** Added Mastra example
|
||||
- **Integrations:** Added Flowise integration documentation for Mem0 memory setup
|
||||
|
||||
**Improvements:**
|
||||
- **Demo:** Updated Demo Mem0AI
|
||||
- **Client:** Enhanced Ping method in Mem0 Client
|
||||
- **AI SDK:** Updated AI SDK implementation
|
||||
</Update>
|
||||
|
||||
<Update label="2025-03-29" description="v2.1.13">
|
||||
**Improvements:**
|
||||
- **Introuced `ping` method to check if API key is valid and populate org/project id**
|
||||
</Update>
|
||||
|
||||
<Update label="2025-03-29" description="AI SDK v1.0.0">
|
||||
**New Features:**
|
||||
- **Vercel AI SDK Update:** Support threshold and rerank
|
||||
|
||||
**Improvements:**
|
||||
- **Made add calls async to avoid blocking**
|
||||
- **Bump `mem0ai` to use `2.1.12`**
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-03-26" description="v2.1.12">
|
||||
**New Features:**
|
||||
- **Mem0 OSS:** Support infer param
|
||||
|
||||
**Improvements:**
|
||||
- **Updated Supabase TS Docs**
|
||||
- **Made package size smaller**
|
||||
|
||||
</Update>
|
||||
|
||||
<Update label="2025-03-19" description="v2.1.11">
|
||||
**New Features:**
|
||||
- **Supabase Vector Store Integration**
|
||||
- **Feedback Method**
|
||||
</Update>
|
||||
|
||||
</Tab>
|
||||
|
||||
<Tab title="Platform">
|
||||
|
||||
<Update label="2025-03-28" description="">
|
||||
- **Updated Playground Prompt**
|
||||
- **Send Email on User Addition to Org/Proj**
|
||||
- **Fix Search Entity**
|
||||
</Update>
|
||||
|
||||
<Update label="2025-03-19" description="">
|
||||
- **General Stability & Performance Improvements**
|
||||
</Update>
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
@@ -4,6 +4,8 @@ icon: "gear"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Config in mem0 is a dictionary that specifies the settings for your embedding models. It allows you to customize the behavior and connection details of your chosen embedder.
|
||||
|
||||
## How to define configurations?
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
---
|
||||
title: AWS Bedrock
|
||||
---
|
||||
|
||||
To use AWS Bedrock embedding models, you need to have the appropriate AWS credentials and permissions. The embeddings implementation relies on the `boto3` library.
|
||||
|
||||
### Setup
|
||||
- Ensure you have model access from the [AWS Bedrock Console](https://us-east-1.console.aws.amazon.com/bedrock/home?region=us-east-1#/modelaccess)
|
||||
- Authenticate the boto3 client using a method described in the [AWS documentation](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html)
|
||||
- Set up environment variables for authentication:
|
||||
```bash
|
||||
export AWS_REGION=us-east-1
|
||||
export AWS_ACCESS_KEY_ID=your-access-key
|
||||
export AWS_SECRET_ACCESS_KEY=your-secret-key
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
import os
|
||||
from mem0 import Memory
|
||||
|
||||
# For LLM if needed
|
||||
os.environ["OPENAI_API_KEY"] = "your-openai-api-key"
|
||||
|
||||
# AWS credentials
|
||||
os.environ["AWS_REGION"] = "us-west-2"
|
||||
os.environ["AWS_ACCESS_KEY_ID"] = "your-access-key"
|
||||
os.environ["AWS_SECRET_ACCESS_KEY"] = "your-secret-key"
|
||||
|
||||
config = {
|
||||
"embedder": {
|
||||
"provider": "aws_bedrock",
|
||||
"config": {
|
||||
"model": "amazon.titan-embed-text-v2:0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m = Memory.from_config(config)
|
||||
messages = [
|
||||
{"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
|
||||
{"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."},
|
||||
{"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."},
|
||||
{"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."}
|
||||
]
|
||||
m.add(messages, user_id="alice")
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Config
|
||||
|
||||
Here are the parameters available for configuring AWS Bedrock embedder:
|
||||
|
||||
<Tabs>
|
||||
<Tab title="Python">
|
||||
| Parameter | Description | Default Value |
|
||||
| --- | --- | --- |
|
||||
| `model` | The name of the embedding model to use | `amazon.titan-embed-text-v1` |
|
||||
</Tab>
|
||||
</Tabs>
|
||||
@@ -6,7 +6,8 @@ To use Azure OpenAI embedding models, set the `EMBEDDING_AZURE_OPENAI_API_KEY`,
|
||||
|
||||
### Usage
|
||||
|
||||
```python
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
import os
|
||||
from mem0 import Memory
|
||||
|
||||
@@ -46,6 +47,36 @@ messages = [
|
||||
m.add(messages, user_id="john")
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
import { Memory } from 'mem0ai/oss';
|
||||
|
||||
const config = {
|
||||
embedder: {
|
||||
provider: "azure_openai",
|
||||
config: {
|
||||
model: "text-embedding-3-large",
|
||||
modelProperties: {
|
||||
endpoint: "your-api-base-url",
|
||||
deployment: "your-deployment-name",
|
||||
apiVersion: "version-to-use",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const memory = new Memory(config);
|
||||
|
||||
const messages = [
|
||||
{"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
|
||||
{"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."},
|
||||
{"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."},
|
||||
{"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."}
|
||||
]
|
||||
|
||||
await memory.add(messages, { userId: "john" });
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Config
|
||||
|
||||
Here are the parameters available for configuring Azure OpenAI embedder:
|
||||
|
||||
@@ -25,12 +25,44 @@ m = Memory.from_config(config)
|
||||
messages = [
|
||||
{"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
|
||||
{"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."},
|
||||
{"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."},
|
||||
{"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."},
|
||||
{"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."}
|
||||
]
|
||||
m.add(messages, user_id="john")
|
||||
```
|
||||
|
||||
### Using Text Embeddings Inference (TEI)
|
||||
|
||||
You can also use Hugging Face's Text Embeddings Inference service for faster and more efficient embeddings:
|
||||
|
||||
```python
|
||||
import os
|
||||
from mem0 import Memory
|
||||
|
||||
os.environ["OPENAI_API_KEY"] = "your_api_key" # For LLM
|
||||
|
||||
# Using HuggingFace Text Embeddings Inference API
|
||||
config = {
|
||||
"embedder": {
|
||||
"provider": "huggingface",
|
||||
"config": {
|
||||
"huggingface_base_url": "http://localhost:3000/v1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m = Memory.from_config(config)
|
||||
m.add("This text will be embedded using the TEI service.", user_id="john")
|
||||
```
|
||||
|
||||
To run the TEI service, you can use Docker:
|
||||
|
||||
```bash
|
||||
docker run -d -p 3000:80 -v huggingfacetei:/data --platform linux/amd64 \
|
||||
ghcr.io/huggingface/text-embeddings-inference:cpu-1.6 \
|
||||
--model-id BAAI/bge-small-en-v1.5
|
||||
```
|
||||
|
||||
### Config
|
||||
|
||||
Here are the parameters available for configuring Huggingface embedder:
|
||||
@@ -39,4 +71,5 @@ Here are the parameters available for configuring Huggingface embedder:
|
||||
| --- | --- | --- |
|
||||
| `model` | The name of the model to use | `multi-qa-MiniLM-L6-cos-v1` |
|
||||
| `embedding_dims` | Dimensions of the embedding model | `selected_model_dimensions` |
|
||||
| `model_kwargs` | Additional arguments for the model | `None` |
|
||||
| `model_kwargs` | Additional arguments for the model | `None` |
|
||||
| `huggingface_base_url` | URL to connect to Text Embeddings Inference (TEI) API | `None` |
|
||||
@@ -42,6 +42,32 @@ messages = [
|
||||
]
|
||||
m.add(messages, user_id="alice", metadata={"category": "movies"})
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
import { Memory } from "mem0ai";
|
||||
import { OpenAIEmbeddings } from "@langchain/openai";
|
||||
|
||||
const embeddings = new OpenAIEmbeddings();
|
||||
const config = {
|
||||
"embedder": {
|
||||
"provider": "langchain",
|
||||
"config": {
|
||||
"model": embeddings
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const memory = new Memory(config);
|
||||
|
||||
const messages = [
|
||||
{ role: "user", content: "I'm planning to watch a movie tonight. Any recommendations?" },
|
||||
{ role: "assistant", content: "How about a thriller movies? They can be quite engaging." },
|
||||
{ role: "user", content: "I'm not a big fan of thriller movies but I love sci-fi movies." },
|
||||
{ role: "assistant", content: "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future." }
|
||||
]
|
||||
|
||||
memory.add(messages, user_id="alice", metadata={"category": "movies"})
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Supported LangChain Embedding Providers
|
||||
|
||||
@@ -4,6 +4,8 @@ icon: "info"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Mem0 offers support for various embedding models, allowing users to choose the one that best suits their needs.
|
||||
|
||||
## Supported Embedders
|
||||
@@ -24,6 +26,7 @@ See the list of supported embedders below.
|
||||
<Card title="Together" href="/components/embedders/models/together"></Card>
|
||||
<Card title="LM Studio" href="/components/embedders/models/lmstudio"></Card>
|
||||
<Card title="Langchain" href="/components/embedders/models/langchain"></Card>
|
||||
<Card title="AWS Bedrock" href="/components/embedders/models/aws_bedrock"></Card>
|
||||
</CardGroup>
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -4,6 +4,8 @@ icon: "gear"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
## How to define configurations?
|
||||
|
||||
<Tabs>
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Anthropic
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
To use anthropic's models, please set the `ANTHROPIC_API_KEY` which you find on their [Account Settings Page](https://console.anthropic.com/account/keys).
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: AWS Bedrock
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
### Setup
|
||||
- Before using the AWS Bedrock LLM, make sure you have the appropriate model access from [Bedrock Console](https://us-east-1.console.aws.amazon.com/bedrock/home?region=us-east-1#/modelaccess).
|
||||
- You will also need to authenticate the `boto3` client by using a method in the [AWS documentation](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html#configuring-credentials)
|
||||
@@ -13,16 +15,15 @@ title: AWS Bedrock
|
||||
import os
|
||||
from mem0 import Memory
|
||||
|
||||
os.environ["OPENAI_API_KEY"] = "your-api-key" # used for embedding model
|
||||
os.environ['AWS_REGION'] = 'us-east-1'
|
||||
os.environ["AWS_ACCESS_KEY"] = "xx"
|
||||
os.environ['AWS_REGION'] = 'us-west-2'
|
||||
os.environ["AWS_ACCESS_KEY_ID"] = "xx"
|
||||
os.environ["AWS_SECRET_ACCESS_KEY"] = "xx"
|
||||
|
||||
config = {
|
||||
"llm": {
|
||||
"provider": "aws_bedrock",
|
||||
"config": {
|
||||
"model": "arn:aws:bedrock:us-east-1:123456789012:model/your-model-name",
|
||||
"model": "anthropic.claude-3-5-haiku-20241022-v1:0",
|
||||
"temperature": 0.2,
|
||||
"max_tokens": 2000,
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Azure OpenAI
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
<Note> Mem0 Now Supports Azure OpenAI Models in TypeScript SDK </Note>
|
||||
|
||||
To use Azure OpenAI models, you have to set the `LLM_AZURE_OPENAI_API_KEY`, `LLM_AZURE_ENDPOINT`, `LLM_AZURE_DEPLOYMENT` and `LLM_AZURE_API_VERSION` environment variables. You can obtain the Azure API key from the [Azure](https://azure.microsoft.com/).
|
||||
@@ -16,6 +18,8 @@ To use Azure OpenAI models, you have to set the `LLM_AZURE_OPENAI_API_KEY`, `LLM
|
||||
import os
|
||||
from mem0 import Memory
|
||||
|
||||
os.environ["OPENAI_API_KEY"] = "your-api-key" # used for embedding model
|
||||
|
||||
os.environ["LLM_AZURE_OPENAI_API_KEY"] = "your-api-key"
|
||||
os.environ["LLM_AZURE_DEPLOYMENT"] = "your-deployment-name"
|
||||
os.environ["LLM_AZURE_ENDPOINT"] = "your-api-base-url"
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: DeepSeek
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
To use DeepSeek LLM models, you have to set the `DEEPSEEK_API_KEY` environment variable. You can also optionally set `DEEPSEEK_API_BASE` if you need to use a different API endpoint (defaults to "https://api.deepseek.com").
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Gemini
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
To use Gemini model, you have to set the `GEMINI_API_KEY` environment variable. You can obtain the Gemini API key from the [Google AI Studio](https://aistudio.google.com/app/apikey)
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Google AI
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
To use Google AI model, you have to set the `GOOGLE_API_KEY` environment variable. You can obtain the Google API key from the [Google Maker Suite](https://makersuite.google.com/app/apikey)
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Groq
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
[Groq](https://groq.com/) is the creator of the world's first Language Processing Unit (LPU), providing exceptional speed performance for AI workloads running on their LPU Inference Engine.
|
||||
|
||||
In order to use LLMs from Groq, go to their [platform](https://console.groq.com/keys) and get the API key. Set the API key as `GROQ_API_KEY` environment variable to use the model as given below in the example.
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: LangChain
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Mem0 supports LangChain as a provider to access a wide range of LLM models. LangChain is a framework for developing applications powered by language models, making it easy to integrate various LLM providers through a consistent interface.
|
||||
|
||||
For a complete list of available chat models supported by LangChain, refer to the [LangChain Chat Models documentation](https://python.langchain.com/docs/integrations/chat).
|
||||
@@ -43,6 +45,37 @@ messages = [
|
||||
]
|
||||
m.add(messages, user_id="alice", metadata={"category": "movies"})
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
import { Memory } from "mem0ai";
|
||||
import { ChatOpenAI } from "@langchain/openai";
|
||||
|
||||
const openai_model = new ChatOpenAI({
|
||||
model: "gpt-4o",
|
||||
temperature: 0.2,
|
||||
max_tokens: 2000
|
||||
})
|
||||
|
||||
const config = {
|
||||
"llm": {
|
||||
"provider": "langchain",
|
||||
"config": {
|
||||
"model": openai_model
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const memory = new Memory(config);
|
||||
|
||||
const messages = [
|
||||
{ role: "user", content: "I'm planning to watch a movie tonight. Any recommendations?" },
|
||||
{ role: "assistant", content: "How about a thriller movies? They can be quite engaging." },
|
||||
{ role: "user", content: "I'm not a big fan of thriller movies but I love sci-fi movies." },
|
||||
{ role: "assistant", content: "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future." }
|
||||
]
|
||||
|
||||
memory.add(messages, user_id="alice", metadata={"category": "movies"})
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Supported LangChain Providers
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
[Litellm](https://litellm.vercel.app/docs/) is compatible with over 100 large language models (LLMs), all using a standardized input/output format. You can explore the [available models](https://litellm.vercel.app/docs/providers) to use with Litellm. Ensure you set the `API_KEY` for the model you choose to use.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: LM Studio
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
To use LM Studio with Mem0, you'll need to have LM Studio running locally with its server enabled. LM Studio provides a way to run local LLMs with an OpenAI-compatible API.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Mistral AI
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
To use mistral's models, please obtain the Mistral AI api key from their [console](https://console.mistral.ai/). Set the `MISTRAL_API_KEY` environment variable to use the model as given below in the example.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
You can use LLMs from Ollama to run Mem0 locally. These [models](https://ollama.com/search?c=tools) support tool support.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: OpenAI
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
To use OpenAI LLM models, you have to set the `OPENAI_API_KEY` environment variable. You can obtain the OpenAI API key from the [OpenAI Platform](https://platform.openai.com/account/api-keys).
|
||||
|
||||
## Usage
|
||||
@@ -92,10 +94,6 @@ config = {
|
||||
m = Memory.from_config(config)
|
||||
```
|
||||
|
||||
<Note>
|
||||
OpenAI structured-outputs is currently only available in the Python implementation.
|
||||
</Note>
|
||||
|
||||
## Config
|
||||
|
||||
All available parameters for the `openai` config are present in [Master List of All Params in Config](../config).
|
||||
All available parameters for the `openai` config are present in [Master List of All Params in Config](../config).
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
To use TogetherAI LLM models, you have to set the `TOGETHER_API_KEY` environment variable. You can obtain the TogetherAI API key from their [Account settings page](https://api.together.xyz/settings/api-keys).
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: xAI
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
[xAI](https://x.ai/) is a new AI company founded by Elon Musk that develops large language models, including Grok. Grok is trained on real-time data from X (formerly Twitter) and aims to provide accurate, up-to-date responses with a touch of wit and humor.
|
||||
|
||||
In order to use LLMs from xAI, go to their [platform](https://console.x.ai) and get the API key. Set the API key as `XAI_API_KEY` environment variable to use the model as given below in the example.
|
||||
|
||||
@@ -4,6 +4,8 @@ icon: "info"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Mem0 includes built-in support for various popular large language models. Memory can utilize the LLM provided by the user, ensuring efficient use for specific needs.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -4,6 +4,8 @@ icon: "gear"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
## How to define configurations?
|
||||
|
||||
The `config` is defined as an object with two main keys:
|
||||
|
||||
@@ -44,6 +44,33 @@ messages = [
|
||||
]
|
||||
m.add(messages, user_id="alice", metadata={"category": "movies"})
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
import { Memory } from "mem0ai";
|
||||
import { OpenAIEmbeddings } from "@langchain/openai";
|
||||
import { MemoryVectorStore as LangchainMemoryStore } from "langchain/vectorstores/memory";
|
||||
|
||||
const embeddings = new OpenAIEmbeddings();
|
||||
const vectorStore = new LangchainVectorStore(embeddings);
|
||||
|
||||
const config = {
|
||||
"vector_store": {
|
||||
"provider": "langchain",
|
||||
"config": { "client": vectorStore }
|
||||
}
|
||||
}
|
||||
|
||||
const memory = new Memory(config);
|
||||
|
||||
const messages = [
|
||||
{ role: "user", content: "I'm planning to watch a movie tonight. Any recommendations?" },
|
||||
{ role: "assistant", content: "How about a thriller movies? They can be quite engaging." },
|
||||
{ role: "user", content: "I'm not a big fan of thriller movies but I love sci-fi movies." },
|
||||
{ role: "assistant", content: "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future." }
|
||||
]
|
||||
|
||||
memory.add(messages, user_id="alice", metadata={"category": "movies"})
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Supported LangChain Vector Stores
|
||||
|
||||
@@ -1,59 +1,75 @@
|
||||
[OpenSearch](https://opensearch.org/) is an open-source, enterprise-grade search and observability suite that brings order to unstructured data at scale. OpenSearch supports k-NN (k-Nearest Neighbors) and allows you to store and retrieve high-dimensional vector embeddings efficiently.
|
||||
[OpenSearch](https://opensearch.org/) is an enterprise-grade search and observability suite that brings order to unstructured data at scale. OpenSearch supports k-NN (k-Nearest Neighbors) and allows you to store and retrieve high-dimensional vector embeddings efficiently.
|
||||
|
||||
### Installation
|
||||
|
||||
OpenSearch support requires additional dependencies. Install them with:
|
||||
|
||||
```bash
|
||||
pip install opensearch>=2.8.0
|
||||
pip install opensearch-py
|
||||
```
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Before using OpenSearch with Mem0, you need to set up a collection in AWS OpenSearch Service.
|
||||
|
||||
#### AWS OpenSearch Service
|
||||
You can create a collection through the AWS Console:
|
||||
- Navigate to [OpenSearch Service Console](https://console.aws.amazon.com/aos/home)
|
||||
- Click "Create collection"
|
||||
- Select "Serverless collection" and then enable "Vector search" capabilities
|
||||
- Once created, note the endpoint URL (host) for your configuration
|
||||
|
||||
|
||||
### Usage
|
||||
|
||||
```python
|
||||
import os
|
||||
from mem0 import Memory
|
||||
import boto3
|
||||
from opensearchpy import OpenSearch, RequestsHttpConnection, AWSV4SignerAuth
|
||||
|
||||
os.environ["OPENAI_API_KEY"] = "sk-xx"
|
||||
# For AWS OpenSearch Service with IAM authentication
|
||||
region = 'us-west-2'
|
||||
service = 'aoss'
|
||||
credentials = boto3.Session().get_credentials()
|
||||
auth = AWSV4SignerAuth(credentials, region, service)
|
||||
|
||||
config = {
|
||||
"vector_store": {
|
||||
"provider": "opensearch",
|
||||
"config": {
|
||||
"collection_name": "mem0",
|
||||
"host": "localhost",
|
||||
"port": 9200,
|
||||
"embedding_model_dims": 1536
|
||||
"host": "your-domain.us-west-2.aoss.amazonaws.com",
|
||||
"port": 443,
|
||||
"http_auth": auth,
|
||||
"embedding_model_dims": 1024,
|
||||
"connection_class": RequestsHttpConnection,
|
||||
"pool_maxsize": 20,
|
||||
"use_ssl": True,
|
||||
"verify_certs": True
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Add Memories
|
||||
|
||||
```python
|
||||
m = Memory.from_config(config)
|
||||
messages = [
|
||||
{"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
|
||||
{"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."},
|
||||
{"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."},
|
||||
{"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."},
|
||||
{"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."}
|
||||
]
|
||||
m.add(messages, user_id="alice", metadata={"category": "movies"})
|
||||
```
|
||||
|
||||
### Config
|
||||
### Search Memories
|
||||
|
||||
Let's see the available parameters for the `opensearch` config:
|
||||
|
||||
| Parameter | Description | Default Value |
|
||||
| ---------------------- | -------------------------------------------------- | ------------- |
|
||||
| `collection_name` | The name of the index to store the vectors | `mem0` |
|
||||
| `embedding_model_dims` | Dimensions of the embedding model | `1536` |
|
||||
| `host` | The host where the OpenSearch server is running | `localhost` |
|
||||
| `port` | The port where the OpenSearch server is running | `9200` |
|
||||
| `api_key` | API key for authentication | `None` |
|
||||
| `user` | Username for basic authentication | `None` |
|
||||
| `password` | Password for basic authentication | `None` |
|
||||
| `verify_certs` | Whether to verify SSL certificates | `False` |
|
||||
| `auto_create_index` | Whether to automatically create the index | `True` |
|
||||
| `use_ssl` | Whether to use SSL for connection | `False` |
|
||||
```python
|
||||
results = m.search("What kind of movies does Alice like?", user_id="alice")
|
||||
```
|
||||
|
||||
### Features
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ icon: "info"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Mem0 includes built-in support for various popular databases. Memory can utilize the database provided by the user, ensuring efficient use for specific needs.
|
||||
|
||||
## Supported Vector Databases
|
||||
|
||||
@@ -3,6 +3,8 @@ title: Development
|
||||
icon: "code"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
# Development Contributions
|
||||
|
||||
We strive to make contributions **easy, collaborative, and enjoyable**. Follow the steps below to ensure a smooth contribution process.
|
||||
|
||||
@@ -3,6 +3,8 @@ title: Documentation
|
||||
icon: "book"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
# Documentation Contributions
|
||||
|
||||
## 📌 Prerequisites
|
||||
|
||||
@@ -5,6 +5,8 @@ icon: "gear"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Mem0 provides two core operations for managing memories in AI applications: adding new memories and searching existing ones. This guide covers how these operations work and how to use them effectively in your application.
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@ description: Understanding different types of memory in AI Applications
|
||||
icon: "memory"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
To build useful AI applications, we need to understand how different memory systems work together. This guide explores the fundamental types of memory in AI systems and shows how Mem0 implements these concepts.
|
||||
|
||||
## Why Memory Matters
|
||||
|
||||
+22
-7
@@ -49,6 +49,7 @@
|
||||
"features/advanced-retrieval",
|
||||
"features/contextual-add",
|
||||
"features/multimodal-support",
|
||||
"features/timestamp",
|
||||
"features/selective-memory",
|
||||
"features/custom-categories",
|
||||
"features/custom-instructions",
|
||||
@@ -57,7 +58,8 @@
|
||||
"features/memory-export",
|
||||
"features/webhooks",
|
||||
"features/graph-memory",
|
||||
"features/feedback-mechanism"
|
||||
"features/feedback-mechanism",
|
||||
"features/expiration-date"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -164,7 +166,8 @@
|
||||
"components/embedders/models/gemini",
|
||||
"components/embedders/models/lmstudio",
|
||||
"components/embedders/models/together",
|
||||
"components/embedders/models/langchain"
|
||||
"components/embedders/models/langchain",
|
||||
"components/embedders/models/aws_bedrock"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -181,6 +184,14 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tab": "OpenMemory",
|
||||
"icon": "square-terminal",
|
||||
"pages": [
|
||||
"openmemory/overview",
|
||||
"openmemory/quickstart"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tab": "Examples",
|
||||
"groups": [
|
||||
@@ -188,9 +199,12 @@
|
||||
"group": "💡 Examples",
|
||||
"icon": "lightbulb",
|
||||
"pages": [
|
||||
"examples/overview",
|
||||
"examples",
|
||||
"examples/aws_example",
|
||||
"examples/mem0-demo",
|
||||
"examples/ai_companion_js",
|
||||
"examples/collaborative-task-agent",
|
||||
"examples/eliza_os",
|
||||
"examples/mem0-mastra",
|
||||
"examples/mem0-with-ollama",
|
||||
"examples/personal-ai-tutor",
|
||||
@@ -217,7 +231,7 @@
|
||||
"group": "Integrations",
|
||||
"icon": "plug",
|
||||
"pages": [
|
||||
"integrations/overview",
|
||||
"integrations",
|
||||
"integrations/vercel-ai-sdk",
|
||||
"integrations/flowise",
|
||||
"integrations/crewai",
|
||||
@@ -231,7 +245,8 @@
|
||||
"integrations/livekit",
|
||||
"integrations/elevenlabs",
|
||||
"integrations/pipecat",
|
||||
"integrations/agno"
|
||||
"integrations/agno",
|
||||
"integrations/keywords"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -244,7 +259,7 @@
|
||||
"group": "API Reference",
|
||||
"icon": "terminal",
|
||||
"pages": [
|
||||
"api-reference/overview",
|
||||
"api-reference",
|
||||
{
|
||||
"group": "Memory APIs",
|
||||
"icon": "microchip",
|
||||
@@ -320,7 +335,7 @@
|
||||
"group": "Product Updates",
|
||||
"icon": "rocket",
|
||||
"pages": [
|
||||
"changelog/overview"
|
||||
"changelog"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -3,6 +3,8 @@ title: Overview
|
||||
description: How to use mem0 in your existing applications?
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
|
||||
With Mem0, you can create stateful LLM-based applications such as chatbots, virtual assistants, or AI agents. Mem0 enhances your applications by providing a memory layer that makes responses:
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: AI Companion
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
You can create a personalised AI Companion using Mem0. This guide will walk you through the necessary steps and provide the complete code to get you started.
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: AI Companion in Node.js
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
You can create a personalised AI Companion using Mem0. This guide will walk you through the necessary steps and provide the complete code to get you started.
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
---
|
||||
title: AWS Bedrock and AOSS
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
This example demonstrates how to configure and use the `mem0ai` SDK with **AWS Bedrock** and **OpenSearch Service (AOSS)** for persistent memory capabilities in Python.
|
||||
|
||||
## Installation
|
||||
|
||||
Install the required dependencies:
|
||||
|
||||
```bash
|
||||
pip install mem0ai boto3 opensearch-py
|
||||
```
|
||||
|
||||
## Environment Setup
|
||||
|
||||
Set your AWS environment variables:
|
||||
|
||||
```python
|
||||
import os
|
||||
|
||||
# Set these in your environment or notebook
|
||||
os.environ['AWS_REGION'] = 'us-west-2'
|
||||
os.environ['AWS_ACCESS_KEY_ID'] = 'AK00000000000000000'
|
||||
os.environ['AWS_SECRET_ACCESS_KEY'] = 'AS00000000000000000'
|
||||
|
||||
# Confirm they are set
|
||||
print(os.environ['AWS_REGION'])
|
||||
print(os.environ['AWS_ACCESS_KEY_ID'])
|
||||
print(os.environ['AWS_SECRET_ACCESS_KEY'])
|
||||
```
|
||||
|
||||
## Configuration and Usage
|
||||
|
||||
This sets up Mem0 with AWS Bedrock for embeddings and LLM, and OpenSearch as the vector store.
|
||||
|
||||
```python
|
||||
import boto3
|
||||
from opensearchpy import OpenSearch, RequestsHttpConnection, AWSV4SignerAuth
|
||||
from mem0.memory.main import Memory
|
||||
|
||||
region = 'us-west-2'
|
||||
service = 'aoss'
|
||||
credentials = boto3.Session().get_credentials()
|
||||
auth = AWSV4SignerAuth(credentials, region, service)
|
||||
|
||||
config = {
|
||||
"embedder": {
|
||||
"provider": "aws_bedrock",
|
||||
"config": {
|
||||
"model": "amazon.titan-embed-text-v2:0"
|
||||
}
|
||||
},
|
||||
"llm": {
|
||||
"provider": "aws_bedrock",
|
||||
"config": {
|
||||
"model": "anthropic.claude-3-5-haiku-20241022-v1:0",
|
||||
"temperature": 0.1,
|
||||
"max_tokens": 2000
|
||||
}
|
||||
},
|
||||
"vector_store": {
|
||||
"provider": "opensearch",
|
||||
"config": {
|
||||
"collection_name": "mem0",
|
||||
"host": "your-opensearch-domain.us-west-2.es.amazonaws.com",
|
||||
"port": 443,
|
||||
"http_auth": auth,
|
||||
"embedding_model_dims": 1024,
|
||||
"connection_class": RequestsHttpConnection,
|
||||
"pool_maxsize": 20,
|
||||
"use_ssl": True,
|
||||
"verify_certs": True
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Initialize memory system
|
||||
m = Memory.from_config(config)
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
#### Add a memory:
|
||||
|
||||
```python
|
||||
messages = [
|
||||
{"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
|
||||
{"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."},
|
||||
{"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."},
|
||||
{"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."}
|
||||
]
|
||||
|
||||
# Store inferred memories (default behavior)
|
||||
result = m.add(messages, user_id="alice", metadata={"category": "movie_recommendations"})
|
||||
```
|
||||
|
||||
#### Search a memory:
|
||||
```python
|
||||
relevant_memories = m.search(query, user_id="alice")
|
||||
```
|
||||
|
||||
#### Get all memories:
|
||||
```python
|
||||
all_memories = m.get_all(user_id="alice")
|
||||
```
|
||||
|
||||
#### Get a specific memory:
|
||||
```python
|
||||
memory = m.get(memory_id)
|
||||
```
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Conclusion
|
||||
|
||||
With Mem0 and AWS services like Bedrock and OpenSearch, you can build intelligent AI companions that remember, adapt, and personalize their responses over time. This makes them ideal for long-term assistants, tutors, or support bots with persistent memory and natural conversation abilities.
|
||||
@@ -1,5 +1,7 @@
|
||||
# Mem0 Chrome Extension
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Enhance your AI interactions with **Mem0**, a Chrome extension that introduces a universal memory layer across platforms like `ChatGPT`, `Claude`, and `Perplexity`. Mem0 ensures seamless context sharing, making your AI experiences more personalized and efficient.
|
||||
|
||||
<Note>
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
---
|
||||
title: Collaborative Task Agent
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
# Building a Collaborative Task Management System with Mem0
|
||||
|
||||
## Overview
|
||||
|
||||
Mem0's advanced attribution capabilities now allow you to create multi-user , multi-agent collaborative or chat systems by attaching an **`actor_id`** to each memory. By setting the users's name in `message["name"]`, you can build powerful team collaboration tools where contributions are properly attributed to their authors.
|
||||
|
||||
When using `infer=False`, messages are stored exactly as provided while still preserving actor metadata—making this approach ideal for:
|
||||
|
||||
- Multi-user chat applications
|
||||
- Team brainstorming sessions
|
||||
- Any collaborative "shared canvas" scenario
|
||||
|
||||
> **ℹ️ Note**
|
||||
> Actor attribution works today with `infer=False` mode.
|
||||
> Full attribution support for the fact-extraction pipeline (`infer=True`) will be available in an upcoming release.
|
||||
|
||||
## Key Concepts
|
||||
|
||||
### Session Context
|
||||
|
||||
Session context is defined by one of three identifiers:
|
||||
- **`user_id`**: Ideal for personal memory or user-specific data
|
||||
- **`agent_id`**: Used for agent-specific memory storage
|
||||
- **`run_id`**: Best for shared task contexts or collaborative spaces
|
||||
|
||||
Developers choose which identifier best represents their use case. In this example, we use `run_id` to create a shared project space where all team members can collaborate.
|
||||
|
||||
### Actor Attribution
|
||||
|
||||
Actor attribution is derived internally from:
|
||||
- **`message["name"]`**: Becomes the `actor_id` in the memory's metadata
|
||||
- **`message["role"]`**: Stored as the `role` in the memory's metadata
|
||||
|
||||
Note that `actor_id` is not a top-level parameter for the `add()` method, but is instead extracted from the message itself.
|
||||
|
||||
### Memory Filtering
|
||||
|
||||
When retrieving memories, you can filter by actor using the `filters` parameter:
|
||||
```python
|
||||
# Get all memories from a specific actor
|
||||
memories = mem.search("query", run_id="landing-v1", filters={"actor_id": "alice"})
|
||||
|
||||
# Get all memories from all team members
|
||||
all_memories = mem.get_all(run_id="landing-v1")
|
||||
```
|
||||
|
||||
## Upcoming Features
|
||||
|
||||
Mem0 will soon support full actor attribution with `infer=True`, enabling automatic extraction of actor names during the fact extraction process. This enhancement will allow the system to:
|
||||
|
||||
1. Maintain attribution information when converting raw messages to semantic facts
|
||||
2. Associate extracted knowledge with its original source
|
||||
3. Track the provenance of information across complex interactions
|
||||
|
||||
Mem0's actor attribution system can power a wide range of advanced conversation and agent scenarios:
|
||||
|
||||
### Conversation Scenarios
|
||||
|
||||
| Scenario | Description | Implementation |
|
||||
|----------|-------------|----------------|
|
||||
| **Simple Chat** | One-to-one conversation between user and assistant
|
||||
| **Multi-User Chat** | Multiple users conversing with a single assistant
|
||||
| **Multi-Agent Chat** | Multiple AI assistants with distinct personas or capabilities
|
||||
| **Group Chat** | Complex interactions between multiple humans and assistants
|
||||
### Agent-Based Applications
|
||||
|
||||
The collaborative task agent uses a simple but powerful architecture:
|
||||
|
||||
* A **shared project space** identified by a single `run_id`
|
||||
* Each participant (user or AI) writes with their own **unique name** which becomes the `actor_id` in Mem0
|
||||
* All memories can be searched, filtered, or visualized by actor
|
||||
|
||||
|
||||
## Implementation
|
||||
|
||||
Below is a complete implementation of a collaborative task agent that demonstrates how to build team-oriented applications with Mem0.
|
||||
|
||||
```python
|
||||
from openai import OpenAI
|
||||
from mem0 import Memory
|
||||
import os
|
||||
from datetime import datetime # For parsing and formatting timestamps
|
||||
|
||||
# Configuration
|
||||
os.environ["OPENAI_API_KEY"] = "sk-your-key" # Replace with your key
|
||||
client = OpenAI()
|
||||
|
||||
RUN_ID = "landing-v1" # Shared project context
|
||||
APP_ID = "task-agent-demo" # Application identifier
|
||||
|
||||
# Initialize Mem0 with default settings (local Qdrant + SQLite)
|
||||
# Ensure the path is writable if not using in-memory
|
||||
mem = Memory()
|
||||
|
||||
class TaskAgent:
|
||||
def __init__(self, run_id: str):
|
||||
"""
|
||||
Initialize a collaborative task agent for a specific project.
|
||||
|
||||
Args:
|
||||
run_id: Unique identifier for this project workspace
|
||||
"""
|
||||
self.run_id = run_id
|
||||
self.mem = mem
|
||||
|
||||
def add_message(self, role: str, speaker: str, content: str):
|
||||
"""
|
||||
Store a chat message with proper attribution.
|
||||
|
||||
Args:
|
||||
role: Message role (user, assistant, system)
|
||||
speaker: Name of the person/agent speaking (becomes actor_id)
|
||||
content: The actual message content
|
||||
"""
|
||||
msg = {"role": role, "name": speaker, "content": content}
|
||||
# Ensure created_at is stored. Mem0 does this by default.
|
||||
self.mem.add(
|
||||
[msg],
|
||||
run_id=self.run_id,
|
||||
metadata={"app_id": APP_ID},
|
||||
infer=False
|
||||
)
|
||||
|
||||
def brainstorm(self, prompt: str, speaker: str = "assistant", search_limit: int = 10, exclude_assistant_context: bool = False):
|
||||
"""
|
||||
Generate a response based on project context and team input.
|
||||
|
||||
Args:
|
||||
prompt: The question or task to address
|
||||
speaker: Name to attribute the assistant's response to
|
||||
search_limit: Max number of memories to retrieve for context
|
||||
exclude_assistant_context: If True, filters out assistant's own messages from context
|
||||
|
||||
Returns:
|
||||
str: The assistant's response
|
||||
"""
|
||||
# Retrieve relevant context from team's shared memory
|
||||
# Fetch a bit more if we plan to filter, to ensure we still get enough relevant user messages.
|
||||
fetch_limit = search_limit + 5 if exclude_assistant_context else search_limit
|
||||
retrieved_memories = self.mem.search(prompt, run_id=self.run_id, limit=fetch_limit)["results"]
|
||||
|
||||
# Client-side sorting by 'created_at' to prioritize recent memories for context.
|
||||
# Note: Timestamps should be in a directly comparable format or parsed.
|
||||
# Mem0 stores created_at as ISO format strings, which are comparable.
|
||||
retrieved_memories.sort(key=lambda m: m.get('created_at', ''), reverse=True)
|
||||
|
||||
ctx_for_llm = []
|
||||
if exclude_assistant_context:
|
||||
for m in retrieved_memories:
|
||||
if m.get("role") != "assistant":
|
||||
ctx_for_llm.append(m)
|
||||
if len(ctx_for_llm) >= search_limit:
|
||||
break
|
||||
else:
|
||||
ctx_for_llm = retrieved_memories[:search_limit]
|
||||
|
||||
context_parts = []
|
||||
for m in ctx_for_llm:
|
||||
actor = m.get('actor_id') or "Unknown"
|
||||
# Attempt to parse and format the timestamp for better readability
|
||||
try:
|
||||
ts_iso = m.get('created_at', '')
|
||||
if ts_iso:
|
||||
ts_obj = datetime.fromisoformat(ts_iso.replace('Z', '+00:00')) # Handle Zulu time
|
||||
formatted_ts = ts_obj.strftime('%Y-%m-%d %H:%M:%S %Z')
|
||||
else:
|
||||
formatted_ts = "Timestamp N/A"
|
||||
except ValueError:
|
||||
formatted_ts = ts_iso # Fallback to raw string if parsing fails
|
||||
context_parts.append(f"- {m['memory']} (by {actor} at {formatted_ts})")
|
||||
|
||||
context_str = "\n".join(context_parts)
|
||||
|
||||
# Generate response with context-aware prompting
|
||||
sys_prompt = "You are the team's project assistant. Use the provided memory context, paying attention to timestamps for recency, to answer the user's query or perform the task."
|
||||
user_prompt_with_context = f"Query: {prompt}\n\nRelevant Context (most recent first):\n{context_str}"
|
||||
|
||||
msgs = [
|
||||
{"role": "system", "content": sys_prompt},
|
||||
{"role": "user", "content": user_prompt_with_context}
|
||||
]
|
||||
|
||||
reply = client.chat.completions.create(
|
||||
model="gpt-4o-mini",
|
||||
messages=msgs
|
||||
).choices[0].message.content.strip()
|
||||
|
||||
# Store the assistant's response with attribution
|
||||
self.add_message("assistant", speaker, reply)
|
||||
return reply
|
||||
|
||||
def dump(self, sort_by_time: bool = True, group_by_speaker: bool = False):
|
||||
"""
|
||||
Display all messages in the shared project space with attribution.
|
||||
Can be sorted by time and/or grouped by speaker.
|
||||
"""
|
||||
results = self.mem.get_all(run_id=self.run_id)["results"]
|
||||
|
||||
if not results:
|
||||
print("No memories found for this run.")
|
||||
return
|
||||
|
||||
# Sort by 'created_at' if requested
|
||||
if sort_by_time:
|
||||
results.sort(key=lambda m: m.get('created_at', ''))
|
||||
print(f"\n--- Project memory (run_id: {self.run_id}, sorted by time) ---")
|
||||
else:
|
||||
print(f"\n--- Project memory (run_id: {self.run_id}) ---")
|
||||
|
||||
if group_by_speaker:
|
||||
from collections import defaultdict
|
||||
grouped_memories = defaultdict(list)
|
||||
for m in results: # Use already potentially sorted results
|
||||
grouped_memories[m.get("actor_id") or "Unknown"].append(m)
|
||||
|
||||
for speaker, mem_list in grouped_memories.items():
|
||||
print(f"\n=== Speaker: {speaker} ===")
|
||||
# If not already sorted by time globally, sort within group
|
||||
# If already sorted globally, this re-sort is redundant unless different key.
|
||||
# For simplicity, if sort_by_time was true, list is already sorted.
|
||||
for m_item in mem_list:
|
||||
timestamp_str = m_item.get('created_at', 'Timestamp N/A')
|
||||
try:
|
||||
# Basic parsing for display, adjust as needed
|
||||
dt_obj = datetime.fromisoformat(timestamp_str.replace('Z', '+00:00'))
|
||||
formatted_time = dt_obj.strftime('%Y-%m-%d %H:%M:%S')
|
||||
except ValueError:
|
||||
formatted_time = timestamp_str # Fallback
|
||||
print(f"[{formatted_time:19}] {m_item['memory']}")
|
||||
else: # Not grouping by speaker
|
||||
for m in results:
|
||||
who = m.get("actor_id") or "Unknown"
|
||||
timestamp_str = m.get('created_at', 'Timestamp N/A')
|
||||
try:
|
||||
dt_obj = datetime.fromisoformat(timestamp_str.replace('Z', '+00:00'))
|
||||
formatted_time = dt_obj.strftime('%Y-%m-%d %H:%M:%S')
|
||||
except ValueError:
|
||||
formatted_time = timestamp_str # Fallback
|
||||
print(f"[{formatted_time:19}][{who:8}] {m['memory']}")
|
||||
|
||||
# Demo Usage
|
||||
agent = TaskAgent(RUN_ID)
|
||||
|
||||
# Team collaboration session
|
||||
agent.add_message("user", "alice", "Let's list tasks for the new landing page.")
|
||||
agent.add_message("user", "bob", "I'll own the hero section copy. Maybe tomorrow.")
|
||||
agent.add_message("user", "carol", "I'll choose three product screenshots later today.")
|
||||
agent.add_message("user", "alice", "Actually, I will work on the hero section copy today.")
|
||||
|
||||
|
||||
print("\nAssistant brainstorm reply (default settings):\n")
|
||||
print(agent.brainstorm("What are the current open tasks related to the hero section?"))
|
||||
|
||||
print("\nAssistant brainstorm reply (excluding its own prior context):\n")
|
||||
print(agent.brainstorm("Summarize what Alice is working on.", exclude_assistant_context=True))
|
||||
|
||||
|
||||
print("\n--- Dump (sorted by time by default) ---")
|
||||
agent.dump()
|
||||
|
||||
print("\n--- Dump (grouped by speaker, also sorted by time globally) ---")
|
||||
agent.dump(group_by_speaker=True)
|
||||
|
||||
print("\n--- Dump (default order, not sorted by time explicitly by dump) ---")
|
||||
agent.dump(sort_by_time=False)
|
||||
|
||||
```
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Customer Support AI Agent
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
You can create a personalized Customer Support AI Agent using Mem0. This guide will walk you through the necessary steps and provide the complete code to get you started.
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
title: Document Editing with Mem0
|
||||
---
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
This guide demonstrates how to leverage **Mem0** to edit documents efficiently, ensuring they align with your unique writing style and preferences.
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
title: Eliza OS Character
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
You can create a personalised Eliza OS Character using Mem0. This guide will walk you through the necessary steps and provide the complete code to get you started.
|
||||
|
||||
## Overview
|
||||
|
||||
ElizaOS is a powerful AI agent framework for autonomy & personality. It is a collection of tools that help you create a personalised AI agent.
|
||||
|
||||
## Setup
|
||||
You can start by cloning the eliza-os repository:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/elizaOS/eliza.git
|
||||
```
|
||||
|
||||
Change the directory to the eliza-os repository:
|
||||
|
||||
```bash
|
||||
cd eliza
|
||||
```
|
||||
|
||||
Install the dependencies:
|
||||
|
||||
```bash
|
||||
pnpm install
|
||||
```
|
||||
|
||||
Build the project:
|
||||
|
||||
```bash
|
||||
pnpm build
|
||||
```
|
||||
|
||||
## Setup ENVs
|
||||
|
||||
Create a `.env` file in the root of the project and add the following ( You can use the `.env.example` file as a reference):
|
||||
|
||||
```bash
|
||||
# Mem0 Configuration
|
||||
MEM0_API_KEY= # Mem0 API Key ( Get from https://app.mem0.ai/dashboard/api-keys )
|
||||
MEM0_USER_ID= # Default: eliza-os-user
|
||||
MEM0_PROVIDER= # Default: openai
|
||||
MEM0_PROVIDER_API_KEY= # API Key for the provider (openai, anthropic, etc.)
|
||||
SMALL_MEM0_MODEL= # Default: gpt-4o-mini
|
||||
MEDIUM_MEM0_MODEL= # Default: gpt-4o
|
||||
LARGE_MEM0_MODEL= # Default: gpt-4o
|
||||
```
|
||||
|
||||
## Make the default character use Mem0
|
||||
|
||||
By default, there is a character called `eliza` that uses the `ollama` model. You can make this character use Mem0 by changing the config in the `agent/src/defaultCharacter.ts` file.
|
||||
|
||||
```ts
|
||||
modelProvider: ModelProviderName.MEM0,
|
||||
```
|
||||
|
||||
This will make the character use Mem0 to generate responses.
|
||||
|
||||
## Run the project
|
||||
|
||||
```bash
|
||||
pnpm start
|
||||
```
|
||||
|
||||
## Conclusion
|
||||
|
||||
You have now created a personalised Eliza OS Character using Mem0. You can now start interacting with the character by running the project and talking to the character.
|
||||
|
||||
This is a simple example of how to use Mem0 to create a personalised AI agent. You can use this as a starting point to create your own AI agent.
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Email Processing with Mem0
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
This guide demonstrates how to build an intelligent email processing system using Mem0's memory capabilities. You'll learn how to store, categorize, retrieve, and analyze emails to create a smart email management solution.
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
---
|
||||
title: LlamaIndex ReAct Agent
|
||||
---
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Create a ReAct Agent with LlamaIndex which uses Mem0 as the memory store.
|
||||
|
||||
### Overview
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Mem0 as an Agentic Tool
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Integrate Mem0's memory capabilities with OpenAI's Agents SDK to create AI agents with persistent memory.
|
||||
You can create agents that remember past conversations and use that context to provide better responses.
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
title: Mem0 Demo
|
||||
---
|
||||
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
You can create a personalized AI Companion using Mem0. This guide will walk you through the necessary steps and provide the complete setup instructions to get you started.
|
||||
|
||||
<video
|
||||
@@ -13,7 +16,7 @@ You can create a personalized AI Companion using Mem0. This guide will walk you
|
||||
src="https://github.com/user-attachments/assets/cebc4f8e-bdb9-4837-868d-13c5ab7bb433"
|
||||
></video>
|
||||
|
||||
You can try the [Mem0 Demo](https://mem0.dev/demo) live here.
|
||||
You can try the [Mem0 Demo](https://mem0-4vmi.vercel.app) live here.
|
||||
|
||||
## Overview
|
||||
|
||||
|
||||
@@ -0,0 +1,291 @@
|
||||
---
|
||||
title: 'Healthcare Assistant with Mem0 and Google ADK'
|
||||
description: 'Build a personalized healthcare agent that remembers patient information across conversations using Mem0 and Google ADK'
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
# Healthcare Assistant with Memory
|
||||
|
||||
This example demonstrates how to build a healthcare assistant that remembers patient information across conversations using Google ADK and Mem0.
|
||||
|
||||
## Overview
|
||||
|
||||
The Healthcare Assistant helps patients by:
|
||||
- Remembering their medical history and symptoms
|
||||
- Providing general health information
|
||||
- Scheduling appointment reminders
|
||||
- Maintaining a personalized experience across conversations
|
||||
|
||||
By integrating Mem0's memory layer with Google ADK, the assistant maintains context about the patient without requiring them to repeat information.
|
||||
|
||||
## Setup
|
||||
|
||||
Before you begin, make sure you have:
|
||||
|
||||
Installed Google ADK and Mem0 SDK:
|
||||
```bash
|
||||
pip install google-adk
|
||||
pip install mem0ai
|
||||
```
|
||||
|
||||
## Code Breakdown
|
||||
|
||||
Let's get started and understand the different components required in building a healthcare assistant powered by memory
|
||||
|
||||
```python
|
||||
# Import dependencies
|
||||
import os
|
||||
from google.adk.agents import Agent
|
||||
from google.adk.sessions import InMemorySessionService
|
||||
from google.adk.runners import Runner
|
||||
from google.genai import types
|
||||
from mem0 import MemoryClient
|
||||
|
||||
# Set up API keys (replace with your actual keys)
|
||||
os.environ["GOOGLE_API_KEY"] = "your-google-api-key"
|
||||
os.environ["MEM0_API_KEY"] = "your-mem0-api-key"
|
||||
|
||||
# Define a global user ID for simplicity
|
||||
USER_ID = "Alex"
|
||||
|
||||
# Initialize Mem0 client
|
||||
mem0_client = MemoryClient()
|
||||
```
|
||||
|
||||
## Define Memory Tools
|
||||
|
||||
First, we'll create tools that allow our agent to store and retrieve information using Mem0:
|
||||
|
||||
```python
|
||||
def save_patient_info(information: str) -> dict:
|
||||
"""Saves important patient information to memory."""
|
||||
|
||||
# Store in Mem0
|
||||
response = mem0_client.add(
|
||||
[{"role": "user", "content": information}],
|
||||
user_id=USER_ID,
|
||||
run_id="healthcare_session",
|
||||
metadata={"type": "patient_information"}
|
||||
)
|
||||
|
||||
|
||||
def retrieve_patient_info(query: str) -> dict:
|
||||
"""Retrieves relevant patient information from memory."""
|
||||
|
||||
# Search Mem0
|
||||
results = mem0_client.search(
|
||||
query,
|
||||
user_id=USER_ID,
|
||||
limit=5,
|
||||
threshold=0.7, # Higher threshold for more relevant results
|
||||
output_format="v1.1"
|
||||
)
|
||||
|
||||
# Format and return the results
|
||||
if results and len(results) > 0:
|
||||
memories = [memory["memory"] for memory in results.get('results', [])]
|
||||
return {
|
||||
"status": "success",
|
||||
"memories": memories,
|
||||
"count": len(memories)
|
||||
}
|
||||
else:
|
||||
return {
|
||||
"status": "no_results",
|
||||
"memories": [],
|
||||
"count": 0
|
||||
}
|
||||
```
|
||||
|
||||
## Define Healthcare Tools
|
||||
|
||||
Next, we'll add tools specific to healthcare assistance:
|
||||
|
||||
```python
|
||||
def schedule_appointment(date: str, time: str, reason: str) -> dict:
|
||||
"""Schedules a doctor's appointment."""
|
||||
# In a real app, this would connect to a scheduling system
|
||||
appointment_id = f"APT-{hash(date + time) % 10000}"
|
||||
|
||||
return {
|
||||
"status": "success",
|
||||
"appointment_id": appointment_id,
|
||||
"confirmation": f"Appointment scheduled for {date} at {time} for {reason}",
|
||||
"message": "Please arrive 15 minutes early to complete paperwork."
|
||||
}
|
||||
```
|
||||
|
||||
## Create the Healthcare Assistant Agent
|
||||
|
||||
Now we'll create our main agent with all the tools:
|
||||
|
||||
```python
|
||||
# Create the agent
|
||||
healthcare_agent = Agent(
|
||||
name="healthcare_assistant",
|
||||
model="gemini-1.5-flash", # Using Gemini for healthcare assistant
|
||||
description="Healthcare assistant that helps patients with health information and appointment scheduling.",
|
||||
instruction="""You are a helpful Healthcare Assistant with memory capabilities.
|
||||
|
||||
Your primary responsibilities are to:
|
||||
1. Remember patient information using the 'save_patient_info' tool when they share symptoms, conditions, or preferences.
|
||||
2. Retrieve past patient information using the 'retrieve_patient_info' tool when relevant to the current conversation.
|
||||
3. Help schedule appointments using the 'schedule_appointment' tool.
|
||||
|
||||
IMPORTANT GUIDELINES:
|
||||
- Always be empathetic, professional, and helpful.
|
||||
- Save important patient information like symptoms, conditions, allergies, and preferences.
|
||||
- Check if you have relevant patient information before asking for details they may have shared previously.
|
||||
- Make it clear you are not a doctor and cannot provide medical diagnosis or treatment.
|
||||
- For serious symptoms, always recommend consulting a healthcare professional.
|
||||
- Keep all patient information confidential.
|
||||
""",
|
||||
tools=[save_patient_info, retrieve_patient_info, schedule_appointment]
|
||||
)
|
||||
```
|
||||
|
||||
## Set Up Session and Runner
|
||||
|
||||
```python
|
||||
# Set up Session Service and Runner
|
||||
session_service = InMemorySessionService()
|
||||
|
||||
# Define constants for the conversation
|
||||
APP_NAME = "healthcare_assistant_app"
|
||||
USER_ID = "Alex"
|
||||
SESSION_ID = "session_001"
|
||||
|
||||
# Create a session
|
||||
session = session_service.create_session(
|
||||
app_name=APP_NAME,
|
||||
user_id=USER_ID,
|
||||
session_id=SESSION_ID
|
||||
)
|
||||
|
||||
# Create the runner
|
||||
runner = Runner(
|
||||
agent=healthcare_agent,
|
||||
app_name=APP_NAME,
|
||||
session_service=session_service
|
||||
)
|
||||
```
|
||||
|
||||
## Interact with the Healthcare Assistant
|
||||
|
||||
```python
|
||||
# Function to interact with the agent
|
||||
async def call_agent_async(query, runner, user_id, session_id):
|
||||
"""Sends a query to the agent and returns the final response."""
|
||||
print(f"\n>>> Patient: {query}")
|
||||
|
||||
# Format the user's message
|
||||
content = types.Content(
|
||||
role='user',
|
||||
parts=[types.Part(text=query)]
|
||||
)
|
||||
|
||||
# Set user_id for tools to access
|
||||
save_patient_info.user_id = user_id
|
||||
retrieve_patient_info.user_id = user_id
|
||||
|
||||
# Run the agent
|
||||
async for event in runner.run_async(
|
||||
user_id=user_id,
|
||||
session_id=session_id,
|
||||
new_message=content
|
||||
):
|
||||
if event.is_final_response():
|
||||
if event.content and event.content.parts:
|
||||
response = event.content.parts[0].text
|
||||
print(f"<<< Assistant: {response}")
|
||||
return response
|
||||
|
||||
return "No response received."
|
||||
|
||||
# Example conversation flow
|
||||
async def run_conversation():
|
||||
# First interaction - patient introduces themselves with key information
|
||||
await call_agent_async(
|
||||
"Hi, I'm Alex. I've been having headaches for the past week, and I have a penicillin allergy.",
|
||||
runner=runner,
|
||||
user_id=USER_ID,
|
||||
session_id=SESSION_ID
|
||||
)
|
||||
|
||||
# Request for health information
|
||||
await call_agent_async(
|
||||
"Can you tell me more about what might be causing my headaches?",
|
||||
runner=runner,
|
||||
user_id=USER_ID,
|
||||
session_id=SESSION_ID
|
||||
)
|
||||
|
||||
# Schedule an appointment
|
||||
await call_agent_async(
|
||||
"I think I should see a doctor. Can you help me schedule an appointment for next Monday at 2pm?",
|
||||
runner=runner,
|
||||
user_id=USER_ID,
|
||||
session_id=SESSION_ID
|
||||
)
|
||||
|
||||
# Test memory - should remember patient name, symptoms, and allergy
|
||||
await call_agent_async(
|
||||
"What medications should I avoid for my headaches?",
|
||||
runner=runner,
|
||||
user_id=USER_ID,
|
||||
session_id=SESSION_ID
|
||||
)
|
||||
|
||||
# Run the conversation example
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(run_conversation())
|
||||
```
|
||||
|
||||
## How It Works
|
||||
|
||||
This healthcare assistant demonstrates several key capabilities:
|
||||
|
||||
1. **Memory Storage**: When Alex mentions her headaches and penicillin allergy, the agent stores this information in Mem0 using the `save_patient_info` tool.
|
||||
|
||||
2. **Contextual Retrieval**: When Alex asks about headache causes, the agent uses the `retrieve_patient_info` tool to recall her specific situation.
|
||||
|
||||
3. **Memory Application**: When discussing medications, the agent remembers Alex's penicillin allergy without her needing to repeat it, providing safer and more personalized advice.
|
||||
|
||||
4. **Conversation Continuity**: The agent maintains context across the entire conversation session, creating a more natural and efficient interaction.
|
||||
|
||||
## Key Implementation Details
|
||||
|
||||
### User ID Management
|
||||
|
||||
Instead of passing the user ID as a parameter to the memory tools (which would require modifying the ADK's tool calling system), we attach it directly to the function object:
|
||||
|
||||
```python
|
||||
# Set user_id for tools to access
|
||||
save_patient_info.user_id = user_id
|
||||
retrieve_patient_info.user_id = user_id
|
||||
```
|
||||
|
||||
Inside the tool functions, we retrieve this attribute:
|
||||
|
||||
```python
|
||||
# Get user_id from session state or use default
|
||||
user_id = getattr(save_patient_info, 'user_id', 'default_user')
|
||||
```
|
||||
|
||||
This approach allows our tools to maintain user context without complicating their parameter signatures.
|
||||
|
||||
### Mem0 Integration
|
||||
|
||||
The integration with Mem0 happens through two primary functions:
|
||||
|
||||
1. `mem0_client.add()` - Stores new information with appropriate metadata
|
||||
2. `mem0_client.search()` - Retrieves relevant memories using semantic search
|
||||
|
||||
The `threshold` parameter in the search function ensures that only highly relevant memories are returned.
|
||||
|
||||
## Conclusion
|
||||
|
||||
This example demonstrates how to build a healthcare assistant with persistent memory using Google ADK and Mem0. The integration allows for a more personalized patient experience by maintaining context across conversation turns, which is particularly valuable in healthcare scenarios where continuity of information is crucial.
|
||||
|
||||
By storing and retrieving patient information intelligently, the assistant provides more relevant responses without requiring the patient to repeat their medical history, symptoms, or preferences.
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Mem0 with Mastra
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
In this example you'll learn how to use the Mem0 to add long-term memory capabilities to [Mastra's agent](https://mastra.ai/) via tool-use.
|
||||
This memory integration can work alongside Mastra's [agent memory features](https://mastra.ai/docs/agents/01-agent-memory).
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ title: 'Mem0 with OpenAI Agents SDK for Voice'
|
||||
description: 'Integrate memory capabilities into your voice agents using Mem0 and OpenAI Agents SDK'
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
# Building Voice Agents with Memory using Mem0 and OpenAI Agents SDK
|
||||
|
||||
This guide demonstrates how to combine OpenAI's Agents SDK for voice applications with Mem0's memory capabilities to create a voice assistant that remembers user preferences and past interactions.
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Mem0 with Ollama
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
## Running Mem0 Locally with Ollama
|
||||
|
||||
Mem0 can be utilized entirely locally by leveraging Ollama for both the embedding model and the language model (LLM). This guide will walk you through the necessary steps and provide the complete code to get you started.
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Multimodal Demo with Mem0
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Enhance your AI interactions with **Mem0**'s multimodal capabilities. Mem0 now supports image understanding, allowing for richer context and more natural interactions across supported AI platforms.
|
||||
|
||||
> 🎉 Experience the power of multimodal AI! Test out Mem0's image understanding capabilities at [multimodal-demo.mem0.ai](https://multimodal-demo.mem0.ai)
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: OpenAI Inbuilt Tools
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Integrate Mem0’s memory capabilities with OpenAI’s Inbuilt Tools to create AI agents with persistent memory.
|
||||
|
||||
## Getting Started
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Personalized AI Tutor
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
You can create a personalized AI Tutor using Mem0. This guide will walk you through the necessary steps and provide the complete code to get you started.
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
---
|
||||
title: Personal AI Travel Assistant
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Create a personalized AI Travel Assistant using Mem0. This guide provides step-by-step instructions and the complete code to get you started.
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Personalized Deep Research
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Deep Research is an intelligent agent that synthesizes large amounts of online data and completes complex research tasks, customized to your unique preferences and insights. Built on Mem0's technology, it enhances AI-driven online exploration with personalized memories.
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: YouTube Assistant Extension
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Enhance your YouTube experience with Mem0's **YouTube Assistant**, a Chrome extension that brings AI-powered chat directly to your YouTube videos. Get instant, personalized answers about video content while leveraging your own knowledge and memories - all without leaving the page.
|
||||
|
||||
## Features
|
||||
|
||||
@@ -4,6 +4,7 @@ icon: "question"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
<AccordionGroup>
|
||||
<Accordion title="How does Mem0 work?">
|
||||
|
||||
@@ -4,6 +4,8 @@ icon: "wrench"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
## Core features
|
||||
|
||||
- **User, Session, and AI Agent Memory**: Retains information across sessions and interactions for users and AI agents, ensuring continuity and context.
|
||||
|
||||
@@ -4,6 +4,8 @@ icon: "magnifying-glass"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Mem0's **Advanced Retrieval** feature delivers superior search results by leveraging state-of-the-art search algorithms. Beyond the default search functionality, Mem0 offers the following advanced retrieval modes:
|
||||
|
||||
1. **Keyword Search**
|
||||
|
||||
@@ -5,6 +5,7 @@ icon: "bolt"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
The `AsyncMemoryClient` is an asynchronous client for interacting with the Mem0 API. It provides similar functionality to the synchronous `MemoryClient` but allows for non-blocking operations, which can be beneficial in applications that require high concurrency.
|
||||
|
||||
## Initialization
|
||||
|
||||
@@ -4,6 +4,8 @@ icon: "square-plus"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Mem0 now supports an contextual add version (v2). To use it, set `version="v2"` during the add call. The default version is v1, which is deprecated now. We recommend migrating to `v2` for new applications.
|
||||
|
||||
## Key Differences Between v1 and v2
|
||||
|
||||
@@ -5,6 +5,8 @@ icon: "tags"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
## How to set custom categories?
|
||||
|
||||
You can now create custom categories tailored to your specific needs, instead of using the default categories such as travel, sports, music, and more (see [default categories](#default-categories) below). **When custom categories are provided, they will override the default categories.**
|
||||
|
||||
@@ -5,6 +5,8 @@ icon: "pencil"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
## Introduction to Custom Fact Extraction Prompt
|
||||
|
||||
Custom fact extraction prompt allow you to tailor the behavior of your Mem0 instance to specific use cases or domains.
|
||||
|
||||
@@ -5,6 +5,8 @@ icon: "pencil"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
## Introduction to Custom Instructions
|
||||
|
||||
Custom instructions allow you to define specific guidelines for your project. This feature helps ensure consistency and provides clear direction for handling project-specific requirements.
|
||||
|
||||
@@ -3,9 +3,12 @@ title: Custom Update Memory Prompt
|
||||
icon: "pencil"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Update memory prompt is a prompt used to determine the action to be performed on the memory.
|
||||
By customizing this prompt, you can control how the memory is updated.
|
||||
|
||||
|
||||
|
||||
## Introduction
|
||||
Mem0 memory system compares the newly retrieved facts with the existing memory and determines the action to be performed on the memory.
|
||||
|
||||
@@ -5,6 +5,8 @@ icon: "arrow-right"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
## How to use Direct Import?
|
||||
The Direct Import feature allows users to skip the memory deduction phase and directly input pre-defined memories into the system for storage and retrieval.
|
||||
To enable this feature, you need to set the `infer` parameter to `False` in the `add` method.
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
---
|
||||
title: Expiration Date
|
||||
description: 'Set time-bound memories in Mem0 with automatic expiration dates to manage temporal information effectively.'
|
||||
icon: "clock"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
## Benefits of Memory Expiration
|
||||
|
||||
Setting expiration dates for memories offers several advantages:
|
||||
|
||||
• **Time-Sensitive Information Management**: Handle information that's only relevant for a specific time period.
|
||||
|
||||
• **Event-Based Memory**: Manage information related to upcoming events that becomes irrelevant after the event passes.
|
||||
|
||||
These benefits enable more sophisticated memory management for applications where temporal context matters.
|
||||
|
||||
## Setting Memory Expiration Date
|
||||
|
||||
You can set an expiration date for memories, after which they will no longer be retrieved in searches. This is useful for creating temporary memories or memories that are only relevant for a specific time period.
|
||||
|
||||
<CodeGroup>
|
||||
|
||||
```python Python
|
||||
import datetime
|
||||
from mem0 import MemoryClient
|
||||
|
||||
client = MemoryClient(api_key="your-api-key")
|
||||
|
||||
messages = [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "I'll be in San Francisco until end of this month."
|
||||
}
|
||||
]
|
||||
|
||||
# Set an expiration date for this memory
|
||||
client.add(messages=messages, user_id="alex", expiration_date=str(datetime.datetime.now().date() + datetime.timedelta(days=30)))
|
||||
|
||||
# You can also use an explicit date string
|
||||
client.add(messages=messages, user_id="alex", expiration_date="2023-08-31")
|
||||
```
|
||||
|
||||
```javascript JavaScript
|
||||
import MemoryClient from 'mem0ai';
|
||||
const client = new MemoryClient({ apiKey: 'your-api-key' });
|
||||
|
||||
const messages = [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "I'll be in San Francisco until end of this month."
|
||||
}
|
||||
];
|
||||
|
||||
// Set an expiration date 30 days from now
|
||||
const expirationDate = new Date();
|
||||
expirationDate.setDate(expirationDate.getDate() + 30);
|
||||
client.add(messages, {
|
||||
user_id: "alex",
|
||||
expiration_date: expirationDate.toISOString().split('T')[0]
|
||||
})
|
||||
.then(response => console.log(response))
|
||||
.catch(error => console.error(error));
|
||||
|
||||
// You can also use an explicit date string
|
||||
client.add(messages, {
|
||||
user_id: "alex",
|
||||
expiration_date: "2023-08-31"
|
||||
})
|
||||
.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": "I'll be in San Francisco until end of this month."
|
||||
}
|
||||
],
|
||||
"user_id": "alex",
|
||||
"expiration_date": "2023-08-31"
|
||||
}'
|
||||
```
|
||||
|
||||
```json Output
|
||||
{
|
||||
"results": [
|
||||
{
|
||||
"id": "a1b2c3d4-e5f6-4g7h-8i9j-k0l1m2n3o4p5",
|
||||
"data": {
|
||||
"memory": "In San Francisco until end of this month"
|
||||
},
|
||||
"event": "ADD"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
<Note>
|
||||
Once a memory reaches its expiration date, it won't be included in search or get results, though the data remains stored in the system.
|
||||
</Note>
|
||||
|
||||
If you have any questions, please feel free to reach out to us using one of the following methods:
|
||||
|
||||
<Snippet file="get-help.mdx" />
|
||||
@@ -4,6 +4,8 @@ icon: "thumbs-up"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Mem0's **Feedback Mechanism** allows you to provide feedback on the memories generated by your application. This feedback is used to improve the accuracy of the memories and the search results.
|
||||
|
||||
## How it works
|
||||
|
||||
@@ -5,6 +5,8 @@ iconType: "solid"
|
||||
description: "Enable graph-based memory retrieval for more contextually relevant results"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
## Overview
|
||||
|
||||
Graph Memory enhances memory pipeline by creating relationships between entities in your data. It builds a network of interconnected information for more contextually relevant search results.
|
||||
@@ -59,8 +61,8 @@ import { MemoryClient } from "mem0";
|
||||
|
||||
const client = new MemoryClient({
|
||||
apiKey: "your-api-key",
|
||||
orgId: "your-org-id",
|
||||
projectId: "your-project-id"
|
||||
org_id: "your-org-id",
|
||||
project_id: "your-project-id"
|
||||
});
|
||||
|
||||
const messages = [
|
||||
@@ -72,10 +74,10 @@ const messages = [
|
||||
// Enable graph memory when adding
|
||||
await client.add({
|
||||
messages,
|
||||
userId: "joseph",
|
||||
user_id: "joseph",
|
||||
version: "v1",
|
||||
enableGraph: true,
|
||||
outputFormat: "v1.1"
|
||||
enable_graph: true,
|
||||
output_format: "v1.1"
|
||||
});
|
||||
```
|
||||
|
||||
@@ -140,9 +142,9 @@ print(results)
|
||||
// Search with graph memory enabled
|
||||
const results = await client.search({
|
||||
query: "what is my name?",
|
||||
userId: "joseph",
|
||||
enableGraph: true,
|
||||
outputFormat: "v1.1"
|
||||
user_id: "joseph",
|
||||
enable_graph: true,
|
||||
output_format: "v1.1"
|
||||
});
|
||||
|
||||
console.log(results);
|
||||
@@ -209,9 +211,9 @@ print(memories)
|
||||
```javascript JavaScript
|
||||
// Get all memories with graph context
|
||||
const memories = await client.getAll({
|
||||
userId: "joseph",
|
||||
enableGraph: true,
|
||||
outputFormat: "v1.1"
|
||||
user_id: "joseph",
|
||||
enable_graph: true,
|
||||
output_format: "v1.1"
|
||||
});
|
||||
|
||||
console.log(memories);
|
||||
|
||||
@@ -5,6 +5,8 @@ icon: "file-export"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
## Overview
|
||||
|
||||
The Memory Export feature allows you to create structured exports of memories using customizable Pydantic schemas. This process enables you to transform your stored memories into specific data formats that match your needs. You can apply various filters to narrow down which memories to export and define exactly how the data should be structured.
|
||||
|
||||
@@ -5,6 +5,8 @@ icon: "image"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Mem0 extends its capabilities beyond text by supporting multimodal data, including images and documents. With this feature, users can seamlessly integrate visual and document content into their interactions—allowing Mem0 to extract relevant information from various media types and enrich the memory system.
|
||||
|
||||
## How It Works
|
||||
|
||||
@@ -4,6 +4,8 @@ icon: "code"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Mem0 can be easily integrated into chat applications to enhance conversational agents with structured memory. Mem0's APIs are designed to be compatible with OpenAI's, with the goal of making it easy to leverage Mem0 in applications you may have already built.
|
||||
|
||||
If you have a `Mem0 API key`, you can use it to initialize the client. Alternatively, you can initialize Mem0 without an API key if you're using it locally.
|
||||
|
||||
@@ -4,6 +4,8 @@ icon: "info"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Learn about the key features and capabilities that make Mem0 a powerful platform for memory management and retrieval.
|
||||
|
||||
## Core Features
|
||||
|
||||
@@ -5,6 +5,8 @@ icon: "filter"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
## Benefits of Memory Customization
|
||||
|
||||
Memory customization offers several key benefits:
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
---
|
||||
title: Memory Timestamps
|
||||
description: 'Add timestamps to your memories to maintain chronological accuracy and historical context'
|
||||
icon: "clock"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
## Overview
|
||||
|
||||
The Memory Timestamps feature allows you to specify when a memory was created, regardless of when it's actually added to the system. This powerful capability enables you to:
|
||||
|
||||
- Maintain accurate chronological ordering of memories
|
||||
- Import historical data with proper timestamps
|
||||
- Create memories that reflect when events actually occurred
|
||||
- Build timelines with precise temporal information
|
||||
|
||||
By leveraging custom timestamps, you can ensure that your memory system maintains an accurate representation of when information was generated or events occurred.
|
||||
|
||||
## Benefits of Custom Timestamps
|
||||
|
||||
Custom timestamps offer several important benefits:
|
||||
|
||||
• **Historical Accuracy**: Preserve the exact timing of past events and information.
|
||||
|
||||
• **Data Migration**: Seamlessly migrate existing data while maintaining original timestamps.
|
||||
|
||||
• **Time-Sensitive Analysis**: Enable time-based analysis and pattern recognition across memories.
|
||||
|
||||
• **Consistent Chronology**: Maintain proper ordering of memories for coherent storytelling.
|
||||
|
||||
## Using Custom Timestamps
|
||||
|
||||
When adding new memories, you can specify a custom timestamp to indicate when the memory was created. This timestamp will be used instead of the current time.
|
||||
|
||||
### Adding Memories with Custom Timestamps
|
||||
|
||||
<CodeGroup>
|
||||
|
||||
```python Python
|
||||
import os
|
||||
import time
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from mem0 import MemoryClient
|
||||
|
||||
os.environ["MEM0_API_KEY"] = "your-api-key"
|
||||
|
||||
client = MemoryClient()
|
||||
|
||||
# Get the current time
|
||||
current_time = datetime.now()
|
||||
|
||||
# Calculate 5 days ago
|
||||
five_days_ago = current_time - timedelta(days=5)
|
||||
|
||||
# Convert to Unix timestamp (seconds since epoch)
|
||||
unix_timestamp = int(five_days_ago.timestamp())
|
||||
|
||||
# Add memory with custom timestamp
|
||||
client.add("I'm travelling to SF", user_id="user1", timestamp=unix_timestamp)
|
||||
```
|
||||
|
||||
```javascript JavaScript
|
||||
import MemoryClient from 'mem0ai';
|
||||
const client = new MemoryClient({ apiKey: 'your-api-key' });
|
||||
|
||||
// Get the current time
|
||||
const currentTime = new Date();
|
||||
|
||||
// Calculate 5 days ago
|
||||
const fiveDaysAgo = new Date();
|
||||
fiveDaysAgo.setDate(currentTime.getDate() - 5);
|
||||
|
||||
// Convert to Unix timestamp (seconds since epoch)
|
||||
const unixTimestamp = Math.floor(fiveDaysAgo.getTime() / 1000);
|
||||
|
||||
// Add memory with custom timestamp
|
||||
client.add("I'm travelling to SF", { user_id: "user1", timestamp: unixTimestamp })
|
||||
.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": "I'm travelling to SF"}],
|
||||
"user_id": "user1",
|
||||
"timestamp": 1721577600
|
||||
}'
|
||||
```
|
||||
|
||||
```json Output
|
||||
{
|
||||
"results": [
|
||||
{
|
||||
"id": "a1b2c3d4-e5f6-4g7h-8i9j-k0l1m2n3o4p5",
|
||||
"data": {"memory": "Travelling to SF"},
|
||||
"event": "ADD"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
### Timestamp Format
|
||||
|
||||
When specifying a custom timestamp, you should provide a Unix timestamp (seconds since epoch). This is an integer representing the number of seconds that have elapsed since January 1, 1970 (UTC).
|
||||
|
||||
For example, to create a memory with a timestamp of January 1, 2023:
|
||||
|
||||
<CodeGroup>
|
||||
|
||||
```python Python
|
||||
# January 1, 2023 timestamp
|
||||
january_2023_timestamp = 1672531200 # Unix timestamp for 2023-01-01 00:00:00 UTC
|
||||
|
||||
client.add("Important historical information", user_id="user1", timestamp=january_2023_timestamp)
|
||||
```
|
||||
|
||||
```javascript JavaScript
|
||||
// January 1, 2023 timestamp
|
||||
const january2023Timestamp = 1672531200; // Unix timestamp for 2023-01-01 00:00:00 UTC
|
||||
|
||||
client.add("Important historical information", { user_id: "user1", timestamp: january2023Timestamp })
|
||||
.then(response => console.log(response))
|
||||
.catch(error => console.error(error));
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
If you have any questions, please feel free to reach out to us using one of the following methods:
|
||||
|
||||
<Snippet file="get-help.mdx" />
|
||||
@@ -5,6 +5,8 @@ icon: "webhook"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
## Overview
|
||||
|
||||
Webhooks enable real-time notifications for memory events in your Mem0 project. Webhooks are configured at the project level, meaning each webhook is tied to a specific project and receives events solely from that project. You can configure webhooks to send HTTP POST requests to your specified URLs whenever memories are created, updated, or deleted.
|
||||
|
||||
@@ -3,6 +3,8 @@ title: Overview
|
||||
description: How to integrate Mem0 into other frameworks
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Mem0 seamlessly integrates with popular AI frameworks and tools to enhance your LLM-based applications with persistent memory capabilities. By integrating Mem0, your applications benefit from:
|
||||
|
||||
- Enhanced context management across multiple frameworks
|
||||
@@ -303,4 +305,21 @@ Here are the available integrations for Mem0:
|
||||
>
|
||||
Build autonomous agents with memory using Agno framework.
|
||||
</Card>
|
||||
<Card
|
||||
title="Keywords AI"
|
||||
icon={
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.07513 1.1863C9.21663 1.07722 9.39144 1.01009 9.56624 1.01009C9.83261 1.01009 10.0823 1.12756 10.2405 1.33734L15.0101 7.4964V12.4136L16.4335 13.8401C16.7582 14.1673 16.7582 14.7043 16.4335 15.0316C16.1089 15.3588 15.5762 15.3588 15.2515 15.0316L13.3453 13.1016V8.07538L8.92529 2.36944V2.36105C8.64228 2.00024 8.70887 1.4716 9.07513 1.1863ZM18.976 14.4133C18.8344 14.3778 18.7003 14.3042 18.5894 14.1925L16.9163 12.5059C16.7249 12.3129 16.6416 12.0528 16.6749 11.8094V6.88385H16.6499L11.8553 0.691225C11.7282 0.529117 11.6716 0.333133 11.6803 0.140562C11.134 0.0481292 10.5726 0 10 0C4.47715 0 0 4.47715 0 10C0 15.5228 4.47715 20 10 20C13.9387 20 17.3456 17.7229 18.976 14.4133Z" fill="currentColor"></path>
|
||||
</svg>
|
||||
}
|
||||
href="/integrations/keywords"
|
||||
>
|
||||
Build AI applications with persistent memory and comprehensive LLM observability.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -1,8 +1,9 @@
|
||||
---
|
||||
title: Agno
|
||||
---
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Integrate [**Mem0**](https://github.com/mem0ai/mem0) with [Agno](https://github.com/agno-ai/agno), a Python framework for building autonomous agents. This integration enables Agno agents to access persistent memory across conversations, enhancing context retention and personalization.
|
||||
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.
|
||||
|
||||
## Overview
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
Build conversational AI agents with memory capabilities. This integration combines AutoGen for creating AI agents with Mem0 for memory management, enabling context-aware and personalized interactions.
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
## Overview
|
||||
|
||||
In this guide, we'll explore an example of creating a conversational AI system with memory:
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: CrewAI
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Build an AI system that combines CrewAI's agent-based architecture with Mem0's memory capabilities. This integration enables persistent memory across agent interactions and personalized task execution based on user history.
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Dify
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
# Integrating Mem0 with Dify AI
|
||||
|
||||
Mem0 brings a robust memory layer to Dify AI, empowering your AI agents with persistent conversation storage and retrieval capabilities. With Mem0, your Dify applications gain the ability to recall past interactions and maintain context, ensuring more natural and insightful conversations.
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: ElevenLabs
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Create voice-based conversational AI agents with memory capabilities by integrating ElevenLabs and Mem0. This integration enables persistent, context-aware voice interactions that remember past conversations.
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Flowise
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
The [**Mem0 Memory**](https://github.com/mem0ai/mem0) integration with [Flowise](https://github.com/FlowiseAI/Flowise) enables persistent memory capabilities for your AI chatflows. [Flowise](https://flowiseai.com/) is an open-source low-code tool for developers to build customized LLM orchestration flows & AI agents using a drag & drop interface.
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
---
|
||||
title: Keywords AI
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Build AI applications with persistent memory and comprehensive LLM observability by integrating Mem0 with Keywords AI.
|
||||
|
||||
## Overview
|
||||
|
||||
Mem0 is a self-improving memory layer for LLM applications, enabling personalized AI experiences that save costs and delight users. Keywords AI provides complete LLM observability.
|
||||
|
||||
Combining Mem0 with Keywords AI allows you to:
|
||||
1. Add persistent memory to your AI applications
|
||||
2. Track interactions across sessions
|
||||
3. Monitor memory usage and retrieval with Keywords AI observability
|
||||
4. Optimize token usage and reduce costs
|
||||
|
||||
<Note>
|
||||
You can get your Mem0 API key, user_id, and org_id from the [Mem0 dashboard](https://app.mem0.ai/). These are required for proper integration.
|
||||
</Note>
|
||||
|
||||
## Setup and Configuration
|
||||
|
||||
Install the necessary libraries:
|
||||
|
||||
```bash
|
||||
pip install mem0 keywordsai-sdk
|
||||
```
|
||||
|
||||
Set up your environment variables:
|
||||
|
||||
```python
|
||||
import os
|
||||
|
||||
# Set your API keys
|
||||
os.environ["MEM0_API_KEY"] = "your-mem0-api-key"
|
||||
os.environ["KEYWORDSAI_API_KEY"] = "your-keywords-api-key"
|
||||
os.environ["KEYWORDSAI_BASE_URL"] = "https://api.keywordsai.co/api/"
|
||||
```
|
||||
|
||||
## Basic Integration Example
|
||||
|
||||
Here's a simple example of using Mem0 with Keywords AI:
|
||||
|
||||
```python
|
||||
from mem0 import Memory
|
||||
import os
|
||||
|
||||
# Configuration
|
||||
api_key = os.getenv("MEM0_API_KEY")
|
||||
keywordsai_api_key = os.getenv("KEYWORDSAI_API_KEY")
|
||||
base_url = os.getenv("KEYWORDSAI_BASE_URL") # "https://api.keywordsai.co/api/"
|
||||
|
||||
# Set up Mem0 with Keywords AI as the LLM provider
|
||||
config = {
|
||||
"llm": {
|
||||
"provider": "openai",
|
||||
"config": {
|
||||
"model": "gpt-4o-mini",
|
||||
"temperature": 0.0,
|
||||
"api_key": keywordsai_api_key,
|
||||
"openai_base_url": base_url,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
# Initialize Memory
|
||||
memory = Memory.from_config(config_dict=config)
|
||||
|
||||
# Add a memory
|
||||
result = memory.add(
|
||||
"I like to take long walks on weekends.",
|
||||
user_id="alice",
|
||||
metadata={"category": "hobbies"},
|
||||
)
|
||||
|
||||
print(result)
|
||||
```
|
||||
|
||||
## Advanced Integration with OpenAI SDK
|
||||
|
||||
For more advanced use cases, you can integrate Keywords AI with Mem0 through the OpenAI SDK:
|
||||
|
||||
```python
|
||||
from openai import OpenAI
|
||||
import os
|
||||
import json
|
||||
|
||||
# Initialize client
|
||||
client = OpenAI(
|
||||
api_key=os.environ.get("KEYWORDSAI_API_KEY"),
|
||||
base_url=os.environ.get("KEYWORDSAI_BASE_URL"),
|
||||
)
|
||||
|
||||
# Sample conversation messages
|
||||
messages = [
|
||||
{"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
|
||||
{"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."},
|
||||
{"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."},
|
||||
{"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."}
|
||||
]
|
||||
|
||||
# Add memory and generate a response
|
||||
response = client.chat.completions.create(
|
||||
model="openai/gpt-4o",
|
||||
messages=messages,
|
||||
extra_body={
|
||||
"mem0_params": {
|
||||
"user_id": "test_user",
|
||||
"org_id": "org_1",
|
||||
"api_key": os.environ.get("MEM0_API_KEY"),
|
||||
"add_memories": {
|
||||
"messages": messages,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
print(json.dumps(response.model_dump(), indent=4))
|
||||
```
|
||||
|
||||
For detailed information on this integration, refer to the official [Keywords AI Mem0 integration documentation](https://docs.keywordsai.co/integration/development-frameworks/mem0).
|
||||
|
||||
## Key Features
|
||||
|
||||
1. **Memory Integration**: Store and retrieve relevant information from past interactions
|
||||
2. **LLM Observability**: Track memory usage and retrieval patterns with Keywords AI
|
||||
3. **Session Persistence**: Maintain context across multiple user sessions
|
||||
4. **Cost Optimization**: Reduce token usage through efficient memory retrieval
|
||||
|
||||
## Conclusion
|
||||
|
||||
Integrating Mem0 with Keywords AI provides a powerful combination for building AI applications with persistent memory and comprehensive observability. This integration enables more personalized user experiences while providing insights into your application's memory usage.
|
||||
|
||||
## Help
|
||||
|
||||
For more information on using Mem0 and Keywords AI together, refer to:
|
||||
- [Mem0 Documentation](https://docs.mem0.ai)
|
||||
- [Keywords AI Documentation](https://docs.keywordsai.co)
|
||||
|
||||
<Snippet file="get-help.mdx" />
|
||||
@@ -3,6 +3,8 @@ title: Langchain Tools
|
||||
description: 'Integrate Mem0 with LangChain tools to enable AI agents to store, search, and manage memories through structured interfaces'
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
## Overview
|
||||
|
||||
Mem0 provides a suite of tools for storing, searching, and retrieving memories, enabling agents to maintain context and learn from past interactions. The tools are built as Langchain tools, making them easily integrable with any AI agent implementation.
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Langchain
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Build a personalized Travel Agent AI using LangChain for conversation flow and Mem0 for memory retention. This integration enables context-aware and efficient travel planning experiences.
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: LangGraph
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Build a personalized Customer Support AI Agent using LangGraph for conversation flow and Mem0 for memory retention. This integration enables context-aware and efficient support experiences.
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Livekit
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
This guide demonstrates how to create a memory-enabled voice assistant using LiveKit, Deepgram, OpenAI, and Mem0, focusing on creating an intelligent, context-aware travel planning agent.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: LlamaIndex
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
LlamaIndex supports Mem0 as a [memory store](https://llamahub.ai/l/memory/llama-index-memory-mem0). In this guide, we'll show you how to use it.
|
||||
|
||||
<Note type="info">
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: MCP Server
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
## Integrating mem0 as an MCP Server in Cursor
|
||||
[mem0](https://github.com/mem0ai/mem0-mcp) is a powerful tool designed to enhance AI-driven workflows, particularly in code generation and contextual memory. In this guide, we'll walk through integrating mem0 as an **MCP (Model Context Protocol) server** within [Cursor](https://cursor.sh/), an AI-powered coding editor.
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: MultiOn
|
||||
---
|
||||
|
||||
<Snippet file="paper-release.mdx" />
|
||||
|
||||
Build a personal browser agent that remembers user preferences and automates web tasks. It integrates Mem0 for memory management with MultiOn for executing browser actions, enabling personalized and efficient web interactions.
|
||||
|
||||
## Overview
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user