feat(regulatory): 为核查流程增加LLM复核记录
This commit is contained in:
@@ -121,6 +121,7 @@ def test_detect_regulatory_condition_uses_llm_review_for_better_product_name(
|
||||
monkeypatch, settings, tmp_path, django_user_model
|
||||
):
|
||||
settings.MEDIA_ROOT = tmp_path
|
||||
settings.REGULATORY_LLM_REVIEW_ALLOW_TEST_CALLS = True
|
||||
user = django_user_model.objects.create_user(username="owner", password="pass")
|
||||
conversation = Conversation.objects.create(user=user, title="会话")
|
||||
summary = FileSummaryBatch.objects.create(
|
||||
|
||||
@@ -263,3 +263,50 @@ def test_workflow_generates_issues_exports_and_assistant_summary(settings, tmp_p
|
||||
assert RegulatoryArtifact.objects.filter(batch=batch, name="text_extract_status.json").exists()
|
||||
assert RegulatoryArtifact.objects.filter(batch=batch, name="rag_result_json.json").exists()
|
||||
assert conversation.messages.filter(role=Message.Role.ASSISTANT, content__contains="已完成 NMPA").exists()
|
||||
|
||||
|
||||
def test_workflow_records_llm_review_artifacts_for_review_nodes(
|
||||
monkeypatch, settings, tmp_path, django_user_model
|
||||
):
|
||||
settings.MEDIA_ROOT = tmp_path
|
||||
settings.REGULATORY_REVIEW_ASYNC = False
|
||||
settings.REGULATORY_RAG_CHROMA_PATH = tmp_path / "missing-rag"
|
||||
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-OK",
|
||||
status=FileSummaryBatch.Status.SUCCESS,
|
||||
)
|
||||
ifu_path = tmp_path / "ifu.txt"
|
||||
ifu_path.write_text("产品名称:甲胎蛋白检测试剂盒\n型号规格:20人份/盒", encoding="utf-8")
|
||||
FileSummaryItem.objects.create(
|
||||
batch=summary,
|
||||
file_index=1,
|
||||
file_name="说明书.txt",
|
||||
file_type="txt",
|
||||
relative_path="说明书.txt",
|
||||
storage_path=str(ifu_path),
|
||||
)
|
||||
batch = create_regulatory_review_batch(
|
||||
conversation=conversation,
|
||||
user=user,
|
||||
source_summary_batch=summary,
|
||||
)
|
||||
batch.condition_json = {"confirmed": True, "confirmed_conditions": {"product_category": "体外诊断试剂"}}
|
||||
batch.save(update_fields=["condition_json"])
|
||||
|
||||
monkeypatch.setattr(
|
||||
"review_agent.regulatory_review.workflow.review_workflow_payload",
|
||||
lambda stage, payload: {"status": "success", "stage": stage, "result": {"reviewed": True}, "error_message": ""},
|
||||
)
|
||||
|
||||
start_regulatory_review_workflow(batch, async_run=False)
|
||||
|
||||
artifact_names = set(RegulatoryArtifact.objects.filter(batch=batch).values_list("name", flat=True))
|
||||
assert "llm_review_completeness_check.json" in artifact_names
|
||||
assert "llm_review_text_extract.json" in artifact_names
|
||||
assert "llm_review_structure_check.json" in artifact_names
|
||||
assert "llm_review_consistency_check.json" in artifact_names
|
||||
assert "llm_review_risk_assess.json" in artifact_names
|
||||
|
||||
Reference in New Issue
Block a user