feat: 完成 issue #133 对话助手增强版(引用溯源/路由分级/DLP 拦截,直连推理服务)
This commit is contained in:
@@ -9,11 +9,39 @@
|
||||
web/chat/
|
||||
├── chat_api.py 对话后端 API(http.server):场景分发 + 统一 JSON
|
||||
├── chat_widget.html 前端对话组件(内联 HTML/CSS/JS,深色主题对齐驾驶舱)
|
||||
├── assistant.html 增强版对话页(#133:引用溯源/路由分级/DLP 拦截反馈)
|
||||
├── assistant.css 增强版样式
|
||||
├── assistant.js 增强版逻辑(直连推理服务 /v1/chat/completions)
|
||||
├── citations.json RAG 引用语料(scripts/build_citations.py 编译产物)
|
||||
├── scripts/
|
||||
│ └── build_citations.py 模板知识库文档 → 引用语料编译脚本
|
||||
├── tests/
|
||||
│ └── test_chat_api.py 场景分发 / 端点 / 错误处理测试
|
||||
└── README.md
|
||||
```
|
||||
|
||||
## 增强版对话页(issue #133 / PRD 5.4)
|
||||
|
||||
`assistant.html` 在 chat_widget 雏形上完善并直连已部署推理服务
|
||||
(`http://39.101.182.167:30800`,OpenAI 兼容):
|
||||
|
||||
- **消息流 + 元信息**:每条回答带路由分级 / 模型 / 耗时;
|
||||
- **RAG 引用溯源**(PRD 5.4 强制):`citations.json`(由
|
||||
`python web/chat/scripts/build_citations.py` 从 `templates/*/rag-kb/documents/`
|
||||
编译)关键词检索,回答下方列出「文档 + 章节 + 摘要」引用;未命中显式标注无引用;
|
||||
- **路由分级提示**:镜像 `core/llm-gateway/router.py`——敏感/核心 → 本地
|
||||
(数据不出厂),通用/脱敏 → 云端,DLP 命中 → 拦截(fail-closed);
|
||||
- **DLP 拦截反馈**:镜像 `dlp.py` 的 `DLP_DEFAULT_RULES`(身份证/手机号/邮箱/
|
||||
IPv4/访问密钥/密钥键值对/配方敏感词),命中即阻止外发并展示命中规则,
|
||||
可选择「转本地模型处理」;
|
||||
- **报警解释**(PRD 场景A):severity + 点位结构化输入 → 「原因 + 处置建议」,
|
||||
P0 告警附「需值班长确认」提示(PRD 高利害人工确认);
|
||||
- **交接班报告**(PRD 场景C):按 `handover_brief.ti.yaml` 章节模板
|
||||
(生产概况/异常事项/安全注意事项/能耗/待办)生成,耗时展示(目标 ≤ 2 分钟)。
|
||||
|
||||
运行:`cd web/chat && python -m http.server 8082`,打开
|
||||
`http://127.0.0.1:8082/assistant.html`(Chrome / Edge 最新两版)。
|
||||
|
||||
## 快速运行
|
||||
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user