diff --git a/qingjian_cs/app/client.py b/qingjian_cs/app/client.py index 42551c6..d0c28ab 100644 --- a/qingjian_cs/app/client.py +++ b/qingjian_cs/app/client.py @@ -91,6 +91,7 @@ class QingjianClient: def _shorten_reply(self, text: str) -> str: max_len = max(8, int(SHORT_REPLY_MAX_CHARS)) t = str(text or "").strip() + t = self._humanize_reply(t) if len(t) <= max_len: return t parts = re.split(r"[。!?!?]", t) @@ -99,6 +100,27 @@ class QingjianClient: head = head[:max_len].rstrip(",,;;:: ") return head or t[:max_len] + @staticmethod + def _humanize_reply(text: str) -> str: + t = str(text or "").strip() + replacements = { + "您好呀": "在的", + "您好,": "在的,", + "您好": "在的", + "很高兴为您服务": "我在呢", + "请问您有什么需求": "你要做啥图", + "请问有什么可以帮您": "你要做啥", + "可以把要做的图发我": "图发我就行", + "请您先完成订单付款": "先拍下付款哈", + "麻烦您先完成付款": "先拍下付款哈", + "我们马上为您处理": "我马上处理", + "我这边": "我这", + } + for k, v in replacements.items(): + t = t.replace(k, v) + t = t.replace("~~", "~") + return t + @staticmethod def _is_invalid_ai_reply(text: str) -> bool: t = str(text or "").strip().lower() diff --git a/qingjian_cs/app/config.py b/qingjian_cs/app/config.py index a69e1f2..e0f4fcf 100644 --- a/qingjian_cs/app/config.py +++ b/qingjian_cs/app/config.py @@ -16,7 +16,7 @@ MESSAGE_DEBOUNCE_SECONDS = int(os.getenv("MESSAGE_DEBOUNCE_SECONDS", "6")) AUTO_QUOTE_WAIT_SECONDS = int(os.getenv("AUTO_QUOTE_WAIT_SECONDS", "18")) AGENT_MAX_ITERS = int(os.getenv("AGENT_MAX_ITERS", "3")) FAST_ROUTE_ENABLED = os.getenv("FAST_ROUTE_ENABLED", "1").strip() in {"1", "true", "True", "yes", "on"} -SHORT_REPLY_MAX_CHARS = int(os.getenv("SHORT_REPLY_MAX_CHARS", "28")) +SHORT_REPLY_MAX_CHARS = int(os.getenv("SHORT_REPLY_MAX_CHARS", "20")) STORE_BACKEND = os.getenv("STORE_BACKEND", "sqlite").strip().lower() STORE_SQLITE_PATH = os.getenv("STORE_SQLITE_PATH", "").strip() diff --git a/qingjian_cs/app/rules.py b/qingjian_cs/app/rules.py index 11e07af..9bac547 100644 --- a/qingjian_cs/app/rules.py +++ b/qingjian_cs/app/rules.py @@ -127,7 +127,7 @@ def rules_prompt() -> str: "10) 尺寸明显超大(如>=2m*2m): 提示需补图/重做边缘, 不要直接承诺一模一样。\n" "11) 店铺差异化: 按 acc_id/persona 口吻回复, 保持真人聊天。\n" "12) 最终输出只允许一个动作, 不能混合。\n" - "13) reply 必须简短: 优先 1 句, 一般不超过 28 个汉字, 禁止长段解释。\n" + "13) reply 必须很短: 1句为主, 不超过20字, 口语化, 不要客服官话和AI腔。\n" "输出格式:\n" '{"action":"reply|quote|transfer|noop","reply":"","transfer_msg":"","quote_mode":"flush_pending|analyze_current_or_recent|collect_only","reason":""}' )