fix: 规则模式摘要改为结构化生成,不再简单拼接消息原文
This commit is contained in:
+35
-13
@@ -249,19 +249,41 @@ def generate_summary_rule(messages: list[dict]) -> dict:
|
||||
if not objections and stage == "异议处理":
|
||||
objections = ["其他异议"]
|
||||
|
||||
# 摘要文本:取前 5 条和后 3 条消息拼接
|
||||
summary_parts = []
|
||||
for m in messages[:5]:
|
||||
sender = m["sender_display_name"] or "未知"
|
||||
content = m["normalized_content"] or f"[{m['message_type']}]"
|
||||
summary_parts.append(f"{sender}: {content}")
|
||||
if len(messages) > 8:
|
||||
summary_parts.append("...")
|
||||
for m in messages[-3:]:
|
||||
sender = m["sender_display_name"] or "未知"
|
||||
content = m["normalized_content"] or f"[{m['message_type']}]"
|
||||
summary_parts.append(f"{sender}: {content}")
|
||||
summary = " | ".join(summary_parts)
|
||||
# 摘要文本:根据阶段和关键词生成结构化摘要
|
||||
customer_name = messages[0]["sender_display_name"] if messages else "客户"
|
||||
# 提取客户需求关键词
|
||||
needs = []
|
||||
for kw in SYMPTOM_WORDS + ["减肥", "减脂", "瘦身", "体脂", "产后"]:
|
||||
if kw in all_text and kw not in needs:
|
||||
needs.append(kw)
|
||||
needs_str = "、".join(needs[:3]) if needs else "未明确"
|
||||
|
||||
# 判断是否有朋友推荐
|
||||
referred = "朋友推荐" if any(w in all_text for w in ["推荐", "小鹿", "小林", "朋友"]) else "主动咨询"
|
||||
|
||||
# 判断产品线
|
||||
is_diet = any(kw in all_text for kw in ["减肥", "减脂", "瘦身", "B420", "纤益", "代餐", "体脂", "产后减肥"])
|
||||
|
||||
if stage == "成交":
|
||||
# 提取成交产品
|
||||
if "2盒" in all_text or "656" in all_text:
|
||||
deal_detail = "2盒套餐656元" if is_diet else "3盒套餐798元"
|
||||
elif "单盒" in all_text or "328" in all_text:
|
||||
deal_detail = "单盒328元" if is_diet else "单盒298元"
|
||||
elif "6盒" in all_text or "1499" in all_text:
|
||||
deal_detail = "6盒套餐1499元"
|
||||
else:
|
||||
deal_detail = "套餐"
|
||||
summary = f"客户{customer_name}({needs_str}),{referred},经产品介绍和案例展示后认可产品,最终成交{deal_detail}。"
|
||||
elif stage == "异议处理":
|
||||
top_obj = objections[0] if objections else "价格"
|
||||
summary = f"客户{customer_name}({needs_str}),{referred},对产品有一定兴趣但存在{top_obj}方面的顾虑,尚未成交,需持续跟进。"
|
||||
elif stage == "报价":
|
||||
summary = f"客户{customer_name}({needs_str}),{referred},已进入报价阶段,等待客户反馈。"
|
||||
elif stage == "需求发现":
|
||||
summary = f"客户{customer_name}({needs_str}),{referred},正在了解客户具体需求和产品适配度。"
|
||||
else:
|
||||
summary = f"客户{customer_name}({needs_str}),{referred},初步建立联系,尚未深入沟通。"
|
||||
|
||||
# 下一步建议
|
||||
next_action = "继续跟进"
|
||||
|
||||
Reference in New Issue
Block a user