fix: avoid duplicate greeting reply and improve fallback text
Some checks failed
Mark stale issues and pull requests / stale (push) Has been cancelled
Pre-commit / run (ubuntu-latest) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_en (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.12) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_zh (ubuntu-latest, 3.10) (push) Has been cancelled

This commit is contained in:
2026-03-03 14:44:54 +08:00
parent 77391daf77
commit c6200fd64d

View File

@@ -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(