diff --git a/templates/chat/index.html b/templates/chat/index.html index 6980d90..ed9a7a4 100644 --- a/templates/chat/index.html +++ b/templates/chat/index.html @@ -143,6 +143,16 @@ {% empty %}
  • 当前无目录汇总结果。
  • {% endfor %} + {% elif analysis_card.kind == "completeness" %} + {% for item in analysis_card.items %} +
  • + {{ item.document_name|default:"必交项" }} +
    章节点:{{ item.chapter_code|default:"-" }}
    +
    {{ item.reason|default:"当前资料包未提供该资料。" }}
    +
  • + {% empty %} +
  • 当前无缺失项。
  • + {% endfor %} {% elif analysis_card.kind == "consistency" %} {% for item in analysis_card.items %}
  • @@ -155,8 +165,11 @@ {% elif analysis_card.kind == "field_extraction" %} {% for item in analysis_card.items %}
  • - {{ item.field_name|default:item.name }} -
    {{ item.field_value|default:item.value }}
    + {{ item.field_name|default:"抽取字段" }} +
    {{ item.field_value|default:"-" }}
    + {% if item.source_document %} +
    来源:{{ item.source_document }}
    + {% endif %}
  • {% empty %}
  • 当前无抽取字段。
  • @@ -177,8 +190,15 @@ {% for item in analysis_card.warnings %}
  • {% if analysis_card.kind == "field_extraction" %} - {{ item.field_name|default:item.name|default:"低置信度字段" }} -
    {{ item.field_value|default:item.value|default:item }}
    + {{ item.field_name|default:"低置信度字段" }} +
    {{ item.field_value|default:"-" }}
    + {% if item.source_document %} +
    来源:{{ item.source_document }}
    + {% endif %} + {% elif analysis_card.kind == "completeness" %} + {{ item.document_name|default:"错放项" }} +
    目标章节点:{{ item.chapter_code|default:"-" }}
    +
    当前归类:{{ item.current_location|default:"未识别" }}
    {% else %} {{ item }} {% endif %} diff --git a/tests/test_chat.py b/tests/test_chat.py index a2b08f5..a16b4b9 100644 --- a/tests/test_chat.py +++ b/tests/test_chat.py @@ -466,6 +466,86 @@ def test_chat_page_shows_consistency_card_from_conversation_summary(client, db): assert "high" in content +def test_chat_page_shows_completeness_card_from_conversation_summary(client, db): + batch, conversation = _create_conversation_with_batch() + conversation.latest_summary = { + "structured_output": { + "output_type": "registration_completeness_report", + "summary": "当前资料包仍缺少关键必交项。", + "risk_level": "high", + "missing_items": [ + { + "chapter_code": "CH2", + "document_name": "产品技术要求", + "reason": "当前资料包未发现对应文件", + } + ], + "misplaced_items": [ + { + "chapter_code": "CH4", + "document_name": "研究资料", + "current_location": "CH6", + } + ], + } + } + conversation.save(update_fields=["latest_summary", "updated_at"]) + + response = client.get(reverse("chat:detail", args=[conversation.conversation_id])) + + content = response.content.decode("utf-8") + assert response.status_code == 200 + assert "完整性检查能力卡" in content + assert "当前资料包仍缺少关键必交项" in content + assert "产品技术要求" in content + assert "CH2" in content + assert "当前资料包未发现对应文件" in content + assert "研究资料" in content + assert "当前归类:CH6" in content + + +def test_chat_page_shows_field_extraction_card_from_conversation_summary(client, db): + batch, conversation = _create_conversation_with_batch() + conversation.latest_summary = { + "structured_output": { + "output_type": "registration_field_extraction_report", + "summary": "已完成核心注册字段抽取。", + "field_items": [ + { + "field_name": "产品名称", + "field_value": batch.product_name, + "source_document": "申请表.docx", + }, + { + "field_name": "规格型号", + "field_value": "48T/盒", + "source_document": "产品列表.xlsx", + }, + ], + "low_confidence_items": [ + { + "field_name": "储存条件", + "field_value": "2-8℃", + "source_document": "说明书.docx", + } + ], + } + } + conversation.save(update_fields=["latest_summary", "updated_at"]) + + response = client.get(reverse("chat:detail", args=[conversation.conversation_id])) + + content = response.content.decode("utf-8") + assert response.status_code == 200 + assert "字段抽取能力卡" in content + assert "已完成核心注册字段抽取" in content + assert "产品名称" in content + assert "48T/盒" in content + assert "来源:申请表.docx" in content + assert "储存条件" in content + assert "来源:说明书.docx" in content + + def test_chat_page_blocks_formal_export_when_word_export_node_is_blocked(client, db): batch, conversation = _create_conversation_with_batch() conversation.node_results = [