- Introduced a new `/analyze` endpoint in the analyst API to process analysis requests, allowing users to receive textual interpretations and chart specifications based on provided prompts. - Enhanced `analyst_schemas.py` with `AnalyzeRequest` and `ChartSpec` models to structure analysis requests and validate chart specifications. - Implemented chart validation logic in a new `analyst_chart.py` service, ensuring that chart types and fields are correctly specified and conform to allowed values. - Updated `AnalystAgent` to handle analysis requests, integrating the new logic for generating responses based on user prompts and data availability. - Added unit tests to verify the functionality of the new endpoint and validation mechanisms, ensuring robustness and reliability. This update significantly enhances the analytical capabilities of the application, providing users with improved tools for data interpretation and visualization.
203 lines
7.3 KiB
JSON
203 lines
7.3 KiB
JSON
{
|
||
"schema_version": 1,
|
||
"diagram_type": "architecture",
|
||
"meta": {
|
||
"title": "JinRong 运行时架构(merger)",
|
||
"locale": "zh-CN",
|
||
"quality_profile": "showcase",
|
||
"views": [
|
||
{
|
||
"id": "chat-happy-path",
|
||
"label": "对话主路径",
|
||
"focus": ["users", "web", "host", "chat", "graph", "redis", "agent-db", "core-ro", "core-db"],
|
||
"note": "从浏览器到 LangGraph、会话与 Core 只读,不含 RAG/LLM 旁路。"
|
||
},
|
||
{
|
||
"id": "trust-boundary",
|
||
"label": "信任与合规",
|
||
"focus": ["users", "auth", "host", "graph", "core-ro"],
|
||
"note": "JWT、模块 deps 与宿主 gateway 双栈;Tool 的 customer_id 由会话注入。"
|
||
},
|
||
{
|
||
"id": "knowledge-side",
|
||
"label": "知识与模型旁路",
|
||
"focus": ["graph", "rag", "llm"],
|
||
"note": "RAG 仅 customer/advisor 意图;无 API Key 时 LLM 降级但不静默伪造 Core 数据。"
|
||
}
|
||
]
|
||
},
|
||
"components": [
|
||
{
|
||
"id": "users",
|
||
"type": "external",
|
||
"label": "四角色用户",
|
||
"sublabel": "四角色",
|
||
"pos": [40, 320],
|
||
"size": [128, 64],
|
||
"tag": "X-Agent-Type"
|
||
},
|
||
{
|
||
"id": "web",
|
||
"type": "frontend",
|
||
"label": "Web Demo",
|
||
"sublabel": "Vite :5173 → /api",
|
||
"pos": [220, 320],
|
||
"size": [130, 64]
|
||
},
|
||
{
|
||
"id": "auth",
|
||
"type": "security",
|
||
"label": "鉴权双栈",
|
||
"sublabel": "deps.py + gateway/",
|
||
"pos": [220, 140],
|
||
"size": [130, 68],
|
||
"tag": "JWT jti·RBAC"
|
||
},
|
||
{
|
||
"id": "host",
|
||
"type": "backend",
|
||
"label": "FastAPI 宿主",
|
||
"sublabel": "AL-09 集成",
|
||
"pos": [420, 320],
|
||
"size": [140, 64]
|
||
},
|
||
{
|
||
"id": "chat",
|
||
"type": "backend",
|
||
"label": "对话 API",
|
||
"sublabel": "/api/chat · SSE",
|
||
"pos": [620, 320],
|
||
"size": [140, 64]
|
||
},
|
||
{
|
||
"id": "graph",
|
||
"type": "backend",
|
||
"label": "编排运行时",
|
||
"sublabel": "LangGraph · 14 节点客服",
|
||
"pos": [820, 320],
|
||
"size": [150, 68],
|
||
"tag": "tool→llm→guard"
|
||
},
|
||
{
|
||
"id": "redis",
|
||
"type": "database",
|
||
"label": "Redis",
|
||
"sublabel": ":6380 RESP2",
|
||
"pos": [620, 140],
|
||
"size": [130, 60],
|
||
"tag": "会话·限流·jti"
|
||
},
|
||
{
|
||
"id": "agent-db",
|
||
"type": "database",
|
||
"label": "MySQL Agent",
|
||
"sublabel": "jinrong_agent",
|
||
"pos": [820, 140],
|
||
"size": [140, 60],
|
||
"tag": "审计只 INSERT"
|
||
},
|
||
{
|
||
"id": "core-ro",
|
||
"type": "backend",
|
||
"label": "Core 只读层",
|
||
"sublabel": "core_ro · 适当性",
|
||
"pos": [1000, 320],
|
||
"size": [150, 64],
|
||
"tag": "SELECT only"
|
||
},
|
||
{
|
||
"id": "core-db",
|
||
"type": "database",
|
||
"label": "Core 模拟库",
|
||
"sublabel": "jinrong_core",
|
||
"pos": [1180, 320],
|
||
"size": [140, 60]
|
||
},
|
||
{
|
||
"id": "rag",
|
||
"type": "external",
|
||
"label": "向量 RAG",
|
||
"sublabel": "Milvus + Ollama",
|
||
"pos": [1000, 480],
|
||
"size": [140, 60],
|
||
"tag": "source_refs 溯源"
|
||
},
|
||
{
|
||
"id": "llm",
|
||
"type": "external",
|
||
"label": "DeepSeek",
|
||
"sublabel": "无 key 降级",
|
||
"pos": [820, 480],
|
||
"size": [130, 56]
|
||
}
|
||
],
|
||
"boundaries": [
|
||
{
|
||
"kind": "region",
|
||
"label": "Agent 模块边界(禁止 import 宿主 gateway)",
|
||
"wraps": ["host", "chat", "graph", "core-ro", "redis", "agent-db"],
|
||
"pad": 24
|
||
},
|
||
{
|
||
"kind": "security-group",
|
||
"label": "Core 信任域",
|
||
"wraps": ["core-ro", "core-db"],
|
||
"pad": 16
|
||
}
|
||
],
|
||
"connections": [
|
||
{ "id": "u-web", "from": "users", "to": "web", "label": "HTTPS", "variant": "emphasis", "labelDy": 56 },
|
||
{ "id": "web-host", "from": "web", "to": "host", "label": "Bearer JWT", "labelDy": 56 },
|
||
{ "id": "auth-host", "from": "auth", "to": "host", "label": "验签/角色矩阵", "variant": "security", "fromSide": "right", "toSide": "top" },
|
||
{ "id": "host-chat", "from": "host", "to": "chat", "label": "路由+Trace", "variant": "emphasis", "labelDy": 56 },
|
||
{ "id": "chat-graph", "from": "chat", "to": "graph", "label": "客服分流", "variant": "emphasis", "labelDy": 56 },
|
||
{ "id": "graph-redis", "from": "graph", "to": "redis", "label": "会话窗口", "fromSide": "top", "toSide": "bottom", "labelDx": -48, "labelDy": -12 },
|
||
{ "id": "graph-agentdb", "from": "graph", "to": "agent-db", "label": "同事务落盘", "fromSide": "top", "toSide": "bottom", "labelDx": 48, "labelDy": -12 },
|
||
{ "id": "graph-core", "from": "graph", "to": "core-ro", "label": "只读 Tool", "variant": "emphasis", "labelDy": 58 },
|
||
{ "id": "corero-coredb", "from": "core-ro", "to": "core-db", "label": "只读 SQL", "labelDy": 56 },
|
||
{ "id": "graph-rag", "from": "graph", "to": "rag", "label": "kb_tools", "variant": "dashed", "fromSide": "bottom", "toSide": "top", "labelDx": 40 },
|
||
{ "id": "graph-llm", "from": "graph", "to": "llm", "label": "流式块", "variant": "dashed", "fromSide": "bottom", "toSide": "top", "labelDy": 28, "labelDx": -40 },
|
||
{ "id": "redis-chat", "from": "redis", "to": "chat", "label": "限流 fail-open", "variant": "dashed", "fromSide": "left", "toSide": "top" }
|
||
],
|
||
"cards": [
|
||
{
|
||
"dot": "rose",
|
||
"title": "不变量与硬阀门(改代码前)",
|
||
"items": [
|
||
"Core 正式 C1~C5 不被 L1/L2/L3 画像覆盖;仅 R-02 适当性可阻断交易模拟",
|
||
"audit_log / agent_tool_call 等审计链只 INSERT,HTTP 访问与 trace_id 同源",
|
||
"四 Agent 不互调 LLM;跨角色协作走表与预警,不走「再开一个模型」",
|
||
"模块 API 走 app/api/deps.py;禁止业务代码 import app/gateway(宿主 Wave 0 并存)"
|
||
]
|
||
},
|
||
{
|
||
"dot": "amber",
|
||
"title": "非功能与运维习惯",
|
||
"items": [
|
||
"Redis 推荐 Docker 6380 + RESP2,兼容旧 Windows Redis;会话/问数缓存/吊销,平台 GET 仍直打 MySQL",
|
||
"JWT 吊销查 Redis 失败时 fail-open;输入限流被拒 fail-fast 且不建会话",
|
||
"GET /api/ready 自检 Redis+路由;前端 DevReadyBanner 防「旧后端假绿」",
|
||
"Embedding 失败不静默降级维度;RAG 必须带 source_refs 可溯源"
|
||
]
|
||
},
|
||
{
|
||
"dot": "violet",
|
||
"title": "隐藏逻辑与行业常见写法",
|
||
"items": [
|
||
"鉴权接缝 S2:auth_adapter 把宿主 AuthContext 转成模块上下文,登录 token 与 issue_dev_token 同 issuer",
|
||
"customer 线:关键词意图优先于 LLM;sanitize_postprocess 统一合规收口,达线阈值写 notify_log(C-04)",
|
||
"Tool 编排:customer_id 由会话注入,不信任 LLM 填写的归属;risk 分支四只读 Tool + 列表须 RiskListAccess",
|
||
"方案 C SSE:Tool 同步跑完再分块推 LLM;needs_disclaimer 首帧 meta 与落库尾部同一口径"
|
||
]
|
||
},
|
||
{
|
||
"dot": "emerald",
|
||
"title": "主路径一句话",
|
||
"items": [
|
||
"Client → JWT/RBAC → chat(/stream) → LangGraph(或 14 节点客服图)→ Redis 窗口 + MySQL 事务落盘 → core_ro 只读 Core 模拟库",
|
||
"旁路:Milvus 知识库(意图门控)与 DeepSeek;平台 REST(持仓/净值)走独立域 API,与对话 Tool 契约对齐 v0.1"
|
||
]
|
||
}
|
||
]
|
||
}
|