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:
+21
-6
@@ -9,7 +9,7 @@
|
||||
|
||||
**项目是什么:** 金融四 Agent(客户财富 / 代理人 / 数据分析 / 风控)共用数据层与合规底座;**不**互调 LLM,跨 Agent 走 L1/L2/L3 画像与预警表。
|
||||
|
||||
**当前进度:** 需求与表设计已定 · **风控 + 平台 API + 客服 S2 + 数据分析 S3/P2** · **customer Chat SSE**(stream 分流 customer_service)· **STAFF-30001 含 risk_demo**(模拟交易演示)· **774+ pytest** · **19 Vitest** · **Redis @ 6380**
|
||||
**当前进度:** 需求与表设计已定 · **风控 + 平台 API + 客服 S2 Wave3 部分落地 + 数据分析 S3/P2** · **customer Chat SSE** · **C-04/C-05/C-11 等** · **786 pytest** · **19 Vitest** · **Redis @ 6380**
|
||||
|
||||
**工作分支:** 团队开发在 **`merger`**;历史 `risk-control-agent` 交付冻结。
|
||||
|
||||
@@ -41,11 +41,13 @@
|
||||
| `app/utils/` | **基本就绪** | trace(trace_id+request_id 双 contextvar)/ desensitize / db(引擎工厂)/ response(统一错误体+4xx/500 handler)/ exceptions(含 ApiError)已实现;logger 占位 |
|
||||
| `app/config/database.py` | **已实现** | MySQL 双引擎 + **Redis 单例**(`REDIS_URL` · **RESP2 `protocol=2`** 兼容 Docker Redis 7 / 旧 Windows Redis 3) |
|
||||
| `app/config/settings.py` | **已实现** | 双库 + risk_* 阈值 + JWT + **customer/visitor/profile** 字段 + `kb_root_dir` |
|
||||
| `app/service/customer_service.py` `visitor_service.py` | **已实现(S2)** | 客服 14 节点 · 游客 9 节点 LangGraph;RAG 走 **fin_* 三库**;Redis 记忆 **fail-open** |
|
||||
| `app/service/customer_service.py` `visitor_service.py` | **已实现(S2 + Wave3 部分)** | 客服 14 节点 · **C-04 阈值** · **C-05 nav_query** · **C-11 匹配说明** · 游客 9 节点;共用 `sanitize_postprocess.finalize_sanitized_reply`(1B);RAG **fin_* 三库** |
|
||||
| `app/service/threshold_service.py` | **已实现(C-04)** | L1 `threshold_pref_summary` → `customer_threshold_config`;持仓查询加权盈亏 vs 阈值 → `customer_notify_log` |
|
||||
| `app/utils/sanitize_postprocess.py` | **已实现(1B 共用)** | 数据查询 intent(含 nav_query)违禁 → 回退 fact_text;RAG/闲聊 → COMPLIANCE_REJECT;均不自动 transfer |
|
||||
| `scripts/core/*.sql` + `reset.ps1` | **已实现** | Core 模拟库 DDL + 种子 |
|
||||
| `scripts/agent/` `scripts/demo/` `scripts/dev/` | **已实现** | AML 种子 + 演示数据 + `run_sql_file.py` + **`start-redis.ps1`**(Docker Redis 优先)+ issue_dev_token |
|
||||
| `scripts/sync/*.py` | **已实现** | 归属同步 + Neo4j 全图 |
|
||||
| `tests/` | **已实现** | **774 用例** 0 skipped(含 Wave6 analyst + customer stream 测试)
|
||||
| `tests/` | **已实现** | **786 用例** 1 skipped(Wave3 customer + threshold + sanitize_postprocess + 1B/R1)
|
||||
| `docs/course/` | **交互课程集(2026-09-09)** | 打开 `docs/course/index.html` 导览中心 · 总览 + 7 模块深潜课 |
|
||||
| `docs/PRD/PRD-风控监测Agent.md` | **已冻结(v1.1)** | 风控 PRD v1.0 + v1.1 追加 FR-8/9/10(§4A)+ 规则表附录 |
|
||||
| `docs/项目框架设计/实现方案-风控追加需求v1.1-C4C6.md` | **已定稿** | C4~C6 编码依据(经独立 AI 评审修订闭环);分支/进度速览另见项目根 `交接文档.md` |
|
||||
@@ -70,7 +72,7 @@
|
||||
(风控演示:scripts/demo/prepare_risk_demo.sql,reset 后重跑)
|
||||
6. python scripts/sync/sync_advisor_rel.py && python scripts/sync/sync_neo4j.py
|
||||
7. `docker compose up -d redis`(或 `.\scripts\dev\start-redis.ps1`)→ **REDIS_URL=redis://127.0.0.1:6380/0**(Docker Redis 7;避开本机 Windows Redis 占 6379)
|
||||
8. uvicorn … · python -m pytest(**774 绿**);问数冒烟 · 可选 `mysql … < scripts/agent/seed-analyst-metric-dict.sql`
|
||||
8. uvicorn … · python -m pytest(**786 绿**);问数冒烟 · 可选 `mysql … < scripts/agent/seed-analyst-metric-dict.sql`
|
||||
```
|
||||
|
||||
**AL-09 合并后架构(一句话):** 宿主 `gateway/` + 模块 `deps.py` **双栈并存**;对外登录/token **统一**;chat/risk 均走模块鉴权;接缝 S2 用 `auth_adapter`。
|
||||
@@ -153,6 +155,19 @@ audit_log 等审计表(只 INSERT)
|
||||
画像不得覆盖 L0 正式测评
|
||||
```
|
||||
|
||||
**客服合规拍板(2026-09-10 · 已落地):**
|
||||
|
||||
| ID | 决策 | 代码落点 |
|
||||
| --- | --- | --- |
|
||||
| **1B** | 数据查询 intent(持仓/流水/风评/适当性/**净值**)经 `sanitize_reply` 命中违禁词 → **回退 `fact_text`,不转人工**;RAG/闲聊命中 → `COMPLIANCE_REJECT`,**也不自动 transfer**;**customer + visitor 共用** | `app/utils/sanitize_postprocess.py` · `finalize_sanitized_reply` |
|
||||
| **R1** | L1 `product_preferences` / `excluded_products` 合并时写 `items_meta`;注入 prompt **Top-K + 时间衰减 + TTL**(K=3 · TTL=90d · 半衰 30d) | `profile_service` · `settings.profile_preference_*` |
|
||||
| **C-04** | 用户口述「亏 X% 提醒我」→ L1 摘要 + `customer_threshold_config`;**查持仓时**组合加权盈亏达线 → 追加提醒 + `customer_notify_log`(非 push/cron) | `threshold_service` · `core_ro_tool.query_holdings` |
|
||||
| **C-05** | 「最新净值/单位净值」→ Core `get_latest_nav`(快照,非实时盘口);**「实时净值」仍 reject** | `core_ro_tool.query_product_nav` · intent `nav_query` |
|
||||
| **C-11** | 「我能买什么/匹配产品」→ `suitability_check` + Core 可购列表;**「推荐稳赚/买什么好」仍 reject** | `customer_prompts._ELIGIBLE_PRODUCTS_KW` |
|
||||
| **C-07** | 风评查询走 Core;**「重新测评/重做风评」** → 引导 App/网点(Agent 内不做问卷) | `customer_prompts._RISK_KW` |
|
||||
| **C-08** | 仅 L1 槽位 `investment.allocation_target`(13 槽);**无自动偏离检测/调仓** | `profile_slots.py` |
|
||||
| **L0 优先** | 抽槽与 L0 撞车**永远听 L0**;L1 只 enrich 措辞 | `profile_slots` D7 |
|
||||
|
||||
------
|
||||
|
||||
## 4. 入口与运行
|
||||
@@ -165,7 +180,7 @@ Core 模拟:scripts/core/reset.ps1 · 文档 docs/项目框架设计/Core模
|
||||
依赖:requirements.txt(LangGraph + langchain-core/openai + FastAPI + SQLAlchemy)
|
||||
启动:uvicorn app.main:app --reload → GET /health
|
||||
Redis:`docker compose up -d redis` · `REDIS_URL=redis://127.0.0.1:6380/0` · `scripts/dev/start-redis.ps1`
|
||||
测试:python -m pytest(**730 绿**;集成需本机 MySQL + `risk_aml_list` + `prepare_risk_demo.sql`)
|
||||
测试:python -m pytest(**786 绿**;集成需本机 MySQL + `risk_aml_list` + `prepare_risk_demo.sql`)
|
||||
前端:cd web && npm run dev · npm run build/test/lint(**19** Vitest)
|
||||
运维/演示脚本:scripts/demo/subscribe_alerts.py(订阅推送演示)· rebuild_alerts.py TRD-xxx(引擎异常补偿重放)
|
||||
JWT 联调:python scripts/dev/issue_dev_token.py --sub STAFF-30001 --roles risk_officer(+ Authorization: Bearer + X-Agent-Type)
|
||||
@@ -214,6 +229,6 @@ RBAC 联调账号:scripts/dev/rbac-seed-reference.md
|
||||
2. 改动属于 api / service / tool / repository 哪一层?
|
||||
3. 是否需 customer_id 归属与 JWT RBAC?
|
||||
4. Core 是模拟库只读还是 agent 库读写?
|
||||
5. 如何验证?(`python -m pytest` **730 绿** · `docker compose up -d redis` + `.env` **6380** · uvicorn + `/health` · `web/` build/test · 平台 `/api/customers/*` · 登录页游客试聊 · 客户助手 Chat)
|
||||
5. 如何验证?(`python -m pytest` **786 绿** · Redis **6380** · uvicorn + `/health` · 客户助手 Chat SSE · 测试包 `docs/memory/tests/2026-09-10-customer-1b-r1/`)
|
||||
|
||||
大任务:FRAMEWORK/FLOW 与实现状态不符时先更新 memory 再编码(用户确认跳过除外)。
|
||||
|
||||
Reference in New Issue
Block a user