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
@@ -1,7 +1,7 @@
<section class="module" id="module-2">
<div class="module-inner">
<p class="eyebrow animate-in">模块 2 · 会话记忆</p>
<h1 class="module-title animate-in">session_repository + memory_service:<br>Redis 窗口,MySQL 权威</h1>
<h1 class="module-title animate-in">session_repository + Redis 会话窗口(memory_service.py):<br>Redis 窗口,MySQL 权威</h1>
<p class="module-lead animate-in">
对话每轮消息<strong>同步写 MySQL</strong>(权威),同时用
<span class="term" data-definition="Redis = 内存数据库,适合存最近几条消息当「滑动窗口」,丢了可从 MySQL 重建。">Redis</span>
@@ -12,17 +12,17 @@
<div class="screen animate-in">
<h2>数据流:用户发第二条消息</h2>
<div class="flow-animation" data-steps='[
{"highlight":"flow-actor-1","label":"chat.py 收到 POST /api/chat"},
{"highlight":"flow-actor-1","label":"对话 HTTP 入口(chat.py)收到 POST /api/chat"},
{"highlight":"flow-actor-2","label":"session_repository:INSERT agent_message(MySQL 权威)","packet":true,"from":"1","to":"2"},
{"highlight":"flow-actor-3","label":"memory_service.append_window → Redis RPUSH","packet":true,"from":"2","to":"3"},
{"highlight":"flow-actor-3","label":"Redis 会话窗口(memory_service.py).append_window → Redis RPUSH","packet":true,"from":"2","to":"3"},
{"highlight":"flow-actor-3","label":"LTRIM 保留最近 20 条 + EXPIRE 2h"},
{"highlight":"flow-actor-2","label":"get_recent:先 Redis LRANGE,miss 回源 list_messages","packet":true,"from":"3","to":"2"},
{"highlight":"flow-actor-1","label":"拼进 LLM 上下文,生成回复","packet":true,"from":"2","to":"1"}
]'>
<div class="flow-actors">
<div class="flow-actor" id="flow-actor-1"><span class="flow-actor-icon">🚪</span><span>chat.py</span></div>
<div class="flow-actor" id="flow-actor-1"><span class="flow-actor-icon">🚪</span><span>对话 HTTP 入口(chat.py)</span></div>
<div class="flow-actor" id="flow-actor-2"><span class="flow-actor-icon">🗄</span><span>session_repository</span></div>
<div class="flow-actor" id="flow-actor-3"><span class="flow-actor-icon">⚡</span><span>memory_service · Redis</span></div>
<div class="flow-actor" id="flow-actor-3"><span class="flow-actor-icon">⚡</span><span>Redis 会话窗口(memory_service.py)</span></div>
</div>
<p class="flow-step-label">Key 格式:sess:{agent}:{session_id}:msgs</p>
<div class="flow-controls">
@@ -38,7 +38,7 @@
<div class="screen animate-in">
<div class="translation-block">
<div class="translation-code">
<span class="translation-label">memory_service.py</span>
<span class="translation-label">Redis 会话窗口(memory_service.py)</span>
<pre><code><span class="code-line"><span class="code-keyword">def</span> <span class="code-function">window_key</span>(agent_type, session_id):</span>
<span class="code-line"> <span class="code-keyword">return</span> <span class="code-string">f"sess:{agent_type}:{session_id}:msgs"</span></span>
<span class="code-line"></span>