v3.1 + 批次0: 智能回复重构基线 - ApprovalMatcher + 关键词降级 + 文档速修 + v4.0任务书面化

This commit is contained in:
Simon
2026-07-17 23:08:59 +08:00
parent 5a77a89ab1
commit 3ed86d5fb3
181 changed files with 19738 additions and 2655 deletions
+16
View File
@@ -458,14 +458,26 @@ class AIService:
if parsed:
# JSON 解析成功
text = parsed.get("text", "")
# ★ 防御性类型保护:Dify 可能返回 text 为对象/列表而非字符串
# 当 text 为 dict/list 时,直接传给前端会显示 [object Object]
if not isinstance(text, str):
text = json.dumps(text, ensure_ascii=False) if text else ""
logger.warning(f"Dify 返回 text 非 String 类型,已转换为 JSON 字符串: {text[:80]}...")
action = parsed.get("action")
options = parsed.get("options")
diagnosis_stage = parsed.get("diagnosis_stage")
# ★ 调试日志:打印 action 对象的详细内容
logger.info(f"[DEBUG] Dify action 对象: {action}")
if action:
logger.info(f"[DEBUG] action.approval_type = {action.get('approval_type')}")
hit = self._check_knowledge_hit(text) if text else False
logger.info(
f"Dify 原生 structured 返回: hit={hit}, "
f"text_len={len(text)}, "
f"text_preview={text[:60]}, "
f"has_action={action is not None}, "
f"has_options={options is not None}, "
f"diagnosis_stage={diagnosis_stage}, "
@@ -556,6 +568,10 @@ class AIService:
if parsed:
# JSON 解析成功
text = parsed.get("text", "")
# ★ 防御性类型保护(与原生路径一致)
if not isinstance(text, str):
text = json.dumps(text, ensure_ascii=False) if text else ""
logger.warning(f"Dify 代理返回 text 非 String 类型,已转换: {text[:80]}...")
action = parsed.get("action")
options = parsed.get("options")
# Phase 6A: 提取诊断阶段(diagnosis_stage