diff --git a/qingjian_cs/app/client.py b/qingjian_cs/app/client.py index 6b5d325..a03773c 100644 --- a/qingjian_cs/app/client.py +++ b/qingjian_cs/app/client.py @@ -316,7 +316,20 @@ class QingjianClient: def _fallback_reply(self, action: str) -> str: if action == "transfer": return "我先给你转人工处理。" - return "我先看看" + if action == "quote": + return "我先给你找找看" + return "你直接说需求就行" + + @staticmethod + def _is_greeting_only(text: str) -> bool: + t = re.sub(r"\s+", "", str(text or "")) + if not t: + return False + greetings = { + "你好", "您好", "在吗", "在不在", "哈喽", "hello", "hi", "嗨", + "有人吗", "在", "在嘛", + } + return t.lower() in greetings def _is_outbound_echo(self, data: dict, msg: str) -> bool: """ @@ -383,6 +396,21 @@ class QingjianClient: "last_reply": self.last_reply_key.get(key, ""), "recent_dialogue": recent_dialogue[-12:], } + # 首条已快速回复“在的”后,纯问候不再重复走AI回复 + if self._is_greeting_only(merged_msg) and self.last_reply_key.get(key) == "在的" and not urls and int(context["pending_images"]) == 0: + activity_event( + self.logger, + "agent_process_skipped", + trace_id=trace_id, + customer_id=context["customer_id"], + reason="greeting_already_replied", + ) + await post_tianwang_callback( + "message_processed", + data, + extra={"trace_id": trace_id, "route": "pre_sales", "action": "noop", "reply": ""}, + ) + return try: rd = context.get("recent_dialogue", []) or [] rd_preview = " | ".join(