Mem0 是一款基于机器学习的智能记忆系统,能够帮助 AI 助手更好地理解用户,提供更精准的个性化服务。Mem0 适用于各种 AI 应用场景,如客户支持、智能家居、智能车载等。
特性
- 多层级记忆: 用户、会话和 AI 代理记忆保留
- 自适应个性化: 基于交互的持续改进
- 开发者友好型 API: 与各种应用程序简单集成
- 跨平台一致性: 跨设备的统一行为
- 托管服务: 无需费心的托管解决方案
安装
# 通过 pip 安装
pip install mem0ai
# 登录 mem0 平台,复制 API Key
https://mem0.dev/pd-api
# 实例化客户端
from mem0 import MemoryClient
client = MemoryClient(api_key="your-api-key")
# 添加个性记忆
messages = [
{"role": "user", "content": "Hi, I'm Alex. I'm a vegetarian and I'm allergic to nuts."},
{"role": "assistant", "content": "Hello Alex! I've noted that you're a vegetarian and have a nut allergy. I'll keep this in mind for any food-related recommendations or discussions."}
]
client.add(messages, user_id="alex")
# 搜索相关记忆
query = "What can I cook for dinner tonight?"
client.search(query, user_id="alex")
# 获取用户相关
user_memories = client.get_all(user_id="alex")