Add core database support and enhance documentation
- Introduced `MYSQL_CORE_DATABASE` in `.env.example` and `settings.py` for core database configuration. - Added `CoreReadOnlyRepository` for read-only access to the `jinrong_core` database. - Updated `AGENTS.md`, `README.md`, and various documentation files to reflect new agent onboarding processes and project structure. - Revised requirements in `requirements.txt` to include `langgraph` and `langchain-core`. - Enhanced `FLOW.md` with local bootstrap instructions for setting up the core simulation environment. - Added new scripts for database creation and seeding for the core simulation library. - Improved overall documentation for clarity on project architecture and memory management. - Updated `TODO.md` to reflect current development priorities and tasks.
This commit is contained in:
+42
-28
@@ -2,7 +2,8 @@
|
||||
|
||||
> 选型详情:`docs/项目框架设计/技术选型和版本/01-技术栈与版本.md`
|
||||
> 表设计:`docs/项目框架设计/表设计/`
|
||||
> 鉴权:`docs/项目框架设计/技术选型和版本/02-JWT-RBAC鉴权手册.md`
|
||||
> 鉴权:`docs/项目框架设计/技术选型和版本/02-JWT-RBAC鉴权手册.md`
|
||||
> Core 模拟:`docs/项目框架设计/Core模拟底座/`
|
||||
|
||||
------
|
||||
|
||||
@@ -11,15 +12,15 @@
|
||||
| 技术栈 | 已定(用户已同意) | 备注 |
|
||||
| --- | --- | --- |
|
||||
| 后端语言/框架 | Python 3.13.14 + FastAPI | 系统 Python |
|
||||
| Agent 编排 | langchain 1.3.18 / langchain-openai 1.6.0 | DeepSeek API |
|
||||
| 关系库 | MySQL 8.0.46 | jinrong_agent,:3306 |
|
||||
| Agent 编排 | **LangGraph** 1.2.x + langchain-core / langchain-openai 1.6.0 | DeepSeek API;StateGraph + Tool 节点 |
|
||||
| 关系库 | MySQL 8.0.46 | **双库**:`jinrong_agent` + `jinrong_core` |
|
||||
| 缓存 | Redis 8.10.1 | :6379 |
|
||||
| 图库 | Neo4j 5.26.19 Enterprise | Desktop,关系查询 |
|
||||
| 向量库 | Milvus Lite + pymilvus 3.0.1 | 本地文件;1024 维 |
|
||||
| 图库 | Neo4j 5.26.19 Enterprise | Desktop;`sync_neo4j.py` 灌图 |
|
||||
| 向量库 | Milvus Lite + pymilvus 3.0.1 | 本地 `./data/milvus.db`;1024 维 |
|
||||
| Embedding | Ollama bge-m3 | 本地,不出内网 |
|
||||
| LLM 生成 | DeepSeek API | 对话/推理 |
|
||||
| 前端 | React 19 + Vite 7 + AntD 5 + TS strict | 不用 Streamlit |
|
||||
| 对象存储 | 本地目录 data/kb/ | 不用 MinIO |
|
||||
| 前端 | React 19 + Vite 7 + AntD 5 + TS strict | 不用 Streamlit;`web/` 待 init |
|
||||
| 对象存储 | 本地目录 `data/kb/` | 不用 MinIO |
|
||||
| 部署 | Windows 原生 | Docker 仅答辩备选 |
|
||||
|
||||
```text
|
||||
@@ -31,30 +32,41 @@
|
||||
|
||||
## 2. 能力模块
|
||||
|
||||
| 模块 | 职责 | 依赖 |
|
||||
| --- | --- | --- |
|
||||
| Agent Gateway / Auth SDK | JWT、RBAC、归属校验 | Redis、MySQL customer_advisor_rel |
|
||||
| 客户财富 Agent | L1 画像、事实查询、阈值提醒 | Core RO、Milvus 产品库 |
|
||||
| 代理人助手 Agent | L2 画像、RAG、草稿 | L1 只读、Milvus |
|
||||
| 数据分析 Agent | NL→SQL→解读 | Core RO、画像只读 |
|
||||
| 风控监测 Agent | 预警、L3、R-02 适当性 | 交易事件、AML 名单 |
|
||||
| 共用底座 | 会话、审计、输入防护 | MySQL 11 表 + Redis |
|
||||
| 模块 | 职责 | 依赖 | 代码状态 |
|
||||
| --- | --- | --- | --- |
|
||||
| Agent Gateway / Auth SDK | JWT、RBAC、归属校验 | Redis、MySQL customer_advisor_rel | **未做**(见 JWT 手册) |
|
||||
| 客户财富 Agent | L1 画像、事实查询、阈值提醒 | Core RO、Milvus 产品库 | 空壳 service |
|
||||
| 代理人助手 Agent | L2 画像、RAG、草稿 | L1 只读、Milvus | 空壳 service |
|
||||
| 数据分析 Agent | NL→SQL→解读 | Core RO、画像只读 | 空壳 service |
|
||||
| 风控监测 Agent | 预警、L3、R-02 适当性 | 交易事件、AML 名单 | 空壳 service |
|
||||
| Core 只读层 | L0 事实查询 | `jinrong_core` | **core_ro.py 已实现** |
|
||||
| 共用底座 | 会话、审计、输入防护 | MySQL 11 表 + Redis | SQL 已定;代码未接 |
|
||||
| 同步脚本 | 归属、Neo4j | Core → agent / 图库 | **sync_*.py 已实现** |
|
||||
|
||||
------
|
||||
|
||||
## 3. 后端分层(app/)
|
||||
|
||||
```text
|
||||
api/ → 路由(chat、knowledge、admin);薄,不含业务
|
||||
service/ → agent_service、rag_service、memory_service
|
||||
tool/ → document_parser、embedding_tool、milvus_tool
|
||||
model/ → schemas(Pydantic)、entities(ORM)
|
||||
config/ → settings、database
|
||||
utils/ → response、exceptions、logger
|
||||
main.py → FastAPI 入口
|
||||
api/ → 路由(chat、knowledge、admin);薄,不含业务 【空壳】
|
||||
service/ → agent_service、rag_service、memory_service 【空壳】
|
||||
tool/ → document_parser、embedding_tool、milvus_tool 【空壳】
|
||||
repository/ → core_ro(Core 只读);后续 agent 库 Repository 【core_ro 已实现】
|
||||
model/ → schemas(Pydantic)、entities(ORM) 【占位】
|
||||
config/ → settings、database 【settings 已实现】
|
||||
utils/ → response、exceptions、logger 【占位】
|
||||
main.py → FastAPI 入口;当前仅 /health 【部分】
|
||||
|
||||
允许:api → service → tool / model / config
|
||||
禁止:api 直连 Milvus/MySQL 写复杂逻辑;tool 写业务流程
|
||||
允许:api → service → tool / repository / model / config
|
||||
禁止:api 直连 Milvus/MySQL 写复杂逻辑;tool 写业务流程;repository 写 Core
|
||||
```
|
||||
|
||||
**脚本(非 app 包):**
|
||||
|
||||
```text
|
||||
scripts/core/ → jinrong_core DDL + 种子 + reset.ps1
|
||||
scripts/sync/ → sync_advisor_rel.py、sync_neo4j.py
|
||||
scripts/dev/ → rbac-seed-reference.md(联调账号)
|
||||
```
|
||||
|
||||
------
|
||||
@@ -63,14 +75,16 @@ main.py → FastAPI 入口
|
||||
|
||||
| 层 | 存储 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| L0 | Core 只读 | 正式 C1~C5、持仓 |
|
||||
| L1/L2/L3 | MySQL 画像表 | 客户/代理人/风控 enrich |
|
||||
| L0 | `jinrong_core` 只读 | 正式 C1~C5、持仓、流水(模拟) |
|
||||
| L1/L2/L3 | MySQL 画像表(agent 库) | 客户/代理人/风控 enrich |
|
||||
| 会话 | Redis + MySQL | 窗口 + 永久审计 |
|
||||
| RAG | Milvus + 本地文件 | kb_product_rules 等 |
|
||||
| RAG | Milvus + `data/kb/` | kb_product_rules 等 |
|
||||
| 关系 | Neo4j | 客户-产品-代理人(Core 同步) |
|
||||
|
||||
------
|
||||
|
||||
## 5. 骨架一句话
|
||||
|
||||
Gateway 鉴权 → FastAPI api → service 编排 Agent → tool 访问 MySQL/Redis/Milvus/Neo4j/Core → 审计落库。
|
||||
Gateway 鉴权 → FastAPI api → service(LangGraph)→ tool/repository → MySQL/Redis/Milvus/Neo4j/Core → 审计落库。
|
||||
|
||||
**记忆分层详解:** [业务记忆管理手册.md](../业务记忆管理/业务记忆管理手册.md)
|
||||
|
||||
Reference in New Issue
Block a user