From e31c447087402131aba989cef5f01a97c8c87e24 Mon Sep 17 00:00:00 2001 From: selfrelease Date: Wed, 15 Jul 2026 12:18:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=84=E5=88=99=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E6=91=98=E8=A6=81=E6=94=B9=E4=B8=BA=E7=BB=93=E6=9E=84=E5=8C=96?= =?UTF-8?q?=E7=94=9F=E6=88=90=EF=BC=8C=E4=B8=8D=E5=86=8D=E7=AE=80=E5=8D=95?= =?UTF-8?q?=E6=8B=BC=E6=8E=A5=E6=B6=88=E6=81=AF=E5=8E=9F=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/ai/analyze.py | 48 +++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/demo/ai/analyze.py b/demo/ai/analyze.py index e1c3c40..303ba05 100644 --- a/demo/ai/analyze.py +++ b/demo/ai/analyze.py @@ -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 = "继续跟进"