Chat 访谈 - 新增 persona 系统(default / warm_listener / curious_guide)与 background_voice 语气层 - 回复长度由 compute_reply_plan 统一决策(brief / standard / expanded),融合信息密度启发式 - 输入净稿(input_normalize):编排层可选 rules/llm 归一用户口语后再喂模型与记忆检索 - 记忆证据注入:按用户话检索 memory evidence 并注入 prompt Memoir 回忆录 - 口述归一(oral_normalize):segment 原文保留,story 管线取派生净稿作叙事输入 - segment 入队批次门闸:累计字数 + 最长等待秒数,减少零碎提交 - fidelity_check / prompts / narrative_agent 微调 - Alembic 0005:清理跨章节 story 外键 Infra - Dockerfile 加入 ffmpeg - pyproject.toml 新增依赖并同步 uv.lock - .env.example / .env.production 补全新配置项 Tests - 新增 test_background_voice、test_chat_input_normalize、test_experience_regressions - 扩展 test_interview_prompts、test_interview_reply_length、test_story_route_oral_invariant Made-with: Cursor
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
"""职业文本推断 background_voice(干部/军队)。"""
|
||
|
||
from app.agents.chat.background_voice import (
|
||
infer_background_voice,
|
||
normalize_background_voice,
|
||
)
|
||
|
||
|
||
def test_infer_military_before_cadre() -> None:
|
||
assert infer_background_voice("机关文职干部") == "military"
|
||
|
||
|
||
def test_infer_military_keywords() -> None:
|
||
assert infer_background_voice("退伍军人") == "military"
|
||
assert infer_background_voice("陆军某部") == "military"
|
||
|
||
|
||
def test_infer_cadre_keywords() -> None:
|
||
assert infer_background_voice("公务员") == "cadre"
|
||
assert infer_background_voice("某局科长") == "cadre"
|
||
|
||
|
||
def test_infer_default() -> None:
|
||
assert infer_background_voice(None) == "default"
|
||
assert infer_background_voice("") == "default"
|
||
assert infer_background_voice("中学教师") == "default"
|
||
|
||
|
||
def test_normalize_accepts_enum_strings() -> None:
|
||
assert normalize_background_voice("military") == "military"
|
||
assert normalize_background_voice("cadre") == "cadre"
|
||
|
||
|
||
def test_narrative_editor_system_prompt_appends_voice() -> None:
|
||
from app.agents.memoir.prompts import get_narrative_editor_system_prompt
|
||
|
||
base = get_narrative_editor_system_prompt("default")
|
||
mil = get_narrative_editor_system_prompt("military")
|
||
assert len(mil) > len(base)
|
||
assert "背景文体(军队" in mil
|