Files
DronePlanning/tools/rag/README.md
2026-02-20 23:04:09 +08:00

63 lines
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# RAG 工具说明
该目录负责知识构建与向量入库。
## 目录结构
```text
tools/rag/
├── map/ # 原始地图数据
├── knowledge_base/
│ ├── location/ # 地点知识(可选分目录)
│ ├── pattern/ # 模式知识(任务模板)
│ ├── rules/ # 规则知识
│ └── *.ndjson
├── vector_store/ # Chroma 持久化目录
├── build_knowledge_base.py # 从 map 构建 ndjson
└── ingest.py # 入库到 Chroma多集合 + 兼容集合)
```
## 运行前准备
```bash
cd /home/huangfukk/DronePlanning
source backend_service/venv/bin/activate
export ORIN_IP="localhost"
```
并确保 embedding 服务可用(默认 `8090`
```bash
curl -s http://localhost:8090/v1/embeddings \
-H "Content-Type: application/json" \
-d '{"input":["test"]}'
```
## 完整流程(可直接执行)
```bash
cd /home/huangfukk/DronePlanning
source backend_service/venv/bin/activate
# 1) 由 map 构建知识文本
python tools/rag/build_knowledge_base.py
# 2) 入库
python tools/rag/ingest.py
```
## 入库结果
`ingest.py` 会同时写入:
- 兼容集合:`drone_docs`
- 新集合:`location_kb``pattern_kb``rules_kb`
并在 metadata 中写入 `kb_type`,支持检索时按知识域筛选。
## 常见问题
- **Chroma 初始化异常**:先确认使用的是项目 venv再检查 `tools/rag/vector_store/` 是否损坏(备份后重建)。
- **连接 embedding 失败**:检查 `ORIN_IP`、端口 8090、以及模型服务是否已启动。