Install
openclaw skills install knowledge-base-001Convert documents to Markdown, auto-classify, extract keywords, and enable local keyword and vector search in a private knowledge base.
openclaw skills install knowledge-base-001⚠️ 首次使用必读 ⚠️
安装后请立即运行初始化脚本,自动安装依赖并创建知识库目录:
python3 scripts/init.py不运行这一步,后续所有功能都无法正常工作。
一套完整的文档转换与知识库管理工具。自动将各类文档转换为 Markdown,按内容智能分类,建立本地可检索的私人知识库。
首次使用自动检测并安装依赖,无需手动配置:
markitdown[all] — 文档转换核心jieba — 中文分词chromadb — 向量检索(首次使用向量功能时自动安装)如需手动安装:
pip install markitdown[all] jieba chromadb
~/.openclaw/workspace/knowledge-base/
├── .index.json # 索引文件(元数据、关键词、摘要)
├── .chroma/ # 向量数据库
├── 学术论文/
├── 技术文档/
├── 工作资料/
├── 读书笔记/
├── 项目文档/
├── 参考资料/
└── 未分类/
python3 scripts/init.py
python3 scripts/kb_cli.py ingest <文件路径>
python3 scripts/kb_cli.py ingest ~/Downloads/report.pdf --category 技术文档
递归扫描整个目录,批量导入所有支持的文件:
python3 scripts/batch_ingest.py ~/Documents/我的资料
python3 scripts/batch_ingest.py ~/Downloads --no-recursive # 不递归子目录
python3 scripts/batch_ingest.py ~/Documents --dry-run # 预览模式
持续监控 /tmp/openclaw/ 目录(飞书文件下载目录),新文件自动导入:
# 单次扫描
python3 scripts/auto_ingest.py --once
# 持续监控(每30秒扫描一次)
python3 scripts/auto_ingest.py --watch
# 自定义间隔
python3 scripts/auto_ingest.py --watch --interval 60
飞书自动导入建议: 将监控脚本加入 OpenClaw cron job,每分钟自动扫描:
{
"schedule": { "kind": "cron", "expr": "*/1 * * * *" },
"payload": {
"kind": "agentTurn",
"message": "运行 python3 ~/.openclaw/workspace/skills/knowledge-base/scripts/auto_ingest.py --once"
},
"sessionTarget": "isolated"
}
python3 scripts/kb_cli.py search "机器学习"
python3 scripts/kb_cli.py search "神经网络" --category 技术文档 --limit 5
首次使用前需构建索引:
# 构建/更新向量索引
python3 scripts/vector_index.py build
# 强制重建
python3 scripts/vector_index.py build --force
# 语义搜索
python3 scripts/vector_index.py search "深度学习在图像处理中的应用"
python3 scripts/vector_index.py search "神经网络" --limit 5 --category 技术文档
python3 scripts/kb_cli.py list
python3 scripts/kb_cli.py list --category 学术论文
python3 scripts/kb_cli.py get <doc_id>
python3 scripts/kb_cli.py delete <doc_id>
python3 scripts/kb_cli.py add-category "旅行攻略"
python3 scripts/kb_cli.py stats
当用户通过飞书发送文件时:
/tmp/openclaw/ 目录python3 scripts/auto_ingest.py --once 自动导入feishu_im_bot_image 下载后手动导入示例 workflow:
用户发送 PDF → 检测到文件消息
→ 调用 feishu_im_bot_image 下载到 /tmp/openclaw/
→ 调用 auto_ingest.py 导入知识库
→ 返回导入结果给用户
| 脚本 | 功能 |
|---|---|
scripts/kb_manager.py | 核心引擎(Python API) |
scripts/kb_cli.py | 单文件操作 CLI |
scripts/batch_ingest.py | 批量导入 |
scripts/auto_ingest.py | 自动监控导入 |
scripts/vector_index.py | 向量索引与语义搜索 |
scripts/init.py | 初始化与依赖安装 |
MIT