Install
openclaw skills install mem-rag-milvus智能记忆系统,支持 SQLite(零配置)和 Milvus(向量搜索)后端。用于存储、检索和管理 AI 助手的记忆,支持语义搜索和自动备份。
openclaw skills install mem-rag-milvus支持多种后端的智能记忆系统,可选择:
┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ OpenClaw │ ──> │ RAG Memory │ ──> │ SQLite │
│ (记忆请求) │ │ (技能模块) │ │ (本地 DB) │
└─────────────┘ └──────────────┘ └─────────────┘
┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ OpenClaw │ ──> │ RAG Memory │ ──> │ Milvus │
│ (记忆请求) │ │ (技能模块) │ │ (向量存储) │
└─────────────┘ └──────────────┘ └─────────────┘
│
v
┌──────────────┐
│ Ollama │
│ (可选) │
│ 嵌入生成 │
└──────────────┘
# 直接使用,零配置
python -c "from rag_memory import store, search; store('测试记忆')"
# 环境变量配置
export RAG_MEMORY_BACKEND=milvus
export MILVUS_URL=http://localhost:19530
export OLLAMA_URL=http://localhost:11434 # 可选,用于向量搜索
# 安装依赖
pip install pymilvus
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 模式):
pip install requests
完整依赖(Milvus 模式):
pip install requests pymilvus
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: Dict | memory_id: int |
search() | 搜索记忆 | query: str, top_k: int | List[Dict] |
get_memory() | 获取实例 | - | RAGMemory |
{
"id": 1,
"content": "今天讨论了 RAG 系统",
"timestamp": "2026-03-18T15:30:00",
"metadata": {
"type": "conversation",
"topic": "RAG"
},
"distance": 0.85 // 仅 Milvus 模式有
}
| 特性 | SQLite | Milvus |
|---|---|---|
| 安装难度 | ⭐ 零配置 | ⭐⭐⭐ 需要 Docker |
| 向量搜索 | ❌ 不支持 | ✅ 支持 |
| 搜索方式 | 最近优先 | 语义相似度 |
| 适用场景 | 个人使用 | 生产环境 |
| 资源占用 | 低 | 中 - 高 |
# 仅 Milvus 模式需要
pip install pymilvus
# 检查 Milvus 服务
docker ps | grep milvus
curl http://localhost:19530/v1/version
# 检查 Ollama 服务(可选功能)
curl http://localhost:11434/api/tags
ollama pull bge-m3 # 如需使用
cd /app/skills/rag-memory
tar -czf rag-memory.tar.gz SKILL.md rag_memory.py
rag-memory.tar.gzopenclaw skills install rag-memory