feat: 用 Ragflow 搭建鲜境方案客服

咨询台接 Ragflow 检索与示例知识库,支持追问、判定、引用和留资。

Co-authored-by: haijd <haijd@163.com>
This commit is contained in:
Cursor Agent
2026-09-20 01:08:11 +00:00
co-authored by haijd
parent 9c6afcb61a
commit b7bd830da7
20 changed files with 925 additions and 258 deletions
+21 -8
View File
@@ -59,8 +59,15 @@ def handle_message(session_id: str, message: str) -> dict[str, Any]:
"summary": decision.get("summary"),
"confidence": confidence,
"rule_id": decision.get("rule_id"),
"retrieval_backend": retrieval.backend,
"retrieval_warning": retrieval.warning,
"citations": [
{"id": c.get("id"), "title": c.get("title"), "content": c.get("content")}
{
"id": c.get("id"),
"title": c.get("title"),
"content": c.get("content"),
"score": c.get("score"),
}
for c in retrieval.chunks
],
"slots": dict(session.slots),
@@ -75,18 +82,24 @@ def handle_message(session_id: str, message: str) -> dict[str, Any]:
f"推荐组合:{', '.join(bundle)}",
f"说明:{scheme['summary']}",
f"置信度:{confidence:.0%}",
f"检索:{retrieval.backend}",
]
if retrieval.warning:
lines.append(f"注意:{retrieval.warning}")
if scheme["citations"]:
lines.append("")
lines.append("知识依据(原型检索):")
for c in scheme["citations"][:3]:
lines.append(f"- {c['title']}:{c['content']}")
if need_handoff:
lines.append("")
lines.append("系统建议转人工确认后再对外发送方案。回复「转人工」可进入人工流程。")
lines.append("知识依据:")
for citation in scheme["citations"][:3]:
lines.append(f"- {citation['title']}:{citation['content']}")
else:
lines.append("")
lines.append("可继续补充约束,或回复「转人工」交给销售。")
lines.append("知识库未给出可引用片段,请勿把上述组合当成已确认报价。")
if need_handoff or retrieval.warning:
lines.append("")
lines.append("建议转人工确认后再发给客户。可在右侧留下称呼和电话。")
else:
lines.append("")
lines.append("可继续补充约束,或留下联系方式转销售确认。")
reply = "\n".join(lines)
return _finish(session, reply, scheme=scheme, need_handoff=need_handoff)