feat: system.md双要话术+国家代码引导+四处禁令改写(防自锁)+同源断言
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
"""Task 4(spec §4.1, 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 会混合输出两种措辞。
|
||||
"""
|
||||
|
||||
|
||||
def _read_system_md() -> str:
|
||||
with open("app/prompts/system.md", encoding="utf-8") as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
def _note_body(note: str) -> str:
|
||||
"""从注入常量提取 AI 逐字复述的正文(剥"⚠️ 轻补指引"系统指令外壳)。
|
||||
|
||||
常量形态: 外壳说明 + 请逐字使用这句:"正文" + 尾注。外壳含"留邮箱"等
|
||||
渠道词,会误触再索要墙的中文模式——正文才是 AI 真正说出口的部分,
|
||||
同源断言与过墙断言都以正文为准。"""
|
||||
marker = "请逐字使用这句:\""
|
||||
assert marker in note, note[:40]
|
||||
body = note.split(marker, 1)[1].split("\"", 1)[0]
|
||||
assert body, note[:40]
|
||||
return body
|
||||
|
||||
|
||||
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 模板句枚举
|
||||
|
||||
|
||||
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)
|
||||
src = _read_system_md()
|
||||
for note in (_CC_NOTE_EN, _CC_NOTE_ZH, _EMAIL_NOTE_EN, _EMAIL_NOTE_ZH):
|
||||
body = _note_body(note)
|
||||
assert body in src, body[:40]
|
||||
Reference in New Issue
Block a user