72 lines
2.9 KiB
Python
72 lines
2.9 KiB
Python
|
|
"""提示词静态断言(同步自上游 ai-kefu tests/test_prompt_static.py)。
|
||
|
|
|
||
|
|
锚点迁移(Task 6): 上游单副本 app/prompts → seed_profiles/<slug>/prompts
|
||
|
|
按租户持有。auto 租户保留上游逐字锚点;jiancai(主线)措辞已演化——例外
|
||
|
|
句/回显句式/禁令是其等价形态。两租户同测,任何一侧缺件都红;断言语义
|
||
|
|
不变: 例外句在场(教学多点复述)、好例在场、extractor 门控声明在场。
|
||
|
|
"""
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
PROMPTS = Path(__file__).resolve().parent.parent / "seed_profiles"
|
||
|
|
|
||
|
|
# 各租户锚点: exception=(例外句, 最少出现次数), good_example 与小写比较
|
||
|
|
ANCHORS = {
|
||
|
|
# 主线措辞: "**唯一例外**:系统提供的补全号码原文" + 确认/回显各节的
|
||
|
|
# 机制复述("按系统提醒回显补全后的完整号码请客户确认");好例句式与
|
||
|
|
# wall.json cc_templates.echo 同源("— is that right?")
|
||
|
|
"jiancai": {
|
||
|
|
"exception": ("唯一例外", 1),
|
||
|
|
"exception_extra": ("回显补全后的完整号码", 4),
|
||
|
|
"forbidden": "客户自己的号码也不回显",
|
||
|
|
"good_example": "is that right",
|
||
|
|
"gate": "仅当客户在回应号码确认时填写",
|
||
|
|
},
|
||
|
|
# 上游原句(L47/L67/L127/L170 四处),auto 出厂未随主线演化
|
||
|
|
"auto": {
|
||
|
|
"exception": ("唯一例外:系统提醒提供的补全号", 4),
|
||
|
|
"exception_extra": None,
|
||
|
|
"forbidden": "禁止回显任何其他号码",
|
||
|
|
"good_example": "is this your full number",
|
||
|
|
"gate": "仅当客户消息是对号码确认的回应",
|
||
|
|
},
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
def _read(tenant, name):
|
||
|
|
return (PROMPTS / tenant / "prompts" / name).read_text(encoding="utf-8")
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.parametrize("tenant", ["jiancai", "auto"])
|
||
|
|
def test_system_md_exception_clauses_present(tenant):
|
||
|
|
src = _read(tenant, "system.md")
|
||
|
|
a = ANCHORS[tenant]
|
||
|
|
needle, floor = a["exception"]
|
||
|
|
assert src.count(needle) >= floor, f"{tenant}: 例外句缺失/少于 {floor} 处"
|
||
|
|
if a["exception_extra"]:
|
||
|
|
needle2, floor2 = a["exception_extra"]
|
||
|
|
assert src.count(needle2) >= floor2, \
|
||
|
|
f"{tenant}: 例外机制复述少于 {floor2} 处"
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.parametrize("tenant", ["jiancai", "auto"])
|
||
|
|
def test_system_md_echo_examples_present(tenant):
|
||
|
|
src = _read(tenant, "system.md").lower()
|
||
|
|
assert ANCHORS[tenant]["good_example"] in src, \
|
||
|
|
f"{tenant}: 回显好例句式缺失(应与提醒模板同源)"
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.parametrize("tenant", ["jiancai", "auto"])
|
||
|
|
def test_system_md_forbidden_clause_present(tenant):
|
||
|
|
src = _read(tenant, "system.md")
|
||
|
|
assert ANCHORS[tenant]["forbidden"] in src, \
|
||
|
|
f"{tenant}: 禁止回显其他号码条款缺失"
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.parametrize("tenant", ["jiancai", "auto"])
|
||
|
|
def test_extractor_md_cc_reply_declared_with_gate(tenant):
|
||
|
|
src = _read(tenant, "extractor.md")
|
||
|
|
assert "cc_reply" in src and "affirm" in src
|
||
|
|
assert ANCHORS[tenant]["gate"] in src, f"{tenant}: 双门控第一道门声明缺失"
|