Parcourir la source

差旅助手流程图

yyy il y a 3 jours
commit
d162dd3482
1 fichiers modifiés avec 155 ajouts et 0 suppressions
  1. 155 0
      SmartBizTripFlow.svg

+ 155 - 0
SmartBizTripFlow.svg

@@ -0,0 +1,155 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="1560" height="1300" viewBox="0 0 1560 1300" font-family="Microsoft YaHei, Noto Sans CJK SC, sans-serif">
+  <defs>
+    <marker id="arr" markerWidth="10" markerHeight="10" refX="8" refY="4" orient="auto">
+      <path d="M0 0L8 4L0 8Z" fill="#666"/>
+    </marker>
+  </defs>
+  <style>
+    .title{font-size:26px;font-weight:700;fill:#111}
+    .sub{font-size:14px;fill:#666}
+    .layer{font-size:14px;font-weight:700;fill:#777}
+    .bt{font-size:15px;font-weight:700;fill:#222}
+    .bb{font-size:12px;fill:#555}
+    .note{font-size:11px;fill:#888}
+    .lbl{font-size:12px;fill:#666}
+    .box{fill:#fff;stroke:#888;stroke-width:1.5}
+    .band{fill:#f7f7f7;stroke:#ddd;stroke-width:1}
+    .flow{fill:none;stroke:#666;stroke-width:1.6;marker-end:url(#arr)}
+    .hflow{fill:none;stroke:#666;stroke-width:1.4;marker-end:url(#arr)}
+    .link{fill:none;stroke:#999;stroke-width:1.4;marker-start:url(#arr);marker-end:url(#arr)}
+  </style>
+
+  <text x="780" y="44" text-anchor="middle" class="title">SmartBizTrip 整体架构图</text>
+  <text x="780" y="70" text-anchor="middle" class="sub">六层结构 + 主助手五步处理流程;端口 / 文件名 / 工具名均对照代码核实</text>
+
+  <!-- 分层背景带 -->
+  <rect x="40" y="88" width="1480" height="100" rx="6" class="band"/>
+  <text x="56" y="112" class="layer">① 客户端层</text>
+  <rect x="40" y="228" width="1480" height="100" rx="6" class="band"/>
+  <text x="56" y="252" class="layer">② API 服务层</text>
+  <rect x="40" y="370" width="1480" height="250" rx="6" class="band"/>
+  <text x="56" y="394" class="layer">③ 主助手 · 协调层</text>
+  <rect x="40" y="680" width="1480" height="170" rx="6" class="band"/>
+  <text x="56" y="704" class="layer">④ A2A 子助手层</text>
+  <rect x="40" y="890" width="1480" height="170" rx="6" class="band"/>
+  <text x="56" y="914" class="layer">⑤ MCP 工具层</text>
+  <rect x="40" y="1100" width="1480" height="140" rx="6" class="band"/>
+  <text x="56" y="1124" class="layer">⑥ 数据层</text>
+
+  <!-- ① 客户端 -->
+  <rect x="180" y="126" width="560" height="54" rx="4" class="box"/>
+  <text x="204" y="148" class="bt">网页客户端 — static/index.html</text>
+  <text x="204" y="170" class="bb">聊天界面 · 代理卡片 · 记忆面板(SSE 逐段渲染)</text>
+  <rect x="820" y="126" width="560" height="54" rx="4" class="box"/>
+  <text x="844" y="148" class="bt">命令行客户端 — 课件示例/classroom_main.py</text>
+  <text x="844" y="170" class="bb">逐轮输入问题,控制台打印回复</text>
+
+  <!-- ② API -->
+  <rect x="330" y="266" width="900" height="54" rx="4" class="box"/>
+  <text x="354" y="288" class="bt">api_server.py — FastAPI · 127.0.0.1:8080</text>
+  <text x="354" y="310" class="bb">POST /api/chat/stream(SSE 流式,网页默认) · POST /api/chat · GET /api/agents · /api/memory 系列</text>
+
+  <!-- ③ 主助手五步流程 -->
+  <rect x="45" y="408" width="270" height="92" rx="4" class="box"/>
+  <text x="65" y="432" class="bt">① 记忆写入</text>
+  <text x="65" y="456" class="bb">add_message("user")</text>
+  <text x="65" y="478" class="bb">带偏好 · 历史 · 任务上下文</text>
+  <rect x="345" y="408" width="270" height="92" rx="4" class="box"/>
+  <text x="365" y="432" class="bt">② 意图识别 intent_agent</text>
+  <text x="365" y="456" class="bb">LLM → JSON</text>
+  <text x="365" y="478" class="bb">意图 / 改写查询 / 追问</text>
+  <rect x="645" y="408" width="270" height="92" rx="4" class="box"/>
+  <text x="665" y="432" class="bt">③ 追问 · 范围外?</text>
+  <text x="665" y="456" class="bb">是 → 直接返回追问,本轮结束</text>
+  <text x="665" y="478" class="bb">否 → 继续路由</text>
+  <rect x="945" y="408" width="270" height="92" rx="4" class="box"/>
+  <text x="965" y="432" class="bt">④ 路由与执行</text>
+  <text x="965" y="456" class="bb">简单:逐意图直接执行</text>
+  <text x="965" y="478" class="bb">复杂:规划 → ReAct(依赖分批 · 批内并行)</text>
+  <rect x="1245" y="408" width="270" height="92" rx="4" class="box"/>
+  <text x="1265" y="432" class="bt">⑤ 汇总输出</text>
+  <text x="1265" y="456" class="bb">summarize 整理 · 流式分片</text>
+  <text x="1265" y="478" class="bb">多步才调汇总模型 · 存记忆</text>
+
+  <path d="M315 454 H345" class="hflow"/>
+  <path d="M615 454 H645" class="hflow"/>
+  <path d="M915 454 H945" class="hflow"/>
+  <path d="M1215 454 H1245" class="hflow"/>
+
+  <rect x="45" y="544" width="1470" height="58" rx="4" class="box"/>
+  <text x="69" y="566" class="bt">memory.py — ConversationMemory(记忆模块)</text>
+  <text x="69" y="588" class="bb">短期对话(10 条) · 用户偏好 · 任务上下文 · 查询实体/历史 | 启动时从 MySQL 记忆表恢复,变更时写回;派发子助手前记录查询历史</text>
+  <path d="M180 500 V544" class="link"/>
+  <path d="M1380 500 V544" class="link"/>
+
+  <!-- ④ A2A -->
+  <rect x="40" y="718" width="450" height="96" rx="4" class="box"/>
+  <text x="64" y="742" class="bt">天气子助手 · :5005</text>
+  <text x="64" y="766" class="bb">a2a_server/weather_server.py</text>
+  <text x="64" y="786" class="bb">WeatherQueryAssistant · AgentCard</text>
+  <text x="64" y="806" class="bb">工具调用 Agent · 缺参数则追问</text>
+  <rect x="555" y="718" width="450" height="96" rx="4" class="box"/>
+  <text x="579" y="742" class="bt">票务子助手 · :5006</text>
+  <text x="579" y="766" class="bb">a2a_server/ticket_server.py</text>
+  <text x="579" y="786" class="bb">TicketServer(TicketAssistant)</text>
+  <text x="579" y="806" class="bb">高铁 / 航班 / 会展:查询 + 模拟预订</text>
+  <rect x="1070" y="718" width="450" height="96" rx="4" class="box"/>
+  <text x="1094" y="742" class="bt">差旅子助手 · :5007</text>
+  <text x="1094" y="766" class="bb">a2a_server/trip_server.py</text>
+  <text x="1094" y="786" class="bb">TripAssistant</text>
+  <text x="1094" y="806" class="bb">商务用车 / 保险 / 会务套餐</text>
+
+  <!-- ⑤ MCP -->
+  <rect x="40" y="928" width="450" height="96" rx="4" class="box"/>
+  <text x="64" y="952" class="bt">天气 MCP · :8002</text>
+  <text x="64" y="976" class="bb">mcp_server/mcp_weather_server.py</text>
+  <text x="64" y="996" class="bb">query_weather</text>
+  <text x="64" y="1016" class="bb">双数据源:MySQL / 和风API 直查</text>
+  <rect x="555" y="928" width="450" height="96" rx="4" class="box"/>
+  <text x="579" y="952" class="bt">票务 MCP · :8001</text>
+  <text x="579" y="976" class="bb">mcp_server/mcp_ticket_server.py</text>
+  <text x="579" y="996" class="bb">query / order:train · flight · event</text>
+  <text x="579" y="1016" class="bb">参数化 SQL 查询</text>
+  <rect x="1070" y="928" width="450" height="96" rx="4" class="box"/>
+  <text x="1094" y="952" class="bt">差旅 MCP · :8003</text>
+  <text x="1094" y="976" class="bb">mcp_server/mcp_trip_server.py</text>
+  <text x="1094" y="996" class="bb">query / order:用车 · 保险 · 会务套餐</text>
+  <text x="1094" y="1016" class="bb">会务套餐走 Milvus 语义检索</text>
+
+  <!-- ⑥ 数据层 -->
+  <rect x="40" y="1138" width="760" height="80" rx="4" class="box"/>
+  <text x="64" y="1162" class="bt">MySQL · :3306 · biztrip_rag</text>
+  <text x="64" y="1184" class="bb">业务表:train / flight / event_tickets · weather_data · car_rentals · insurances</text>
+  <text x="64" y="1206" class="bb">记忆表:user_profiles · query_history · short_term_messages(weather_data ← 爬虫定时采集)</text>
+  <rect x="1080" y="1138" width="440" height="80" rx="4" class="box"/>
+  <text x="1104" y="1162" class="bt">Milvus 向量库 · :19530</text>
+  <text x="1104" y="1184" class="bb">会务套餐集合 · text-embedding-v3 · COSINE</text>
+  <text x="1104" y="1206" class="bb">初始化:sql/init_meeting_package_rag.py</text>
+
+  <!-- 层间连线 -->
+  <path d="M460 180 V266" class="flow"/>
+  <path d="M1100 180 V266" class="flow"/>
+  <text x="475" y="212" class="lbl">POST /api/chat/stream(SSE)</text>
+
+  <path d="M780 320 V360 H200 V408" class="flow"/>
+  <text x="795" y="350" class="lbl">chat_stream / chat</text>
+
+  <path d="M265 620 V718" class="flow"/>
+  <path d="M780 620 V718" class="flow"/>
+  <path d="M1295 620 V718" class="flow"/>
+  <text x="300" y="640" class="lbl">A2A 协议:Task → status / artifacts</text>
+  <text x="300" y="658" class="lbl">意图映射:weather→天气助手 | train / flight / event / order→票务助手</text>
+  <text x="300" y="676" class="lbl">car_rental / meeting_package / insurance / trip_order→差旅助手 | city_service→主助手直连</text>
+
+  <path d="M265 814 V928" class="flow"/>
+  <path d="M780 814 V928" class="flow"/>
+  <path d="M1295 814 V928" class="flow"/>
+  <text x="300" y="872" class="lbl">MCP 工具调用(to_langchain_tool)</text>
+
+  <path d="M265 1024 V1138" class="flow"/>
+  <path d="M780 1024 V1138" class="flow"/>
+  <path d="M1295 1024 V1138" class="flow"/>
+  <text x="300" y="1082" class="lbl">参数化 SQL / 向量检索(会务套餐 RAG)</text>
+
+  <text x="40" y="1268" class="note">要点:MCP 为参数化工具(%s 防注入,LLM 只提参数不写 SQL);预订均为模拟演示;天气数据由 utils/spider_weather.py 定时从和风API采集入库;启动顺序:MCP(8001-8003) → A2A(5005-5007) → api_server(8080)。</text>
+</svg>