fix: 修复 kbs-text 系统数据结构兼容性问题

问题描述:
- kbs-text 系统的所有评估指标评分异常(检索上下文数量为 0)
- kbs-excel 系统工作正常
- 根本原因是数据结构差异导致检索上下文提取失败

技术细节:
- kbs-text: {question_id, response: {data: [{fileSource}]}}
- kbs-excel: {question_id, data: [{fileSource}]}

修复内容:
1. 修改 extract_retrieved_contexts 方法
   - 增加对 kbs-text 数据格式的兼容处理
   - 当顶层没有 data 键时,尝试从 response.data 获取

2. 修改 convert_to_ragas_format 方法
   - 增加对 kbs-text 数据格式的兼容处理
   - 确保能正确提取问题和答案内容

验证结果:
- kbs-text 检索上下文数量:0 -> 12 ✅
- kbs-text response 长度:0 -> 449 ✅
- kbs-excel 兼容性保持正常 ✅

影响范围:
- src/transformers/data_converter.py (94-136, 182-211)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
hughhuangandClaude Sonnet 4.5 committed 2026-01-08 10:57:19 +08:00
1 parent 76c0bf1d73
commit 1f08977ca7
2 files changed
+25

No files matched your search

+7
View File
@@ -16,6 +16,12 @@
## ✅ 最近完成(2026-01-08)
### Bug 修复 🐛
- [x] 修复 kbs-text 系统检索上下文提取失败的问题
- [x] 增强数据转换器对多种数据格式的兼容性
- [x] 修复 `extract_retrieved_contexts` 方法支持 kbs-text 结构
- [x] 修复 `convert_to_ragas_format` 方法支持 kbs-text 结构
### 功能扩展 🎯
- [x] 实现 answer_correctness 单独评估功能
- [x] 实现评估结果合并功能
@@ -302,6 +308,7 @@
- [x] Embeddings 与阿里云 DashScope API 兼容性问题
- [x] AnswerCorrectness 指标初始化问题
- [x] Windows 控制台编码问题(通过 UTF-8 设置解决)
- [x] kbs-text 系统数据结构兼容性问题(fileSource 字段提取失败)
### 当前状态
- 🟢 无阻塞性问题