feat(regulatory): 增加条件字段LLM复核
This commit is contained in:
42
tests/test_regulatory_llm_review.py
Normal file
42
tests/test_regulatory_llm_review.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import json
|
||||
|
||||
from review_agent.regulatory_review.services.llm_review import review_condition_fields
|
||||
|
||||
|
||||
def test_review_condition_fields_selects_more_complete_llm_product_name():
|
||||
def completion(messages, temperature=0.0):
|
||||
return json.dumps(
|
||||
{
|
||||
"fields": {
|
||||
"产品名称": "呼吸道合胞病毒、肺炎支原体核酸检测试剂盒 (荧光PCR法)",
|
||||
"型号规格": "24人份/盒",
|
||||
}
|
||||
},
|
||||
ensure_ascii=False,
|
||||
)
|
||||
|
||||
result = review_condition_fields(
|
||||
text="产品名称:呼吸道合胞病毒、肺炎支原体核酸检测试剂盒\n(荧光PCR法)\n型号规格:24人份/盒",
|
||||
rule_fields={"产品名称": "呼吸道合胞病毒、肺炎支原体核酸检测试剂盒", "型号规格": "24人份/盒"},
|
||||
file_context="申请表.txt",
|
||||
completion_func=completion,
|
||||
)
|
||||
|
||||
assert result["selected_fields"]["产品名称"] == "呼吸道合胞病毒、肺炎支原体核酸检测试剂盒 (荧光PCR法)"
|
||||
assert result["selected_sources"]["产品名称"] == "llm"
|
||||
assert result["selected_sources"]["型号规格"] == "rule"
|
||||
|
||||
|
||||
def test_review_condition_fields_falls_back_when_llm_returns_chapter_title():
|
||||
def completion(messages, temperature=0.0):
|
||||
return json.dumps({"fields": {"产品名称": "第1章 监管信息"}}, ensure_ascii=False)
|
||||
|
||||
result = review_condition_fields(
|
||||
text="产品名称:甲胎蛋白检测试剂盒",
|
||||
rule_fields={"产品名称": "甲胎蛋白检测试剂盒"},
|
||||
file_context="申请表.txt",
|
||||
completion_func=completion,
|
||||
)
|
||||
|
||||
assert result["selected_fields"]["产品名称"] == "甲胎蛋白检测试剂盒"
|
||||
assert result["selected_sources"]["产品名称"] == "rule"
|
||||
Reference in New Issue
Block a user