feat: 完成 issue #74 [Ti-1] 报警解释 Prompt 模板与 RAG 接入

This commit is contained in:
2026-08-05 03:39:03 +08:00
parent f6cdc84860
commit fc4ac42007
3 changed files with 75 additions and 6 deletions
@@ -105,6 +105,21 @@ class TestScenariosE2E(unittest.TestCase):
self.assertIn("来源", result.answer)
self.assertEqual(result.route.target, RouteTarget.LOCAL)
def test_explain_alarm_rag_sop_only(self):
"""报警解释 RAG 接入(issue #74):只检索 sop 知识域并回显来源。"""
result = self.runner.explain_alarm("炉温超上限报警怎么处理")
# 演示库 sop 类目(异常处置SOP)应被检索到并随答案溯源
self.assertIn("SOP", result.answer)
def test_explain_alarm_min_score_fallback(self):
"""检索阈值(issue #74):低分视为未命中 → 降级提示人工确认。"""
# 注入高 min_score 配置:正常演示库检索得分低于阈值 → 降级
runner = TiScenarioRunner(alarm_config={
"rag": {"categories": ["sop"], "top_k": 3, "min_score": 99.0},
})
result = runner.explain_alarm("炉温超上限报警怎么处理")
self.assertIn("人工确认", result.answer)
def test_shift_handover(self):
result = self.runner.generate_handover("甲班:生产平稳,炉温正常,无异常事项")
self.assertTrue(result.answer)