fix(application-form-fill): 过滤申请表噪声冲突内容
This commit is contained in:
@@ -124,6 +124,26 @@ def test_rule_stops_product_name_before_application_form_instructions():
|
||||
assert "填表说明" not in values["product_name"]
|
||||
|
||||
|
||||
def test_rule_ignores_generic_enterprise_name_from_application_form():
|
||||
texts = {
|
||||
"CH1.4 申请表.docx": "\n".join(
|
||||
[
|
||||
"注册人制度\t是 企业名称:否",
|
||||
"优先通道申请 应急通道 同品种首个产品首次申报",
|
||||
"临床试验",
|
||||
"临床试验机构名称: 中国医学科学院北京协和医院、晋中市第一人民医院",
|
||||
"应附资料",
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
result = extract_by_rules(texts, _registration_specs())
|
||||
|
||||
values = {field["key"]: field["value"] for field in result["fields"]}
|
||||
assert "applicant_name" not in values
|
||||
assert "agent_name" not in values
|
||||
|
||||
|
||||
def test_llm_extract_parses_structured_json(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"review_agent.application_form_fill.services.field_extract.generate_completion",
|
||||
|
||||
39
tests/test_application_form_fill_summary.py
Normal file
39
tests/test_application_form_fill_summary.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import pytest
|
||||
|
||||
from review_agent.application_form_fill.services.summary import build_assistant_summary
|
||||
from review_agent.models import ApplicationFormFillBatch, Conversation, FileSummaryBatch
|
||||
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
|
||||
def test_assistant_summary_compacts_long_conflict_values(django_user_model):
|
||||
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-SUMMARY")
|
||||
batch = ApplicationFormFillBatch.objects.create(
|
||||
conversation=conversation,
|
||||
user=user,
|
||||
source_summary_batch=summary,
|
||||
batch_no="AFF-SUMMARY",
|
||||
conflict_summary=[
|
||||
{
|
||||
"field_key": "applicant_name",
|
||||
"field_label": "注册人名称",
|
||||
"selected_value": "卡尤迪生物科技宜兴有限公司",
|
||||
"conflict_values": [
|
||||
{
|
||||
"source_file": "CH1.4 申请表.docx",
|
||||
"value": "否\n临床试验\n临床试验机构名称: 中国医学科学院北京协和医院、晋中市第一人民医院、北京市疾病预防控制中心 临床数据库.zip\n应附资料",
|
||||
}
|
||||
],
|
||||
"handling": "说明书优先,模板内黄底红字高亮",
|
||||
}
|
||||
],
|
||||
)
|
||||
|
||||
content = build_assistant_summary(batch, [])
|
||||
|
||||
assert "临床试验机构名称" in content
|
||||
assert len([line for line in content.splitlines() if "临床试验机构名称" in line][0]) < 220
|
||||
assert "\n临床试验\n" not in content
|
||||
Reference in New Issue
Block a user