style: 统一审核智能体状态展示口径
This commit is contained in:
@@ -32,3 +32,15 @@ class Conversation(models.Model):
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.title
|
||||
|
||||
def get_task_status_display_text(self) -> str:
|
||||
"""返回会话阶段的中文展示文案。"""
|
||||
return {
|
||||
self.STATUS_PENDING: "处理中",
|
||||
self.STATUS_PROCESSING: "处理中",
|
||||
self.STATUS_COMPLETED: "已完成",
|
||||
self.STATUS_REVIEW_REQUIRED: "待复核",
|
||||
self.STATUS_BLOCKED: "已阻断",
|
||||
self.STATUS_FAILED: "失败",
|
||||
"success": "已完成",
|
||||
}.get(self.task_status, self.task_status)
|
||||
|
||||
@@ -15,6 +15,38 @@ from .export_service import generate_registration_export, update_conversation_wi
|
||||
from .forms import ChatForm, ConversationUploadForm
|
||||
from .models import Conversation
|
||||
|
||||
RISK_LEVEL_DISPLAY = {
|
||||
"high": "高",
|
||||
"medium": "中",
|
||||
"low": "低",
|
||||
}
|
||||
|
||||
PASS_STATUS_DISPLAY = {
|
||||
"blocked": "已阻断",
|
||||
"failed": "失败",
|
||||
"review_required": "待复核",
|
||||
"manual_review": "待复核",
|
||||
"completed": "已完成",
|
||||
"passed": "已完成",
|
||||
}
|
||||
|
||||
EXPORT_STATUS_DISPLAY = {
|
||||
"completed": "已完成",
|
||||
"draft_only": "待复核",
|
||||
"review_required": "待复核",
|
||||
"manual_review": "待复核",
|
||||
"blocked": "已阻断",
|
||||
"failed": "失败",
|
||||
"processing": "处理中",
|
||||
"pending": "处理中",
|
||||
}
|
||||
|
||||
NOTIFY_MESSAGE_STATUS_DISPLAY = {
|
||||
"sent": "已发送",
|
||||
"failed": "失败",
|
||||
"pending": "处理中",
|
||||
}
|
||||
|
||||
|
||||
def index(request):
|
||||
conversations = Conversation.objects.all()
|
||||
@@ -264,7 +296,7 @@ def _build_conversation_context(
|
||||
"batch_id": conversation.batch_id,
|
||||
"product_name": conversation.product_name,
|
||||
"workflow_type": batch.workflow_type if batch else "registration",
|
||||
"task_status": conversation.task_status,
|
||||
"task_status": conversation.get_task_status_display_text(),
|
||||
"highest_risk_level": workspace_summary.get("highest_risk_level", "-"),
|
||||
"export_allowed": workspace_summary.get("export_allowed", "-"),
|
||||
}
|
||||
@@ -327,7 +359,7 @@ def _build_analysis_card(result: AgentResult | None, conversation: Conversation)
|
||||
"kind": "completeness",
|
||||
"title": "完整性检查能力卡",
|
||||
"summary": structured_output.get("summary", ""),
|
||||
"stats": [{"label": "风险等级", "value": structured_output.get("risk_level", "-")}],
|
||||
"stats": [{"label": "风险等级", "value": _get_risk_level_display_text(structured_output.get("risk_level", "-"))}],
|
||||
"items": structured_output.get("missing_items") or [],
|
||||
"warnings": structured_output.get("misplaced_items") or [],
|
||||
}
|
||||
@@ -345,7 +377,7 @@ def _build_analysis_card(result: AgentResult | None, conversation: Conversation)
|
||||
"kind": "consistency",
|
||||
"title": "一致性核查能力卡",
|
||||
"summary": structured_output.get("summary", ""),
|
||||
"stats": [{"label": "风险等级", "value": structured_output.get("risk_level", "-")}],
|
||||
"stats": [{"label": "风险等级", "value": _get_risk_level_display_text(structured_output.get("risk_level", "-"))}],
|
||||
"items": structured_output.get("conflict_items") or [],
|
||||
"warnings": structured_output.get("mixed_document_risks") or [],
|
||||
}
|
||||
@@ -368,7 +400,7 @@ def _build_export_card(result: AgentResult | None, conversation: Conversation) -
|
||||
return {
|
||||
"template_name": structured_output.get("template_name", ""),
|
||||
"template_version": structured_output.get("template_version", ""),
|
||||
"export_status": structured_output.get("export_status", ""),
|
||||
"export_status": _get_export_status_display_text(structured_output.get("export_status", "")),
|
||||
"filled_fields": structured_output.get("filled_fields") or [],
|
||||
"blocked_fields": structured_output.get("blocked_fields") or [],
|
||||
"download_url": structured_output.get("download_url", ""),
|
||||
@@ -385,8 +417,10 @@ def _build_risk_card(result: AgentResult | None, conversation: Conversation) ->
|
||||
return {}
|
||||
return {
|
||||
"summary": structured_output.get("summary", ""),
|
||||
"highest_risk_level": structured_output.get("highest_risk_level", ""),
|
||||
"pass_status": structured_output.get("pass_status", ""),
|
||||
"highest_risk_level": _get_risk_level_display_text(
|
||||
structured_output.get("highest_risk_level", "")
|
||||
),
|
||||
"pass_status": _get_pass_status_display_text(structured_output.get("pass_status", "")),
|
||||
"manual_review_items": structured_output.get("manual_review_items") or [],
|
||||
"risk_items": structured_output.get("risk_items") or [],
|
||||
"owner_roles": structured_output.get("owner_roles") or [],
|
||||
@@ -418,12 +452,28 @@ def _build_notify_card(result: AgentResult | None, conversation: Conversation) -
|
||||
return {
|
||||
"notify_reason": notify_reason,
|
||||
"mentioned_users": mentioned_users,
|
||||
"message_status": message_status,
|
||||
"message_status": _get_notify_message_status_display_text(message_status),
|
||||
"web_detail_url": web_detail_url,
|
||||
"owners": owners,
|
||||
}
|
||||
|
||||
|
||||
def _get_risk_level_display_text(level: str) -> str:
|
||||
return RISK_LEVEL_DISPLAY.get(level, level)
|
||||
|
||||
|
||||
def _get_pass_status_display_text(status: str) -> str:
|
||||
return PASS_STATUS_DISPLAY.get(status, status)
|
||||
|
||||
|
||||
def _get_export_status_display_text(status: str) -> str:
|
||||
return EXPORT_STATUS_DISPLAY.get(status, status)
|
||||
|
||||
|
||||
def _get_notify_message_status_display_text(status: str) -> str:
|
||||
return NOTIFY_MESSAGE_STATUS_DISPLAY.get(status, status)
|
||||
|
||||
|
||||
def _apply_agent_result_to_conversation(conversation: Conversation, result: AgentResult) -> None:
|
||||
conversation.task_status = result.status
|
||||
if result.node_results:
|
||||
|
||||
Reference in New Issue
Block a user