feat: 会话编排建材化+阿语号码转ASCII+12小时话术跨层同步

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-29 17:59:45 +08:00
parent 874308c099
commit 9caf3c4501
8 changed files with 88 additions and 46 deletions
+13 -11
View File
@@ -27,7 +27,7 @@ from app.services.contact_pipeline import (
logger = logging.getLogger(__name__)
# 职能边界触发词(Task 13.2, 评审#1/#4 修订): 命中即注入红线提醒。精修说明:
# - 裸 "how long"/"多久" 不收(续航类问题常用),英文要求 take/arrive/deliver/ship 邻接,
# - 裸 "how long"/"多久" 不收(规格参数类问题常用),英文要求 take/arrive/deliver/ship 邻接,
# 中文只收 到货/多久能到/交货 等明确交付语境
# - 【评审#1】施压话术本身也触发: 磨价轮("just roughly"/"说个大概")没有价格词,
# 却是最易破防的时刻——压力词单列一组
@@ -38,13 +38,15 @@ BOUNDARY_TRIGGER_RE = re.compile(
r"price|pricing|how\s+much|\bcost\b|discount|cheaper|expensive|\bfee\b|"
r"quote|quotation|shipping\s+(fee|cost|time)|freight|tariff|customs\s+fee|"
r"best\s+offer|any\s+offer|free\s+shipping|"
r"test\s+drive|book(ing)?\s|reserv|arrange|"
r"sample|certificat|\bmoq\b|container\s+loading|"
r"book(ing)?\s|reserv|arrange|"
r"delivery|lead\s+time|arriv|"
r"how\s+long\s+(does|will|would|to).*(take|arriv|deliver|ship)|"
r"roughly|ballpark|just\s+tell|come\s+on|at\s+least\s+(a|some|give)|"
r"budget|预算|价格|价钱|多少钱|报价|优惠|折扣|便宜|贵|划算|"
r"总价|落地|运费|关税|免费|"
r"到货|多久能到|交货|时效|发货|试驾|预约|下单|定金|提车|安排|"
r"到货|多久能到|交货|时效|发货|样品|证书|装柜|起订|"
r"预约|下单|定金|安排|"
r"大概|估个|估一|随便说|说个|求你|求了",
re.IGNORECASE,
)
@@ -101,14 +103,14 @@ class ConversationManager:
await self.db.refresh(conv)
# Conditional whitelist seed of app context into raw_info (red line):
# only when `context` is provided, and only vehicle_name/vehicle_id
# only when `context` is provided, and only product_name/product_id
# mapped to app_* keys. WS path passes no context -> raw_info stays {}.
raw_info: dict = {}
if context:
if context.get("vehicle_name"):
raw_info["app_vehicle_name"] = context["vehicle_name"]
if context.get("vehicle_id"):
raw_info["app_vehicle_id"] = context["vehicle_id"]
if context.get("product_name"):
raw_info["app_product_name"] = context["product_name"]
if context.get("product_id"):
raw_info["app_product_id"] = context["product_id"]
profile = CustomerProfile(conversation_id=conv.id, raw_info=raw_info)
self.db.add(profile)
await self.db.commit()
@@ -554,8 +556,8 @@ class ConversationManager:
if BUDGET_TRIGGER_RE.search(latest_msg or ""):
# 评审#9: 预算求推荐 → 预算路径(推荐+反问+引导),不一刀切要号
boundary_note = (
"⚠️ 职能边界提醒:客户报预算求推荐。推荐车型但绝不复述预算数字、"
"不报车价 → 反问意向车型 → 顺势引导留联系方式。")
"⚠️ 职能边界提醒:客户报预算求推荐。推荐产品方案但绝不复述预算数字、"
"不报价格 → 反问意向产品与需求规格 → 顺势引导留联系方式。")
else:
boundary_note = (
"⚠️ 职能边界提醒:客户正在询问价格/优惠/交付时效/实质安排。绝对禁止"
@@ -590,7 +592,7 @@ class ConversationManager:
else:
contact_note = ("⚠️ 客户正在索要我方联系方式(最高意向信号)。请逐字使用这句指路:"
"\"Just tap the WhatsApp button at the top of this chat — "
"our manager replies fast!\"(邮箱同理指 Email 按钮)。"
"our manager will reply within 12 hours!\"(邮箱同理指 Email 按钮)。"
"绝对禁止口头报出任何号码或邮箱。")
if not raw_info: