feat(threshold): Implement customer loss threshold configuration and notification system

- Added `ThresholdRepository` for managing customer loss threshold configurations and notifications.
- Introduced `threshold_service` to handle loss threshold alerts based on customer portfolio performance.
- Enhanced `customer_prompts` to include new intent for querying product net values.
- Updated `customer_service` to integrate new threshold alert functionality into existing workflows.
- Implemented `sanitize_postprocess` for improved compliance handling in customer interactions.
- Enhanced course documentation to reflect updates in advisor training modules and interactive elements.

This update significantly improves the customer experience by providing proactive loss threshold notifications and enhancing the overall service framework.
This commit is contained in:
2026-09-10 10:57:40 +08:00
parent 6f222f1c56
commit 4b8e11c9bd
102 changed files with 4054 additions and 445 deletions
@@ -4,8 +4,8 @@
<h1 class="module-title animate-in">tool → llm → guard<br>群聊走一遍</h1>
<p class="module-lead animate-in">
顾问线 LangGraph 只有三个业务节点(加 START/END):
<span class="term" data-definition="tool 节点 = 根据用户消息关键词匹配 Tool 名,调 run_tool 查库并落 agent_tool_call 留痕。">tool</span>
→ llm → guard。比客户 14 节点图短,但<strong>归属校验在 tool_service.run_tool 里</strong>,和客户线铁律口径一致。
<span class="term" data-definition="tool 节点 = 根据用户消息关键词匹配 Tool 名,调 对话 Tool 编排(tool_service.py)run_tool 查库并落 agent_tool_call 留痕。">tool</span>
→ llm → guard。比客户 14 节点图短,但<strong>归属校验在 对话 Tool 编排(tool_service.py)run_tool 里</strong>,和客户线铁律口径一致。
</p>
<div class="screen animate-in">
@@ -13,7 +13,7 @@
<div class="pattern-cards">
<div class="pattern-card">
<h3>tool_node</h3>
<p><code>match_intent("advisor", message)</code> 命中关键词 → <code>run_tool</code> 查 Core / 知识库 → 结果写入 <code>tool_results</code>。</p>
<p><code>match_intent("advisor", message)</code> 命中关键词 → 对话 Tool 编排(<code>tool_service.py</code>)<code>run_tool</code> 查 Core / 知识库 → 结果写入 <code>tool_results</code>。</p>
</div>
<div class="pattern-card">
<h3>llm_node</h3>
@@ -28,7 +28,7 @@
<div class="screen animate-in">
<h2>群聊:理财师问「客户 CUST-9527 持仓如何」</h2>
<p>简化播放 tool → llm → guard 全链路(前面 chat.py 已验 JWT + G-01)。</p>
<p>简化播放 tool → llm → guard 全链路(前面 四 Agent 对话 HTTP 入口(chat.py)已验 JWT + G-01)。</p>
<div class="chat-window" id="chat-advisor-m2">
<div class="chat-messages">
@@ -42,7 +42,7 @@
<div class="chat-message" data-msg="1" data-sender="chat" style="display:none">
<div class="chat-avatar" style="background:#B8922F">API</div>
<div class="chat-bubble">
<span class="chat-sender" style="color:#B8922F">chat.py</span>
<span class="chat-sender" style="color:#B8922F">四 Agent 对话 HTTP 入口(chat.py)</span>
<p>验 JWT → assert_customer_access(G-01:名下客户)→ 建/续 session</p>
</div>
</div>
@@ -50,7 +50,7 @@
<div class="chat-avatar" style="background:#E0C06A">Tool</div>
<div class="chat-bubble">
<span class="chat-sender" style="color:#E0C06A">tool_node</span>
<p>关键词「持仓」→ <code>query_holdings</code> → tool_service.run_tool</p>
<p>关键词「持仓」→ <code>query_holdings</code> → 对话 Tool 编排(tool_service.py)run_tool</p>
</div>
</div>
<div class="chat-message" data-msg="3" data-sender="core" style="display:none">
@@ -98,7 +98,7 @@
<div class="screen animate-in">
<div class="translation-block">
<div class="translation-code">
<span class="translation-label">CODE · agent_service.tool_node</span>
<span class="translation-label">CODE · 顾问通用 tool→llm→guard 编排(agent_service.py)tool_node</span>
<pre><code><span class="code-line">tool_name = tool_service.match_intent(</span>
<span class="code-line"> state[<span class="code-string">"agent_type"</span>], state[<span class="code-string">"user_message"</span>]</span>
<span class="code-line">)</span>
@@ -113,8 +113,8 @@
<span class="translation-label">白话</span>
<div class="translation-lines">
<p class="tl">先靠关键词判断要不要查库;闲聊不命中就 tool_results 为空,LLM 纯聊。</p>
<p class="tl">customer_id 来自会话绑定(chat.py 归属校验后的值),不是 LLM 生成的。</p>
<p class="tl">query_holdings 和 customer 线共用 core_tools 定义,但跑在 agent_service 图里。</p>
<p class="tl">customer_id 来自会话绑定(四 Agent 对话 HTTP 入口(chat.py)归属校验后的值),不是 LLM 生成的。</p>
<p class="tl">query_holdings 和 customer 线共用 Core 只读 Tool 定义(core_tools.py)定义,但跑在 顾问通用 tool→llm→guard 编排(agent_service.py)图里。</p>
</div>
</div>
</div>