目的地只留地名,货物数量不再用箱型,未成交原因去掉艾特。
口语里逗号后面的品名和包装不再粘在目的地上;件数被抽成箱型时改用件数;群里艾特机器人不记进未成交原因。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1709,7 +1709,7 @@ class AirTextInquiryFlow:
|
||||
sess.phase = "done"
|
||||
sess.allowed = ()
|
||||
self._save(sess)
|
||||
reply(copy.lost_reason_ack(text))
|
||||
reply(copy.lost_reason_ack(str(result.get("lost_reason") or text)))
|
||||
return "done"
|
||||
|
||||
def mark_wait_deal(self, sender_id: str, work_order_no: str) -> None:
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import re
|
||||
from typing import Any, Callable, Optional
|
||||
|
||||
from agent.config import get_settings
|
||||
@@ -22,6 +23,14 @@ EnqueueFn = Callable[..., tuple[bool, str]]
|
||||
_LOST_MARKERS = ("未成交", "没成交", "没有成交", "没做成", "黄了")
|
||||
_QUESTION_TAILS = frozenset({"吗", "呢", "吧", "啊", "呀", "嘛", "?", "?"})
|
||||
_KEEP_REASON_AS_IS = frozenset({"原因不明", "原因不详", "理由不明", "理由不详"})
|
||||
# 群里 @询价小助手 是用来叫醒机器人的,不是未成交原因。
|
||||
_MENTION = re.compile(r"@[^\s,,。.;;::、@]+")
|
||||
|
||||
|
||||
def strip_bot_mentions(text: str) -> str:
|
||||
"""去掉 @某人。原因前后都可能带,去掉后不留空标点。"""
|
||||
cleaned = _MENTION.sub("", text or "")
|
||||
return cleaned.strip(",,。.;;::、 ")
|
||||
|
||||
|
||||
def harvest_inline_lost_reason(text: str) -> str:
|
||||
@@ -56,7 +65,10 @@ def harvest_inline_lost_reason(text: str) -> str:
|
||||
break
|
||||
if rest in _QUESTION_TAILS:
|
||||
return ""
|
||||
return rest.strip()
|
||||
rest = strip_bot_mentions(rest)
|
||||
if rest in _QUESTION_TAILS:
|
||||
return ""
|
||||
return rest
|
||||
|
||||
|
||||
def looks_like_lost_outcome(text: str) -> bool:
|
||||
@@ -211,8 +223,8 @@ def finish_deal_outcome(
|
||||
|
||||
|
||||
def capture_lost_reason(*, ledger: Any, work_order_no: str, reason: str) -> dict[str, Any]:
|
||||
"""把销售下一句写进未成交原因。"""
|
||||
text = (reason or "").strip()
|
||||
"""把销售下一句写进未成交原因。@询价小助手 不是原因。"""
|
||||
text = strip_bot_mentions(reason or "")
|
||||
no = (work_order_no or "").strip()
|
||||
if not no or not text:
|
||||
return {"ok": False, "error": "blank"}
|
||||
@@ -220,6 +232,8 @@ def capture_lost_reason(*, ledger: Any, work_order_no: str, reason: str) -> dict
|
||||
if not callable(patcher):
|
||||
return {"ok": False, "error": "no_patch"}
|
||||
out = patcher(work_order_no=no, lost_reason=text) or {"ok": False}
|
||||
if isinstance(out, dict):
|
||||
out.setdefault("lost_reason", text)
|
||||
if out.get("ok"):
|
||||
from agent.policy.event_exception import clear_wait
|
||||
|
||||
|
||||
@@ -1204,7 +1204,7 @@ def capture_group_lost_reason(
|
||||
sess.phase = "done"
|
||||
sess.allowed = ()
|
||||
flow._save(sess)
|
||||
send_group_text(client, chat_id, copy.lost_reason_ack(text))
|
||||
send_group_text(client, chat_id, copy.lost_reason_ack(str(result.get("lost_reason") or text)))
|
||||
return "done"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user