feat(visitor): Implement visitor chat functionality and enhance customer service interactions
- Added a new visitor chat API endpoint (`/api/chat/visitor`) to allow unauthenticated users to engage in conversations without requiring customer data. - Introduced a visitor context dependency to manage visitor interactions seamlessly. - Enhanced the chat API to support explicit session termination and improved response handling for customer service interactions. - Updated the database configuration to include Redis client support for caching visitor data. - Added a new customer note repository to persist user notes independently of the L1 profile slots. This update significantly improves the customer service experience by enabling visitor interactions and ensuring efficient data handling for both registered and unregistered users.
This commit is contained in:
+11
-8
@@ -9,7 +9,7 @@
|
||||
|
||||
**项目是什么:** 金融四 Agent(客户财富 / 代理人 / 数据分析 / 风控)共用数据层与合规底座;**不**互调 LLM,跨 Agent 走 L1/L2/L3 画像与预警表。
|
||||
|
||||
**当前进度:** 需求与表设计已定 · **风控模块 B1~B9b + C4~C6 + chat B/C + AL-09 合并** · **代销平台 API v0.1 已落地** · **530 passed 0 skipped** · **`web/` P0 脚手架已 init(登录+Layout+占位路由)**。**下一步:前端真接 API/SSE(含 risk Chat)· 接口契约发群。**
|
||||
**当前进度:** 需求与表设计已定 · **风控模块 B1~B9b + C4~C6 + chat B/C + AL-09 合并** · **代销平台 API v0.1 已落地** · **客服 Agent S2 接缝已接线**(visitor 试聊 + customer 并行分流) · **554 passed 0 skipped** · **`web/` 静奢智能 UI 已落地** · **`npm run build/test/lint` 绿(14 例 Vitest)**。**下一步:ChatPanel/SSE · 迁移 SQL CS-C-11 · Wave 1/2/4/5 解禁。**
|
||||
|
||||
**工作分支:** 团队开发在 **`merger`**(已 merge 风控模块);历史开发分支 `risk-control-agent` 交付冻结。旧文档中「待 AL-09 合并」口径已过时。
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
| `app/api/auth_adapter.py` | **已接线(S2)** | `module_auth_from_host()`:宿主 AuthContext → 模块 AuthContext |
|
||||
| `app/gateway/` | **宿主 Wave 0(并存)** | jwt_service / auth_deps / rbac / ownership;模块 API 走 `deps.py`,禁止模块 import gateway |
|
||||
| `app/api/risk.py` `simulate.py` `deps.py` | **已实现** | 风控 4 API + 模拟网关路由 + **JWT 鉴权工厂(T-01:Bearer 全环境优先;debug 头仅 dev+无 RS256 公钥时兜底;AGENT_ACCESS_MATRIX 准入)** |
|
||||
| `app/api/chat.py` `audit_middleware.py` | **已实现(T-06/T-02 + 前端接入 B/C)** | POST /api/chat(SessionGuard+归属+窗口+落盘)· **前端拉侧三端点**(`GET /sessions` / `GET /sessions/{id}/messages` / `POST /sessions/{id}/close`,方案 B `8328c24`)· **SSE 流式 `POST /api/chat/stream`**(OpenAI 兼容 chunk,方案 C `01ec5fc`);守卫抽 `_guard_request`/`_prepare_turn`/`_guard_session` 同步流式共用 · http_access 访问审计 |
|
||||
| `app/api/chat.py` `audit_middleware.py` | **已实现(T-06/T-02 + 前端接入 B/C + 客服 S2)** | POST /api/chat(**customer 分流 → customer_service** · 其余 → agent_service)· **POST /api/chat/visitor**(试聊)· 前端拉侧三端点 · SSE `POST /api/chat/stream` |
|
||||
| `app/api/customers.py` `products.py` `advisors.py` `staff.py` `compliance.py` | **已实现(v0.1)** | 代销平台 REST;`get_platform_auth_context`(无 X-Agent-Type);Service 层 `app/service/platform/` |
|
||||
| `app/api/knowledge.py` `admin.py` | 空壳 | 待审计查询台与知识库 API(T-21 拍板一期只做脚本入库,上传/重建端点不做) |
|
||||
| `app/service/platform/` | **已实现(v0.1)** | 封装 core_ro + `PLATFORM_RESPONSE_DESENSITIZE` 脱敏开关 |
|
||||
@@ -41,7 +41,7 @@
|
||||
| `scripts/core/*.sql` + `reset.ps1` | **已实现** | Core 模拟库 DDL + 种子 |
|
||||
| `scripts/agent/` `scripts/demo/` `scripts/dev/` | **已实现** | AML 名单种子 + 风控演示数据 + `fix_utf8_seed.py`/`run_sql_file.py`(Windows UTF-8 灌库)+ issue_dev_token |
|
||||
| `scripts/sync/*.py` | **已实现** | 归属同步 + Neo4j 全图 |
|
||||
| `tests/` | **已实现** | 37+ 测试模块 **530 用例 0 skipped**(sqlite + 真 MySQL 集成;`test_module_boundary` 宿主 D 类排除)。改路由必同步 `tests/test_main.py::test_all_routers_mounted` |
|
||||
| `tests/` | **已实现** | 37+ 测试模块 **554 用例 0 skipped**(含 `test_wave3_customer_service`;sqlite + 真 MySQL 集成;`test_module_boundary` 宿主 D 类排除)。改路由必同步 `tests/test_main.py::test_all_routers_mounted` |
|
||||
| `docs/需求拆解/` | 已定 | 场景 P0、矩阵、合规原文 |
|
||||
| `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` |
|
||||
@@ -52,7 +52,7 @@
|
||||
| `docs/项目框架设计/接口契约-代销平台API-v0.2-行情扩展草案.md` | **草案(2026-09-09)** | `nav-snapshot` · `sync_market_nav` · 前端产品行情 Phase B |
|
||||
| `docs/项目框架设计/表设计/` | 已定 | Agent 共用 11 表 + agent 专用 SQL |
|
||||
| `docs/项目框架设计/Core模拟底座/` | 已定 | 无真实 Core 时的 L0 方案 |
|
||||
| `web/` | **P0 脚手架(2026-09-09)** | 登录+Layout+四角色路由+占位页;**未接** ChatPanel/SSE、平台读 API、risk alerts;设计 `docs/superpowers/specs/2026-09-09-frontend-p0-design.md` |
|
||||
| `web/` | **静奢智能 UI(2026-09-09)** | React 19 + Vite 8 + **AntD 6** + **Tailwind CSS v4**(`@tailwindcss/vite`)+ HashRouter;`components/ui`/`dashboard`/`layout` 分层 · 四角色首页真调 `customers/products/advisors/risk` · **未接** ChatPanel/SSE、共享 `/app/market`、risk 处置 UI;交接 **`docs/frontend/FRONTEND-HANDOFF.md`** |
|
||||
|
||||
**本地 bootstrap(首次):** 完整步骤与前置说明见 `FLOW.md` §0(权威),速览:
|
||||
|
||||
@@ -65,12 +65,14 @@
|
||||
5. mysql … < scripts/agent/seed-aml-list.sql # AML 名单(Windows 乱码:`python scripts/dev/fix_utf8_seed.py`)
|
||||
(风控演示:scripts/demo/prepare_risk_demo.sql,reset 后重跑)
|
||||
6. python scripts/sync/sync_advisor_rel.py && python scripts/sync/sync_neo4j.py
|
||||
7. uvicorn app.main:app --reload → GET /health;`docker compose up -d redis`(限流/会话窗口);python -m pytest(**530 绿**,系统 Python 3.13.14)
|
||||
7. uvicorn app.main:app --reload → GET /health;`docker compose up -d redis`(限流/会话窗口);python -m pytest(**554 绿**,系统 Python 3.13.14)
|
||||
```
|
||||
|
||||
**AL-09 合并后架构(一句话):** 宿主 `gateway/` + 模块 `deps.py` **双栈并存**;对外登录/token **统一**;chat/risk 均走模块鉴权;接缝 S2 用 `auth_adapter`。
|
||||
|
||||
**下一步(见 TODO):** 前端 P0 真接(ChatPanel+customer/risk SSE、平台读页、risk alerts、market)· 接口契约发群 · Agent 合并改调 platform Service。
|
||||
**下一步(见 TODO):** 前端 ChatPanel/SSE(customer/risk/advisor)· 共享 `/app/market` · risk 台账处置 UI · 接口契约发群 · Agent 合并改调 platform Service。
|
||||
|
||||
**前端启动(`web/`):** `npm install` → `npm run dev`(`5173`,`/api` 代理 `8000`)· 验收四 demo 账号见 **`docs/frontend/FRONTEND-HANDOFF.md` §8** · 改 UI 后跑 `npm run build && npm run test && npm run lint`。
|
||||
|
||||
**平台 API 硬规则(2026-09-08 拍板):** 路由 **A · 按业务域**(`/api/customers` 等);与 Agent 功能重复时 **以本平台 API 为准**;命名见契约 §2;合并时统一改 canonical 路径。
|
||||
|
||||
@@ -155,7 +157,7 @@ Core 模拟:scripts/core/reset.ps1 · 文档 docs/项目框架设计/Core模
|
||||
种子:scripts/agent/seed-aml-list.sql(AML 名单)· scripts/demo/prepare_risk_demo.sql(reset 后重跑)
|
||||
依赖:requirements.txt(LangGraph + langchain-core/openai + FastAPI + SQLAlchemy)
|
||||
启动:uvicorn app.main:app --reload → GET /health
|
||||
测试:python -m pytest(**530 绿**;集成测试需本机 MySQL + `risk_aml_list` + `prepare_risk_demo.sql`)
|
||||
测试:python -m pytest(**554 绿**;集成测试需本机 MySQL + `risk_aml_list` + `prepare_risk_demo.sql`)
|
||||
运维/演示脚本: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)
|
||||
配置:.env(见 .env.example)
|
||||
@@ -185,6 +187,7 @@ RBAC 联调账号:scripts/dev/rbac-seed-reference.md
|
||||
| `docs/项目框架设计/接口契约-代销平台API-v0.1.md` | 写/Review 代销平台 REST;Agent 合并对照 canonical 路径 |
|
||||
| `docs/项目框架设计/C-05-行情数据源选型对比.md` | C-05 行情/净值数据源拍板与禁止项 |
|
||||
| `docs/项目框架设计/接口契约-代销平台API-v0.2-行情扩展草案.md` | Phase B `nav-snapshot` 与 sync 脚本契约(未实现) |
|
||||
| `docs/frontend/FRONTEND-HANDOFF.md` | **改 `web/` 必读**:启动/分层/设计令牌/组件边界/浏览器验收清单 |
|
||||
|
||||
缺 `docs/memory/*` 文件:按 project-memory-kit 同名补回,**禁止空模板盖进度**。
|
||||
|
||||
@@ -202,6 +205,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` 全量(当前 **530 绿**)· `docker compose up -d redis` · uvicorn + /health · 平台 `/api/customers/*` · `tests/test_module_boundary.py` 全绿)
|
||||
5. 如何验证?(`python -m pytest` 全量(当前 **554 绿**)· `docker compose up -d redis` · uvicorn + /health · 平台 `/api/customers/*` · `tests/test_module_boundary.py` 全绿)
|
||||
|
||||
大任务:FRAMEWORK/FLOW 与实现状态不符时先更新 memory 再编码(用户确认跳过除外)。
|
||||
|
||||
Reference in New Issue
Block a user