fix(regulatory): 修复无标签文档适用条件回显

This commit is contained in:
2026-06-07 12:29:22 +08:00
parent 1b4a10b5ba
commit 9e27c4c684
8 changed files with 305 additions and 8 deletions

View File

@@ -161,6 +161,61 @@ def test_detect_regulatory_condition_uses_llm_review_for_better_product_name(
assert candidates["product_name"]["source"] == "llm"
def test_detect_regulatory_condition_infers_fields_from_unlabeled_attachment_text(
settings, tmp_path, django_user_model
):
settings.MEDIA_ROOT = tmp_path
user = django_user_model.objects.create_user(username="owner", password="pass")
conversation = Conversation.objects.create(user=user, title="会话")
summary = FileSummaryBatch.objects.create(
conversation=conversation,
user=user,
batch_no="FS-COND",
status=FileSummaryBatch.Status.SUCCESS,
product_name="第1章 监管信息",
)
standard_list = tmp_path / "standard_list.txt"
standard_list.write_text(
"国家药品监督管理局:\n"
"卡尤迪生物科技宜兴有限公司申请境内第三类体外诊断试剂"
"呼吸道合胞病毒、肺炎支原体核酸检测试剂盒荧光PCR法产品注册。\n",
encoding="utf-8",
)
product_list = tmp_path / "product_list.txt"
product_list.write_text(
"呼吸道合胞病毒、肺炎支原体核酸检测试剂盒\n"
"荧光PCR法\n"
"产品的包装规格\n"
"24人份/盒、48人份/盒\n",
encoding="utf-8",
)
FileSummaryItem.objects.create(
batch=summary,
file_index=1,
directory_level="第1章 监管信息",
file_name="符合标准的清单.txt",
file_type="txt",
relative_path="第1章 监管信息/符合标准的清单.txt",
storage_path=str(standard_list),
)
FileSummaryItem.objects.create(
batch=summary,
file_index=2,
directory_level="第1章 监管信息",
file_name="产品列表.txt",
file_type="txt",
relative_path="第1章 监管信息/产品列表.txt",
storage_path=str(product_list),
)
candidates = detect_regulatory_condition_candidates(summary)
assert candidates["product_category"]["suggested"] == "体外诊断试剂"
assert candidates["product_name"]["suggested"] == "呼吸道合胞病毒、肺炎支原体核酸检测试剂盒荧光PCR法"
assert candidates["product_name"]["source"] == "inferred"
assert candidates["model_spec"]["suggested"] == "24人份/盒、48人份/盒"
def test_workflow_pauses_before_rule_scope_until_conditions_confirmed(settings, tmp_path, django_user_model):
settings.MEDIA_ROOT = tmp_path
user = django_user_model.objects.create_user(username="owner", password="pass")