feat: 增强审核智能体页目录与一致性能力卡展示
This commit is contained in:
@@ -87,6 +87,7 @@ def detail(request, conversation_id: str):
|
||||
workspace_summary = _build_workspace_summary(conversation, batch)
|
||||
conversation_context = _build_conversation_context(conversation, batch, workspace_summary)
|
||||
prompt_templates = _build_prompt_templates()
|
||||
analysis_card = _build_analysis_card(result, conversation)
|
||||
export_card = _build_export_card(result, conversation)
|
||||
risk_card = _build_risk_card(result, conversation)
|
||||
notify_card = _build_notify_card(result, conversation)
|
||||
@@ -109,6 +110,7 @@ def detail(request, conversation_id: str):
|
||||
"workspace_summary": workspace_summary,
|
||||
"conversation_context": conversation_context,
|
||||
"prompt_templates": prompt_templates,
|
||||
"analysis_card": analysis_card,
|
||||
"upload_form": upload_form,
|
||||
"export_card": export_card,
|
||||
"risk_card": risk_card,
|
||||
@@ -274,6 +276,55 @@ def _build_prompt_templates() -> list[str]:
|
||||
]
|
||||
|
||||
|
||||
def _build_analysis_card(result: AgentResult | None, conversation: Conversation) -> dict:
|
||||
structured_output = {}
|
||||
if result and result.structured_output:
|
||||
structured_output = result.structured_output
|
||||
else:
|
||||
structured_output = (conversation.latest_summary or {}).get("structured_output") or {}
|
||||
output_type = structured_output.get("output_type")
|
||||
if output_type == "registration_overview_report":
|
||||
return {
|
||||
"kind": "overview",
|
||||
"title": "目录汇总能力卡",
|
||||
"summary": structured_output.get("product_name", ""),
|
||||
"stats": [
|
||||
{"label": "资料文件数", "value": structured_output.get("file_count", 0)},
|
||||
{"label": "总页数", "value": structured_output.get("total_page_count", 0)},
|
||||
],
|
||||
"items": structured_output.get("chapter_summary") or [],
|
||||
"warnings": structured_output.get("warnings") or [],
|
||||
}
|
||||
if output_type == "registration_completeness_report":
|
||||
return {
|
||||
"kind": "completeness",
|
||||
"title": "完整性检查能力卡",
|
||||
"summary": structured_output.get("summary", ""),
|
||||
"stats": [{"label": "风险等级", "value": structured_output.get("risk_level", "-")}],
|
||||
"items": structured_output.get("missing_items") or [],
|
||||
"warnings": structured_output.get("misplaced_items") or [],
|
||||
}
|
||||
if output_type == "registration_field_extraction_report":
|
||||
return {
|
||||
"kind": "field_extraction",
|
||||
"title": "字段抽取能力卡",
|
||||
"summary": structured_output.get("summary", ""),
|
||||
"stats": [{"label": "字段数", "value": len(structured_output.get("field_items") or [])}],
|
||||
"items": structured_output.get("field_items") or [],
|
||||
"warnings": structured_output.get("low_confidence_items") or [],
|
||||
}
|
||||
if output_type == "registration_consistency_report":
|
||||
return {
|
||||
"kind": "consistency",
|
||||
"title": "一致性核查能力卡",
|
||||
"summary": structured_output.get("summary", ""),
|
||||
"stats": [{"label": "风险等级", "value": structured_output.get("risk_level", "-")}],
|
||||
"items": structured_output.get("conflict_items") or [],
|
||||
"warnings": structured_output.get("mixed_document_risks") or [],
|
||||
}
|
||||
return {}
|
||||
|
||||
|
||||
def _build_export_card(result: AgentResult | None, conversation: Conversation) -> dict:
|
||||
"""
|
||||
统一组装 Word 导出能力卡上下文。
|
||||
|
||||
Reference in New Issue
Block a user