支持多种后端的智能记忆系统,可选择:
text
┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ OpenClaw │ ──> │ RAG Memory │ ──> │ SQLite │
│ (记忆请求) │ │ (技能模块) │ │ (本地 DB) │
└─────────────┘ └──────────────┘ └─────────────┘
text
┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ OpenClaw │ ──> │ RAG Memory │ ──> │ Milvus │
│ (记忆请求) │ │ (技能模块) │ │ (向量存储) │
└─────────────┘ └──────────────┘ └─────────────┘
│
v
┌──────────────┐
│ Ollama │
│ (可选) │
│ 嵌入生成 │
└──────────────┘
bash
# 直接使用,零配置
python -c "from rag_memory import store, search; store('测试记忆')"
bash
# 环境变量配置
export RAG_MEMORY_BACKEND=milvus
export MILVUS_URL=http://localhost:19530
export OLLAMA_URL=http://localhost:11434 # 可选,用于向量搜索
# 安装依赖
pip install pymilvus
bash
RAG_MEMORY_BACKEND=sqlite # sqlite | milvus | chromadb
RAG_MEMORY_SQLITE_DB=./memory.db # SQLite 数据库路径
MILVUS_URL=http://localhost:19530 # Milvus 服务地址
OLLAMA_URL=http://localhost:11434 # Ollama 服务地址(可选)
RAG_MEMORY_COLLECTION=openclaw_memory # 集合名称
RAG_MEMORY_BACKUP_DIR=./memory_backup # 备份目录
最小依赖(SQLite 模式):
bash
pip install requests
完整依赖(Milvus 模式):
bash
pip install requests pymilvus
python
from rag_memory import store, search
# 存储记忆
memory_id = store("今天讨论了 RAG 系统", {"type": "conversation", "topic": "RAG"})
# 搜索记忆
results = search("RAG 系统讨论", top_k=3)
# 删除记忆
from rag_memory import get_memory
get_memory().delete_memory(memory_id)
函数说明参数返回值store()存储记忆content: str, metadata: Dictmemory_id: intsearch()搜索记忆query: str, top_k: intList[Dict]get_memory()获取实例-RAGMemory
json
{
"id": 1,
"content": "今天讨论了 RAG 系统",
"timestamp": "2026-03-18T15:30:00",
"metadata": {
"type": "conversation",
"topic": "RAG"
},
"distance": 0.85 // 仅 Milvus 模式有
}
特性SQLiteMilvus安装难度⭐ 零配置⭐⭐⭐ 需要 Docker向量搜索❌ 不支持✅ 支持搜索方式最近优先语义相似度适用场景个人使用生产环境资源占用低中 - 高
bash
# 仅 Milvus 模式需要
pip install pymilvus
bash
# 检查 Milvus 服务
docker ps | grep milvus
curl http://localhost:19530/v1/version
bash
# 检查 Ollama 服务(可选功能)
curl http://localhost:11434/api/tags
ollama pull bge-m3 # 如需使用
bash
cd /app/skills/rag-memory
tar -czf rag-memory.tar.gz SKILL.md rag_memory.py
rag-memory.tar.gzbash
openclaw skills install rag-memory