"""聊天输入归一:与 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