fix(application-form-fill): 清理填表说明并收窄按钮话术

This commit is contained in:
2026-06-07 20:26:32 +08:00
parent 30bdcdbc9c
commit d640ced748
6 changed files with 96 additions and 4 deletions

View File

@@ -103,6 +103,27 @@ def test_rule_maps_agent_fields_to_manufacturer_company_for_now():
assert values["manufacturer_address"] == "江苏省宜兴经济技术开发区杏里路10号宜兴光电产业园4幢102室"
def test_rule_stops_product_name_before_application_form_instructions():
texts = {
"境内体外诊断试剂注册申请表.docx": "\n".join(
[
"产品名称呼吸道合胞病毒、肺炎支原体核酸检测试剂盒荧光PCR法",
"申请人:",
"卡尤迪生物科技宜兴有限公司",
"国家药品监督管理局",
"填表说明",
"1. 本表依据《体外诊断注册与备案管理办法》制定。",
]
)
}
result = extract_by_rules(texts, _registration_specs())
values = {field["key"]: field["value"] for field in result["fields"]}
assert values["product_name"] == "呼吸道合胞病毒、肺炎支原体核酸检测试剂盒荧光PCR法"
assert "填表说明" not in values["product_name"]
def test_llm_extract_parses_structured_json(monkeypatch):
monkeypatch.setattr(
"review_agent.application_form_fill.services.field_extract.generate_completion",

View File

@@ -41,6 +41,17 @@ def _template(path):
document.save(path)
def _template_with_instructions(path):
document = Document()
table = document.add_table(rows=2, cols=2)
table.rows[0].cells[0].text = "产品名称"
table.rows[1].cells[0].text = "预期用途"
document.add_paragraph("填表说明")
document.add_paragraph("1. 本表依据《体外诊断注册与备案管理办法》制定。")
document.add_paragraph("2. 本表可从国家药品监督管理局网站下载。")
document.save(path)
def test_word_fill_writes_table_rows(tmp_path):
template_path = tmp_path / "template.docx"
output_path = tmp_path / "filled.docx"
@@ -61,6 +72,27 @@ def test_word_fill_writes_table_rows(tmp_path):
assert document.tables[0].rows[1].cells[1].text == "用于体外检测"
def test_word_fill_removes_template_fill_instructions(tmp_path):
template_path = tmp_path / "template.docx"
output_path = tmp_path / "filled.docx"
_template_with_instructions(template_path)
fill_template(
template_path,
output_path,
_spec(),
{
"product_name": MergedField("product_name", "产品名称", "甲胎蛋白检测试剂盒", "说明书.txt", "证据", 0.8),
},
)
document = Document(output_path)
text = "\n".join(paragraph.text for paragraph in document.paragraphs)
assert "填表说明" not in text
assert "本表依据" not in text
assert document.tables[0].rows[0].cells[1].text == "甲胎蛋白检测试剂盒"
def test_word_fill_highlights_conflict_in_docx_xml(tmp_path):
template_path = tmp_path / "template.docx"
output_path = tmp_path / "filled.docx"

View File

@@ -251,6 +251,7 @@ def test_workspace_tool_buttons_fill_default_prompts(client, django_user_model):
assert ">风险预警</button>" not in content
assert 'data-prompt-template="请对当前对话已上传的文件或压缩包自动汇总文件目录' in content
assert 'data-prompt-template="请对当前对话最近成功汇总的注册资料发起 NMPA 法规核查与风险预警' in content
assert 'data-prompt-template="请基于当前对话最近成功汇总的产品资料,自动提取产品关键信息并填入申报文件模板' in content
assert 'data-prompt-template="请基于当前对话最近成功汇总的产品资料,自动提取产品关键信息并填入申报文件模板"' in content
assert "优先生成注册证 Word 和字段来源追溯清单" not in content
assert "bindPromptTemplateButtons" in script
assert "promptInput.value = template" in script