feat(regulatory): 增加条件字段LLM复核
This commit is contained in:
@@ -117,6 +117,49 @@ def test_detect_regulatory_condition_keeps_wrapped_product_name(settings, tmp_pa
|
||||
assert candidates["model_spec"]["suggested"] == "24人份/盒"
|
||||
|
||||
|
||||
def test_detect_regulatory_condition_uses_llm_review_for_better_product_name(
|
||||
monkeypatch, 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章 监管信息",
|
||||
)
|
||||
application = tmp_path / "application.txt"
|
||||
application.write_text(
|
||||
"产品名称:呼吸道合胞病毒、肺炎支原体核酸检测试剂盒\n"
|
||||
"型号规格:24人份/盒\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
FileSummaryItem.objects.create(
|
||||
batch=summary,
|
||||
file_index=1,
|
||||
directory_level="1. 监管信息 / 1.2 申请表",
|
||||
file_name="申请表.txt",
|
||||
file_type="txt",
|
||||
relative_path="1.监管信息/申请表.txt",
|
||||
storage_path=str(application),
|
||||
)
|
||||
|
||||
monkeypatch.setattr(
|
||||
"review_agent.regulatory_review.services.llm_review.generate_completion",
|
||||
lambda messages, temperature=0.0: json.dumps(
|
||||
{"fields": {"产品名称": "呼吸道合胞病毒、肺炎支原体核酸检测试剂盒 (荧光PCR法)"}},
|
||||
ensure_ascii=False,
|
||||
),
|
||||
)
|
||||
|
||||
candidates = detect_regulatory_condition_candidates(summary)
|
||||
|
||||
assert candidates["product_name"]["suggested"] == "呼吸道合胞病毒、肺炎支原体核酸检测试剂盒 (荧光PCR法)"
|
||||
assert candidates["product_name"]["source"] == "llm"
|
||||
|
||||
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user