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
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
"""聊天输入归一:与 memoir 规则共用,配置独立。"""
|
|
|
|
from unittest.mock import patch
|
|
|
|
from app.features.conversation.input_normalize import (
|
|
apply_conversation_input_rules,
|
|
normalize_chat_input_for_agent,
|
|
)
|
|
|
|
|
|
def test_apply_conversation_rules_matches_memoir_mei_kanshang() -> None:
|
|
raw = "我去试镜了 美看上我 张伟"
|
|
assert "没看上我" in apply_conversation_input_rules(raw)
|
|
|
|
|
|
def test_normalize_chat_rules_mode() -> None:
|
|
raw = "美看上我"
|
|
with patch("app.features.conversation.input_normalize.settings") as m:
|
|
m.chat_input_normalize_enabled = True
|
|
m.chat_input_normalize_mode = "rules"
|
|
m.chat_input_normalize_llm_max_tokens = 512
|
|
m.chat_input_normalize_llm_max_input_chars = 8000
|
|
assert normalize_chat_input_for_agent(raw, llm=None) == "没看上我"
|
|
|
|
|
|
def test_normalize_chat_disabled_returns_raw() -> None:
|
|
raw = "美看上我"
|
|
with patch("app.features.conversation.input_normalize.settings") as m:
|
|
m.chat_input_normalize_enabled = False
|
|
m.chat_input_normalize_mode = "rules"
|
|
assert normalize_chat_input_for_agent(raw, llm=None) == raw
|
|
|
|
|
|
def test_normalize_chat_off_mode() -> None:
|
|
raw = "美看上我"
|
|
with patch("app.features.conversation.input_normalize.settings") as m:
|
|
m.chat_input_normalize_enabled = True
|
|
m.chat_input_normalize_mode = "off"
|
|
assert normalize_chat_input_for_agent(raw, llm=None) == raw
|