feat: 提示词回显确认语义+语言规则放开+extractor cc_reply
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -91,3 +91,14 @@ def test_evaluator_positive_signals_are_bonus_not_required():
|
||||
def test_evaluator_interested_example_mentions_rounds():
|
||||
# interested 示例补"聊了几轮后"(轮次语境)
|
||||
assert "聊了几轮后" in EVALUATOR_PROMPT
|
||||
|
||||
|
||||
# ---- Task 5(spec §2/§4b): extractor cc_reply 单轮答语分类 ----
|
||||
def test_extractor_cc_reply_field_and_double_gating():
|
||||
"""cc_reply 可选字段说明 + 双门控声明(提示词侧; Python 侧等待态门控在
|
||||
conversation._cc_round_end)——防止对无关问题的 yes 被误当号码确认。"""
|
||||
assert "cc_reply" in EXTRACTOR_PROMPT
|
||||
assert '{"affirm": true}' in EXTRACTOR_PROMPT
|
||||
assert '{"affirm": false, "country": "Egypt"}' in EXTRACTOR_PROMPT
|
||||
assert "仅当客户在回应号码确认时填写" in EXTRACTOR_PROMPT # 双门控声明
|
||||
assert "自由文本国名" in EXTRACTOR_PROMPT # country 中英皆可
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
"""Task 4(spec §4.1, 2026-10-08): system.md 双要+国家代码话术静态断言。
|
||||
"""Task 5(spec §4b-1/2/5 + 计划 Step 3b, 2026-10-08): system.md 回显确认语义
|
||||
+ 语言规则放开静态断言。
|
||||
|
||||
- test_system_md_dual_contact_wording: 七处话术落盘(§4.1-1~7 关键锚点)
|
||||
- test_system_md_contains_verbatim_note_bodies: 同源断言(Task 3 质量审查
|
||||
Issue 5)——conversation.py 四个逐字注入常量的正文必须逐字出现在
|
||||
system.md: 两处"逐字指令"若各自漂移,GLM 会混合输出两种措辞。
|
||||
- test_system_md_dual_contact_wording: 双要+首轮带码话术锚点(§4.1 仍有效部分;
|
||||
追问句锚点随 4b-6 拆除而移除)
|
||||
- test_system_md_echo_exception_in_all_prohibitions: 禁令例外句全量改写为
|
||||
回显补全语义(grep 计数 ≥5, 按命中计数而非固定清单)
|
||||
- test_system_md_red_line_carries_system_number_exception: :56 零号码红线
|
||||
唯一例外(高权重锚②——不改则 GLM 拒写号、确认句墙轮轮整段替换)
|
||||
- test_system_md_template_list_contains_echo_sentence: :7 模板句清单成员
|
||||
追问句→回显确认句(高权重锚①)
|
||||
- test_system_md_language_rule_relaxed: 语言规则放开(Step 3b, 需求方确认)
|
||||
- test_system_md_echo_good_bad_examples: 好差示例回显组+自编号差例(§4b-2)
|
||||
- test_system_md_contains_verbatim_echo_bodies: 同源断言迁移——回显句以
|
||||
样例号 format 后逐字在场(与 reminder/墙三方同源)
|
||||
- test_system_md_pseudo_echo_bad_example: 伪回显差例(掩码样例)保留
|
||||
"""
|
||||
|
||||
|
||||
@@ -27,33 +37,67 @@ def _note_body(note: str) -> str:
|
||||
|
||||
def test_system_md_dual_contact_wording():
|
||||
src = _read_system_md()
|
||||
assert "with the country code" in src # §4.1-1
|
||||
assert "formal quotation PDF" in src and "轻补" in src # §4.1-2/3
|
||||
assert "send the full number with the country code" in src # §4.1-4
|
||||
assert src.count("国家代码") >= 2 # 好差示例
|
||||
assert "已在手的渠道" in src and "缺失渠道" in src # §4.1-6
|
||||
assert "国家代码追问句" in src and "邮箱轻补句" in src # §4.1-7 模板句枚举
|
||||
assert "with the country code" in src # 首轮带码话术
|
||||
assert "formal quotation PDF" in src and "轻补" in src # 邮箱轻补
|
||||
assert src.count("国家代码") >= 2
|
||||
assert "已在手的渠道" in src and "缺失渠道" in src
|
||||
assert "邮箱轻补句" in src # 模板句枚举
|
||||
|
||||
|
||||
def test_system_md_contains_verbatim_note_bodies():
|
||||
"""Step 5b 同源断言: 四常量正文逐字在 system.md(防两处逐字指令漂移)。"""
|
||||
from app.services.conversation import (
|
||||
_CC_NOTE_EN, _CC_NOTE_ZH, _EMAIL_NOTE_EN, _EMAIL_NOTE_ZH)
|
||||
def test_system_md_echo_exception_in_all_prohibitions():
|
||||
"""spec §4b-1: 禁令例外句(语言规则/红线尾/对话流程/提醒配合/注意, grep
|
||||
全量命中)从"可请客户重发完整号一次"改写为按系统提醒回显补全语义。"""
|
||||
src = _read_system_md()
|
||||
for note in (_CC_NOTE_EN, _CC_NOTE_ZH, _EMAIL_NOTE_EN, _EMAIL_NOTE_ZH):
|
||||
assert src.count("回显补全后的完整号码") >= 5
|
||||
assert "重发完整号一次" not in src # 旧措辞清零
|
||||
|
||||
|
||||
def test_system_md_red_line_carries_system_number_exception():
|
||||
""":56 红线"绝不能在回复里写出号码"加唯一例外=系统提供的补全号原文。"""
|
||||
src = _read_system_md()
|
||||
assert ("回复中不能出现任何电话号码或邮箱地址(**唯一例外**:系统提供的"
|
||||
"补全号码原文,逐字照抄)") in src
|
||||
|
||||
|
||||
def test_system_md_template_list_contains_echo_sentence():
|
||||
"""spec 4b-6: :7 模板句清单成员——国家代码追问句改为回显确认句。"""
|
||||
src = _read_system_md()
|
||||
assert "回显确认句" in src
|
||||
assert "号码由系统提醒提供,逐字照抄" in src
|
||||
assert "国家代码追问句" not in src # 旧成员清零
|
||||
|
||||
|
||||
def test_system_md_language_rule_relaxed():
|
||||
"""计划 Step 3b(需求方确认 2026-10-08): 模板句跟随客户语言自然表达,
|
||||
"绝不翻译成第三种语言"整段拆除。"""
|
||||
src = _read_system_md()
|
||||
assert "跟随客户语言自然表达" in src
|
||||
assert "绝不翻译成" not in src
|
||||
|
||||
|
||||
def test_system_md_echo_good_bad_examples():
|
||||
"""spec §4b-2: 好差示例裸号组改回显确认形态 + 新增自编号/改数字差例。"""
|
||||
src = _read_system_md()
|
||||
assert "直接\"Got it, thanks!\"收下" in src # 差: 裸号直接收下
|
||||
assert "自己拼号码" in src and "改动数字都是违规" in src # 差: 自编/改数字
|
||||
assert "一个数字都不改" in src # 好: 逐字照抄
|
||||
|
||||
|
||||
def test_system_md_contains_verbatim_echo_bodies():
|
||||
"""同源断言迁移(Task 5/4b-6): 回显确认句以统一样例号 format 后逐字在
|
||||
system.md(引导策略节+好差示例——两处逐字指令漂移会让 GLM 混合输出两种
|
||||
措辞); 邮箱轻补句正文沿用旧断言。"""
|
||||
from app.services.conversation import (
|
||||
_CC_ECHO_EN, _CC_ECHO_ZH, _EMAIL_NOTE_EN, _EMAIL_NOTE_ZH)
|
||||
src = _read_system_md()
|
||||
sample = "+966 50 123 4567"
|
||||
assert _CC_ECHO_EN.format(intl=sample) in src
|
||||
assert _CC_ECHO_ZH.format(intl=sample) in src
|
||||
for note in (_EMAIL_NOTE_EN, _EMAIL_NOTE_ZH):
|
||||
body = _note_body(note)
|
||||
assert body in src, body[:40]
|
||||
|
||||
|
||||
def test_system_md_cc_reask_exception_in_all_five_prohibitions():
|
||||
"""生产验收场景①修复: 五处禁令例外全部扩围——号码缺国家代码时可请客户
|
||||
重发完整号一次。CC 追问是对已在手渠道的重发请求,原先只豁免缺失渠道,
|
||||
GLM 会视其为禁令压制对象(裸号追问两轮一致被压制即此根因)。"""
|
||||
src = _read_system_md()
|
||||
# 五节(语言规则/红线/对话流程/提醒配合/注意)逐一扩围,措辞锚点各落一次
|
||||
assert src.count("重发完整号一次") >= 5
|
||||
|
||||
|
||||
def test_system_md_pseudo_echo_bad_example():
|
||||
"""生产验收 r2 实测伪回显: AI 把 +966 5x xxx xxxx 掩码样例当客户号码回显
|
||||
("Got your number +966 5x xxx xxxx")——好差示例补组钉死禁止。"""
|
||||
|
||||
Reference in New Issue
Block a user