feat: 结构化输出按官方规范 + 两段式重试 + DeepSeek 复检开关
- 豆包: response_format.json_schema(strict);DeepSeek: 切 Responses API text.format.json_schema (官方 chat/completions 通道不支持 json_schema),不支持时自动降级 json_object([output] schema) - 重试两段式:传输错误 cfg.retries 次;解析失败/空正文有独立 3 次专用重试,仍失败落 parse_fail - 移除三票复核(decide_final/_verify_clean/verify_clean),DeepSeek 单次判定即终稿 - 新增 [run] deepseek_recheck 开关(默认 no=仅豆包初筛;yes=追加 DeepSeek 复检) - GUI 不再覆盖 config 提示词;prompt 相对/前导斜杠路径按 exe 目录解析 - 报表去「票型/复核」列并同步说明;README/config.example.ini 同步 - 测试新增输出格式、重试、开关与提示词路径用例(50 passed)
This commit is contained in:
+3
-34
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""pipeline 模块测试:排序、投票裁决、成本计算、缓存路径。"""
|
||||
"""pipeline 模块测试:排序、成本计算、缓存路径。"""
|
||||
from violation_detector.pipeline import (
|
||||
_cache_path, _cat_num, deepseek_cost, decide_final, natural_key,
|
||||
_cache_path, _cat_num, deepseek_cost, natural_key,
|
||||
)
|
||||
|
||||
|
||||
@@ -19,42 +19,11 @@ def test_natural_key_sort():
|
||||
def test_cat_num():
|
||||
assert _cat_num("12. 侵权 - 其他") == 12
|
||||
assert _cat_num("1. 烟草") == 1
|
||||
# 无编号的结论统一排到最后(无违规/违规不变动分类,不影响裁决)
|
||||
# 无编号的结论统一排到最后(无违规/违规不明不变动分类)
|
||||
assert _cat_num("无违规") == 99
|
||||
assert _cat_num("违规不明") == 99
|
||||
|
||||
|
||||
def test_decide_final_unanimous_clean():
|
||||
final, note = decide_final([R("无违规"), R("无违规"), R("无违规")])
|
||||
assert final["category"] == "无违规"
|
||||
assert "3票一致" in note
|
||||
|
||||
|
||||
def test_decide_final_clean_majority_keeps_but_flags():
|
||||
final, note = decide_final([R("无违规"), R("无违规"), R("12. 侵权 - 除人物外的其他侵权")])
|
||||
assert final["category"] == "无违规"
|
||||
assert "2:1" in note and "人工复核" in note
|
||||
|
||||
|
||||
def test_decide_final_violation_majority_wins():
|
||||
final, note = decide_final(
|
||||
[R("无违规"), R("12. 侵权 - 除人物外的其他侵权"), R("12. 侵权 - 除人物外的其他侵权")])
|
||||
assert final["category"].startswith("12.")
|
||||
assert "人工复核" in note
|
||||
|
||||
|
||||
def test_decide_final_three_way_split_takes_lowest_number():
|
||||
final, note = decide_final([R("无违规"), R("13. 侵权 - 人物相关"), R("5. 负向敏感")])
|
||||
assert final["category"].startswith("5.")
|
||||
assert "从严" in note
|
||||
|
||||
|
||||
def test_decide_final_two_violations_differ_majority_none():
|
||||
# 两张违规票不同、一张无违规:违规方 2 票 > 1,并列取序号最小
|
||||
final, _ = decide_final([R("无违规"), R("13. 侵权 - 人物相关"), R("12. 侵权 - 其他")])
|
||||
assert final["category"].startswith("12.")
|
||||
|
||||
|
||||
def test_deepseek_cost_known_usage():
|
||||
# miss 407 + cached 1792 + completion 2282
|
||||
results = {"a": R("无违规")}
|
||||
|
||||
Reference in New Issue
Block a user