Mem0 为大型语言模型提供了一个智能的、自我改进的内存层,从而实现跨应用程序的个性化 AI 体验。
快速上手
Installation 安装
1 |
pip install mem0ai |
基本用法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
from mem0 import Memory # Initialize Mem0 m = Memory() # Store a memory from any unstructured text result = m.add("I am working on improving my tennis skills. Suggest some online courses.", user_id="alice", metadata={"category": "hobbies"}) print(result) # Created memory: Improving her tennis skills. Looking for online suggestions. # Retrieve memories all_memories = m.get_all() print(all_memories) # Search memories related_memories = m.search(query="What are Alice's hobbies?", user_id="alice") print(related_memories) # Update a memory result = m.update(memory_id="m1", data="Likes to play tennis on weekends") print(result) # Get memory history history = m.history(memory_id="m1") print(history) |
核心功能
- Multi-Level Memory: User, Session, and AI Agent memory retention
多级内存:用户、会话和 AI 代理内存保留 - Adaptive Personalization: Continuous improvement based on interactions
自适应个性化:基于交互的持续改进 - Developer-Friendly API: Simple integration into various applications
开发人员友好的 API:轻松集成到各种应用程序中 - Cross-Platform Consistency: Uniform behavior across devices
跨平台一致性:跨设备的统一行为 - Managed Service: Hassle-free hosted solution
托管服务:无忧托管解决方案
文档
有关详细的使用说明和 API 参考,请访问我们的文档 docs.mem0.ai
高级用法
对于生产环境,您可以使用 Qdrant 作为矢量存储:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
from mem0 import Memory config = { "vector_store": { "provider": "qdrant", "config": { "host": "localhost", "port": 6333, } }, } m = Memory.from_config(config) |
github: mem0ai/mem0:个性化 AI 的内存层 — mem0ai/mem0: The memory layer for Personalized AI (github.com)