65 lines
3.7 KiB
Markdown
65 lines
3.7 KiB
Markdown
|
|
# 复杂场景重构第二阶段 — 交付总结
|
|||
|
|
|
|||
|
|
## TL;DR
|
|||
|
|
P2(上下文压缩) + P3(多轮纠错) 全部开发完成,48/48 单元测试通过,待部署。
|
|||
|
|
|
|||
|
|
## 交付概览
|
|||
|
|
- **交付状态**: ✅ 开发完成,待部署
|
|||
|
|
- **测试通过率**: 48/48 (100%)
|
|||
|
|
- **已知问题数**: 0(预存 TS 类型错误非本次引入)
|
|||
|
|
- **SOP 流程**: PRD → 架构设计 → 代码实现(T01-T05) → QA 测试
|
|||
|
|
|
|||
|
|
## 文件清单
|
|||
|
|
|
|||
|
|
### 新建文件(15个)
|
|||
|
|
|
|||
|
|
**后端(8个)**:
|
|||
|
|
| 文件 | 功能 |
|
|||
|
|
|------|------|
|
|||
|
|
| `backend/app/utils/token_counter.py` | TokenCounter — tiktoken精确计数+字符估算兜底 |
|
|||
|
|
| `backend/app/services/automation/context_compressor.py` | ContextCompressor — 渐进式3级压缩+截断降级 |
|
|||
|
|
| `backend/app/services/automation/snapshot_service.py` | SnapshotService — 快照创建+撤销(限5次)+版本对比 |
|
|||
|
|
| `backend/app/services/automation/correction_service.py` | CorrectionService — 批量更正(原子事务)+依赖检查+版本链 |
|
|||
|
|
| `backend/alembic/versions/049_add_p2_p3_tables.py` | 迁移脚本 — 2新表+2新列 |
|
|||
|
|
| `backend/tests/test_p2_p3.py` | 48个单元测试 |
|
|||
|
|
| `docs/02-产品需求/复杂场景重构第二阶段-增量PRD.md` | PRD文档 |
|
|||
|
|
| `docs/03-技术架构/复杂场景重构第二阶段-架构设计.md` | 架构设计文档 |
|
|||
|
|
|
|||
|
|
**前端(7个)**:
|
|||
|
|
| 文件 | 端 | 功能 |
|
|||
|
|
|------|-----|------|
|
|||
|
|
| `frontend-agent/src/api/automation_p2.ts` | 坐席端 | P2/P3 API 请求封装 |
|
|||
|
|
| `frontend-agent/src/components/automation/DependencyWarning.vue` | 坐席端 | 依赖联动提示 |
|
|||
|
|
| `frontend-agent/src/views/automation/CorrectionHistory.vue` | 坐席端 | 更正历史时间线+撤销 |
|
|||
|
|
| `frontend-agent/src/views/automation/VersionDiff.vue` | 坐席端 | 版本对比+版本链 |
|
|||
|
|
| `frontend-agent/src/views/automation/CompressionLogs.vue` | 坐席端 | 压缩日志表格 |
|
|||
|
|
| `frontend-h5/src/components/automation/CorrectionNotice.vue` | H5 | 更正通知+依赖警告 |
|
|||
|
|
| `frontend-h5/src/components/automation/UndoButton.vue` | H5 | 撤销更正按钮 |
|
|||
|
|
|
|||
|
|
### 修改文件(6个)
|
|||
|
|
| 文件 | 变更 |
|
|||
|
|
|------|------|
|
|||
|
|
| `backend/app/models/automation.py` | +2模型(ContextCompression/InformationSnapshot) +2字段(derived_from/correction_reason) |
|
|||
|
|
| `backend/app/constants.py` | +3错误码(4017-4019) |
|
|||
|
|
| `backend/app/config.py` | +6配置项(压缩阈值/超时/级别/保留轮数/撤销次数等) |
|
|||
|
|
| `backend/app/schemas/automation.py` | +10个P2/P3 Schema |
|
|||
|
|
| `backend/app/api/automation.py` | +6个API端点+import |
|
|||
|
|
| `backend/app/services/automation/__init__.py` | 导出新服务 |
|
|||
|
|
|
|||
|
|
### 新增 API 端点(6个)
|
|||
|
|
| 方法 | 路径 | 功能 |
|
|||
|
|
|------|------|------|
|
|||
|
|
| POST | `/itportal/automation/sessions/{id}/batch-correct` | 批量更正(原子事务) |
|
|||
|
|
| POST | `/itportal/automation/sessions/{id}/undo-correction` | 撤销最近一次更正 |
|
|||
|
|
| GET | `/itportal/automation/sessions/{id}/correction-history` | 更正历史 |
|
|||
|
|
| GET | `/itportal/automation/sessions/{id}/version-chain/{item}` | 版本链 |
|
|||
|
|
| POST | `/itportal/automation/sessions/{id}/version-diff/{item}` | 版本对比 |
|
|||
|
|
| GET | `/itportal/automation/sessions/{id}/compression-logs` | 压缩日志 |
|
|||
|
|
|
|||
|
|
## 用户下一步建议
|
|||
|
|
1. **部署后端**:通过堡垒机上传新增/修改的 `.py` 文件 → 执行迁移 049 → `docker compose up -d backend` 重建容器
|
|||
|
|
2. **部署前端**:坐席端 `npm run build` → 上传 dist → nginx 重启;H5 端同理
|
|||
|
|
3. **安装 tiktoken**:`pip install tiktoken>=0.5.0`(如未安装,TokenCounter 自动降级为字符估算)
|
|||
|
|
4. **企微内实测**:部署后在企微中走一遍 AI 对话,验证上下文压缩和多轮纠错的实际体验
|
|||
|
|
5. **配置调整**:如需调整压缩阈值或撤销次数,修改 `config.py` 或环境变量
|