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:
+50
-11
@@ -5,12 +5,49 @@
|
||||
|
||||
------
|
||||
|
||||
## 1. 链路总览
|
||||
## 0. 本地 bootstrap(新环境 / 新 Agent)
|
||||
|
||||
```text
|
||||
Client → Gateway(JWT/RBAC) → api/chat → agent_service → Tools → 存储 → 响应 + audit_log
|
||||
前置:MySQL 8、Redis、Neo4j Desktop、Ollama(bge-m3) 已安装并启动
|
||||
|
||||
① 配置
|
||||
cp .env.example .env
|
||||
必填:MYSQL_PASSWORD、NEO4J_PASSWORD、DEEPSEEK_API_KEY(对话阶段)
|
||||
|
||||
② 依赖
|
||||
pip install -r requirements.txt
|
||||
|
||||
③ Core 模拟库(L0)
|
||||
.\scripts\core\reset.ps1
|
||||
→ 创建 jinrong_core + 28 客户 / 12 产品 / 持仓交易种子
|
||||
|
||||
④ Agent 共用底座(若库未建)
|
||||
mysql -u root -p < docs/项目框架设计/表设计/01-mysql-共用底座.sql
|
||||
|
||||
⑤ 同步
|
||||
python scripts/sync/sync_advisor_rel.py → customer_advisor_rel
|
||||
python scripts/sync/sync_neo4j.py → 关系图
|
||||
|
||||
⑥ 验证
|
||||
uvicorn app.main:app --reload
|
||||
GET http://127.0.0.1:8000/health → {"status":"ok"}
|
||||
(可选)Python 调 CoreReadOnlyRepository.get_customer_l0("CUST-10001")
|
||||
|
||||
RBAC 联调账号:scripts/dev/rbac-seed-reference.md
|
||||
```
|
||||
|
||||
**尚未自动化:** agent 专用表 SQL、Milvus 建 Collection、JWT 中间件 — 见 `TODO.md`。
|
||||
|
||||
------
|
||||
|
||||
## 1. 链路总览(目标)
|
||||
|
||||
```text
|
||||
Client → Gateway(JWT/RBAC) → api/chat → agent_service(LangGraph) → Tools → 存储 → 响应 + audit_log
|
||||
```
|
||||
|
||||
当前:`main.py` 仅 health;全链路待 Wave 0 起逐步挂载。
|
||||
|
||||
------
|
||||
|
||||
## 2. 主链路 · 对话
|
||||
@@ -18,19 +55,19 @@ Client → Gateway(JWT/RBAC) → api/chat → agent_service → Tools → 存储
|
||||
```text
|
||||
输入:Authorization + X-Agent-Type + X-Trace-Id + 用户消息
|
||||
↓
|
||||
Gateway:验签、角色准入、注入 AuthContext
|
||||
Gateway:验签、角色准入、注入 AuthContext 【待做 T-01】
|
||||
↓
|
||||
api/chat:SessionGuard;创建/续 agent_session
|
||||
api/chat:SessionGuard;创建/续 agent_session 【待做】
|
||||
↓
|
||||
memory_service:Redis 读最近 N 轮;异步写 agent_message
|
||||
memory_service:Redis 读最近 N 轮;异步写 agent_message 【待做】
|
||||
↓
|
||||
agent_service:LangChain + DeepSeek;按 Agent 类型选 Tool 集
|
||||
agent_service:LangGraph StateGraph + DeepSeek;按 Agent 类型选 Tool 节点 【待做】
|
||||
↓
|
||||
Tool 示例:
|
||||
- Core RO:持仓/流水(自动注入 customer_id)
|
||||
- milvus_tool:产品规则 RAG + source_refs
|
||||
- memory_service:读/写 L1/L2/L3(ProfileGuard)
|
||||
- 风控 service 账号:R-02 适当性(无会话)
|
||||
- CoreReadOnlyRepository:持仓/流水/L0(自动注入 customer_id) 【Repository 已有,Tool 未接】
|
||||
- milvus_tool:产品规则 RAG + source_refs 【待做】
|
||||
- memory_service:读/写 L1/L2/L3(ProfileGuard) 【待做】
|
||||
- 风控 service 账号:R-02 适当性(无会话) 【待做】
|
||||
↓
|
||||
输出:assistant 消息 + has_disclaimer(客户/对外)
|
||||
↓
|
||||
@@ -68,13 +105,15 @@ admin/knowledge 上传 → document_parser → embedding_tool(Ollama bge-m3)
|
||||
| 会话 | session_id | Redis ctx + MySQL session | actor_id 一致 |
|
||||
| RAG | question + product_id? | chunks + source_doc_id | 必须溯源 |
|
||||
| 画像读 | customer_id | L1/L2/L3 JSON | RBAC 矩阵 §8 |
|
||||
| Core RO | customer_id | L0/持仓/流水 | 只读 jinrong_core |
|
||||
| 审计 | 任意判定 | audit_log INSERT | 不可删改 |
|
||||
|
||||
------
|
||||
|
||||
## 6. 关键数据约定
|
||||
|
||||
- MySQL 脚本:`docs/项目框架设计/表设计/01-mysql-共用底座.sql`、`02-mysql-agent专用.sql`
|
||||
- Agent 库 SQL:`docs/项目框架设计/表设计/01-mysql-共用底座.sql`、`02-mysql-agent专用.sql`
|
||||
- Core 模拟:`scripts/core/01-ddl.sql` · 说明 `docs/项目框架设计/Core模拟底座/01-表结构与种子说明.md`
|
||||
- Redis Key:`docs/项目框架设计/表设计/02-redis-keys.md`
|
||||
- Milvus:`kb_product_rules`、`kb_business_ops`;向量 **1024** 维
|
||||
- 禁止:Agent 覆盖 L0 正式 C1~C5
|
||||
|
||||
Reference in New Issue
Block a user