finalize medical consultation agent backend

This commit is contained in:
刘金宝
2026-06-03 15:51:46 +08:00
parent 93d9e1c6a5
commit eb43573a44
33 changed files with 1063 additions and 281 deletions
+25
View File
@@ -9,6 +9,7 @@ class ReportAgent:
"score_type": scoring_result.get("score_type", "percentage"),
"total_score": total_score,
"dimension_scores": dimension_scores,
"score_details": self._normalize_score_details(scoring_result.get("score_details", []), dimension_scores),
"errors": self._ensure_list(scoring_result.get("errors")),
"improvement_plan": self._ensure_list(scoring_result.get("improvement_plan")),
"evidence_summary": self._ensure_list(scoring_result.get("evidence_summary")),
@@ -32,6 +33,30 @@ class ReportAgent:
"score": self._safe_float(item.get("score"), 0),
"max_score": self._safe_float(item.get("max_score"), 0),
"comment": str(item.get("comment", "")),
"evidence": self._ensure_list(item.get("evidence")),
"deductions": self._ensure_list(item.get("deductions")),
"improvement": str(item.get("improvement", "")),
}
)
return normalized
def _normalize_score_details(self, raw_details: object, dimension_scores: list[dict]) -> list[dict]:
"""评分明细校验:保留可写入 training_score_detail 的细粒度字段。"""
source = raw_details if isinstance(raw_details, list) and raw_details else dimension_scores
normalized: list[dict] = []
for item in source:
if not isinstance(item, dict):
continue
deductions = self._ensure_list(item.get("deductions"))
normalized.append(
{
"rule_id": item.get("rule_id"),
"dimension": str(item.get("dimension", "综合表现")),
"score": self._safe_float(item.get("score"), 0),
"deducted_reason": str(item.get("deducted_reason") or "".join(str(value) for value in deductions)),
"evidence_message_ids": self._ensure_list(item.get("evidence_message_ids") or item.get("evidence")),
"ai_confidence": self._safe_float(item.get("ai_confidence"), 0.85),
"comment": str(item.get("comment") or item.get("improvement") or ""),
}
)
return normalized