fix(application-form-fill): 过滤申请表噪声冲突内容

This commit is contained in:
2026-06-07 20:34:24 +08:00
parent d640ced748
commit 003ff59268
4 changed files with 81 additions and 6 deletions

View 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