feat(aia): Complete AIA V2.0 with universal streaming capabilities

Major Changes:
- Add StreamingService with OpenAI Compatible format
- Upgrade Chat component V2 with Ant Design X integration
- Implement AIA module with 12 intelligent agents
- Update API routes to unified /api/v1 prefix
- Update system documentation

Backend (~1300 lines):
- common/streaming: OpenAI Compatible adapter
- modules/aia: 12 agents, conversation service, streaming integration
- Update route versions (RVW, PKB to v1)

Frontend (~3500 lines):
- modules/aia: AgentHub + ChatWorkspace (100% prototype restoration)
- shared/Chat: AIStreamChat, ThinkingBlock, useAIStream Hook
- Update API endpoints to v1

Documentation:
- AIA module status guide
- Universal capabilities catalog
- System overview updates
- All module documentation sync

Tested: Stream response verified, authentication working
Status: AIA V2.0 core completed (85%)
This commit is contained in:
2026-01-14 19:15:01 +08:00
parent 3d35e9c58b
commit 1b53ab9d52
386 changed files with 52096 additions and 65238 deletions

View File

@@ -1,20 +1,20 @@
# 工具C Day 4-5 前端开发计划(最终版)
# 宸ュ叿C Day 4-5 鍓嶇<EFBFBD>寮€鍙戣<EFBFBD>鍒掞紙鏈€缁堢増锛?
> **鍒跺畾鏃ユ湡**: 2025-12-07
> **开发目标**: Tool C前端MVP - AI驱动的科研数据编辑器
> **预计工时**: 12-16小时Day 4: 6-8h, Day 5: 6-8h
> **寮€鍙戠洰鏍?*: Tool C鍓嶇<EFBFBD>MVP - AI椹卞姩鐨勭<EFBFBD>鐮旀暟鎹<EFBFBD>紪杈戝櫒
> **棰勮<EFBFBD>宸ユ椂**: 12-16灏忔椂锛圖ay 4: 6-8h, Day 5: 6-8h锛?
> **鏍稿績鐩<E7B8BE>爣**: 绔<>埌绔疉I鏁版嵁娓呮礂娴佺▼鍙<E296BC>
---
## 馃幆 鏍稿績鍐崇瓥
| 决策项 | 最终方案 | 理由 |
| 鍐崇瓥椤?| 鏈€缁堟柟妗?| 鐞嗙敱 |
|--------|---------|------|
| **表格组件** | **AG Grid Community** | 用户强烈要求Excel级体验 |
| **琛ㄦ牸缁勪欢** | **AG Grid Community** | 鐢ㄦ埛寮虹儓瑕佹眰锛孍xcel绾т綋楠?|
| **寮€鍙戜紭鍏堢骇** | **AI鏍稿績鍔熻兘浼樺厛** | 鍏堥獙璇佸悗绔<E68297>紝UI缁嗚妭鍚庣画浼樺寲 |
| **UI椋庢牸** | **涓ユ牸杩樺師鍘熷瀷V6** | Emerald缁胯壊涓婚<E6B693>锛岀<E9949B>鍚圱ool C瀹氫綅 |
| **测试数据** | **真实医疗数据** | cqol-demo.csv (21列x300+行) |
| **娴嬭瘯鏁版嵁** | **鐪熷疄鍖荤枟鏁版嵁** | cqol-demo.csv (21鍒梮300+琛? |
| **Day 4-5鐩<35>** | **AI鏍稿績鍔熻兘鍙<E58598>** | 涓婁紶鈫扐I瀵硅瘽鈫掓墽琛屸啋鏇存柊琛ㄦ牸 |
| **浠g爜椋庢牸** | **鍚孴ool B鏍囧噯** | TypeScript + Tailwind + Lucide |
@@ -29,8 +29,8 @@
"ag-grid-react": "^31.0.0", // React闆嗘垚
"react": "^18.2.0",
"react-router-dom": "^6.x",
"lucide-react": "^0.x", // 图标库
"axios": "^1.x" // HTTP客户端
"lucide-react": "^0.x", // 鍥炬爣搴?
"axios": "^1.x" // HTTP瀹㈡埛绔?
}
```
@@ -39,76 +39,76 @@
- **Tailwind CSS**: 鍘熷瓙鍖朇SS
- **AG Grid Community**: 寮€婧愮増锛屽姛鑳借冻澶烳VP
- **Prism.js**: 浠爜璇<E7889C>硶楂樹寒
- **React Markdown**: Markdown渲染AI回复
- **React Markdown**: Markdown娓叉煋锛圓I鍥炲<EFBFBD>锛?
---
## 馃搻 椤甸潰甯冨眬璁捐<E79281>
```
┌────────────────────────────────────────────────────────────┐
Header (h-14)
│ [🟢 科研数据编辑器] lung_cancer.csv [撤销/重做] [导出]
└────────────────────────────────────────────────────────────┘
┌──────────────────────────┬─────────────────────────────────┐
Left Panel (flex-1) Right Sidebar (w-[420px])
│ ┌──────────────────────┐ │ ┌───────────────────────────┐ │
│ │ Toolbar (h-16) │ │ │ Tab: [Chat] [Insights] │ │
│ │ 7个快捷按钮 + 搜索 │ │ └───────────────────────────┘ │
│ └──────────────────────┘ │
│ ┌───────────────────────────┐ │
│ ┌──────────────────────┐ │ │ Chat Messages Area │ │
│ │ │ │ │ - 用户消息 │ │
│ │ AG Grid Table │ │ │ - AI消息含代码块 │ │
│ │ (Excel风格) │ │ │ - 系统消息 │ │
│ │ │ │ │ │ │
│ │ 21x 300+ │ │ └───────────────────────────┘ │
│ │ │ │
│ │ 支持: │ │ ┌───────────────────────────┐ │
│ │ - 列排序 │ │ │ Input + Send Button │ │
│ │ - 列宽调整 │ │ └───────────────────────────┘ │
│ │ - 单元格编辑(后期) │ │
│ │ - 选择高亮 │ │
│ └──────────────────────┘ │
└──────────────────────────┴─────────────────────────────────┘
鈹屸攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?
鈹?Header (h-14) 鈹?
鈹?[馃煝 绉戠爺鏁版嵁缂栬緫鍣╙ lung_cancer.csv [鎾ら攢/閲嶅仛] [瀵煎嚭] 鈹?
鈹斺攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?
鈹屸攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹<EFBFBD>攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?
鈹?Left Panel (flex-1) 鈹?Right Sidebar (w-[420px]) 鈹?
鈹? 鈹? 鈹?
鈹?鈹屸攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?鈹?鈹屸攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?鈹?
鈹?鈹?Toolbar (h-16) 鈹?鈹?鈹?Tab: [Chat] [Insights] 鈹?鈹?
鈹?鈹?7涓<37>揩鎹锋寜閽?+ 鎼滅储 鈹?鈹?鈹斺攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?鈹?
鈹?鈹斺攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?鈹? 鈹?
鈹? 鈹?鈹屸攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?鈹?
鈹?鈹屸攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?鈹?鈹?Chat Messages Area 鈹?鈹?
鈹?鈹? 鈹?鈹?鈹?- 鐢ㄦ埛娑堟伅 鈹?鈹?
鈹?鈹? AG Grid Table 鈹?鈹?鈹?- AI娑堟伅锛堝惈浠爜鍧楋級 鈹?鈹?
鈹?鈹? (Excel椋庢牸) 鈹?鈹?鈹?- 绯荤粺娑堟伅 鈹?鈹?
鈹?鈹? 鈹?鈹?鈹? 鈹?鈹?
鈹?鈹? 21鍒?x 300+琛? 鈹?鈹?鈹斺攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?鈹?
鈹?鈹? 鈹?鈹? 鈹?
鈹?鈹? 鏀<>寔锛? 鈹?鈹?鈹屸攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?鈹?
鈹?鈹? - 鍒楁帓搴? 鈹?鈹?鈹?Input + Send Button 鈹?鈹?
鈹?鈹? - 鍒楀<E98D92>璋冩暣 鈹?鈹?鈹斺攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?鈹?
鈹?鈹? - 鍗曞厓鏍肩紪杈戯紙鍚庢湡锛?鈹?鈹? 鈹?
鈹?鈹? - 閫夋嫨楂樹寒 鈹?鈹? 鈹?
鈹?鈹斺攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?鈹? 鈹?
鈹斺攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹粹攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?
```
---
## 🗂️ 文件结构规划
## 馃梻锔?鏂囦欢缁撴瀯瑙勫垝
```
frontend-v2/src/modules/dc/pages/tool-c/
├── index.tsx # 主入口(状态管理+布局)
鈹溾攢鈹€ index.tsx # 涓诲叆鍙紙鐘舵€佺<EFBFBD>鐞?甯冨眬锛?
鈹溾攢鈹€ components/
│ ├── Header.tsx # 顶部栏
│ ├── Toolbar.tsx # 工具栏7个按钮
│ ├── DataGrid.tsx # AG Grid表格(核心)
│ ├── Sidebar.tsx # 右侧栏容器
│ ├── ChatPanel.tsx # Chat面板
│ ├── InsightsPanel.tsx # Insights面板
│ ├── MessageList.tsx # 消息列表
│ ├── MessageItem.tsx # 单条消息
│ ├── CodeBlock.tsx # 代码块渲染
│ └── InputArea.tsx # 输入框
鈹? 鈹溾攢鈹€ Header.tsx # 椤堕儴鏍?
鈹? 鈹溾攢鈹€ Toolbar.tsx # 宸ュ叿鏍忥紙7涓<EFBFBD>寜閽<EFBFBD>
鈹? 鈹溾攢鈹€ DataGrid.tsx # AG Grid琛ㄦ牸锛堟牳蹇冿級
鈹? 鈹溾攢鈹€ Sidebar.tsx # 鍙充晶鏍忓<EFBFBD>鍣?
鈹? 鈹溾攢鈹€ ChatPanel.tsx # Chat闈㈡澘
鈹? 鈹溾攢鈹€ InsightsPanel.tsx # Insights闈㈡澘
鈹? 鈹溾攢鈹€ MessageList.tsx # 娑堟伅鍒楄〃
鈹? 鈹溾攢鈹€ MessageItem.tsx # 鍗曟潯娑堟伅
鈹? 鈹溾攢鈹€ CodeBlock.tsx # 浠g爜鍧楁覆鏌?
鈹? 鈹斺攢鈹€ InputArea.tsx # 杈撳叆妗?
鈹溾攢鈹€ hooks/
│ ├── useToolC.ts # 核心状态管理Hook
│ ├── useSession.ts # Session管理
│ ├── useChat.ts # AI对话逻辑
│ └── useDataGrid.ts # 表格数据管理
鈹? 鈹溾攢鈹€ useToolC.ts # 鏍稿績鐘舵€佺<EFBFBD>鐞咹ook
鈹? 鈹溾攢鈹€ useSession.ts # Session绠$悊
鈹? 鈹溾攢鈹€ useChat.ts # AI瀵硅瘽閫昏緫
鈹? 鈹斺攢鈹€ useDataGrid.ts # 琛ㄦ牸鏁版嵁绠$悊
鈹斺攢鈹€ types/
鈹斺攢鈹€ index.ts # TypeScript绫诲瀷瀹氫箟
frontend-v2/src/modules/dc/api/
└── toolC.ts # API封装6个方法
鈹斺攢鈹€ toolC.ts # API灏佽<EFBFBD>锛?涓<>柟娉曪級
```
---
## ⏱️ Day 4 开发计划6-8小时
## 鈴憋笍 Day 4 寮€鍙戣<EFBFBD>鍒掞紙6-8灏忔椂锛?
### 阶段1项目初始化1小时
### 闃舵<EFBFBD>1锛氶」鐩<EFBFBD>垵濮嬪寲锛?灏忔椂锛?
#### 1.1 瀹夎<E780B9>渚濊禆
```bash
@@ -127,32 +127,32 @@ touch src/modules/dc/pages/tool-c/index.tsx
#### 1.3 鏇存柊璺<E69F8A>敱閰嶇疆
```typescript
// src/App.tsx 或路由配置文件
// src/App.tsx 鎴栬矾鐢遍厤缃<EFBFBD>枃浠?
<Route path="/data-cleaning/tool-c" element={<ToolC />} />
```
#### 1.4 鏇存柊Portal椤甸潰
```typescript
// src/modules/dc/pages/Portal.tsx
// 将Tool C的status从'disabled'改为'ready'
// 灏員ool C鐨剆tatus浠?disabled'鏀逛负'ready'
{
id: 'tool-c',
title: '科研数据编辑器',
status: 'ready', // ⭐ 修改这里
title: '绉戠爺鏁版嵁缂栬緫鍣?,
status: 'ready', // 猸?淇<>敼杩欓噷
route: '/data-cleaning/tool-c'
}
```
**交付物**
- ✅ 依赖安装完成
- ✅ 文件结构创建
- Portal可点击进入Tool C
**浜や粯鐗?*锛?
- 鉁?渚濊禆瀹夎<E780B9>瀹屾垚
- 鉁?鏂囦欢缁撴瀯鍒涘缓
- 鉁?Portal<EFBFBD>偣鍑昏繘鍏<EFBFBD>ool C
---
### 阶段2页面框架搭建2小时
### 闃舵<EFBFBD>2锛氶〉闈㈡<EFBFBD>鏋舵惌寤猴紙2灏忔椂锛?
#### 2.1 创建主入口 (index.tsx)
#### 2.1 鍒涘缓涓诲叆鍙?(index.tsx)
```typescript
import { useState } from 'react';
import Header from './components/Header';
@@ -229,7 +229,7 @@ const Header: React.FC<HeaderProps> = ({ fileName, onUndo, onRedo, onExport }) =
<Table2 size={20} />
</div>
<span className="font-bold text-lg text-slate-900">
?
<span className="text-emerald-600 text-xs px-1.5 py-0.5 bg-emerald-50 rounded-full ml-1">
Pro
</span>
@@ -283,8 +283,8 @@ const ToolbarButton = ({ icon: Icon, label, colorClass }: any) => (
const Toolbar = () => {
return (
<div className="bg-white border-b border-slate-200 px-4 py-2 flex items-center gap-1 overflow-x-auto flex-none shadow-sm z-10">
<ToolbarButton icon={Calculator} label="生成新变量" colorClass="text-emerald-600 bg-emerald-50 hover:bg-emerald-100" />
<ToolbarButton icon={CalendarClock} label="时间差" colorClass="text-blue-600 bg-blue-50 hover:bg-blue-100" />
<ToolbarButton icon={Calculator} label="鐢熸垚鏂板彉閲? colorClass="text-emerald-600 bg-emerald-50 hover:bg-emerald-100" />
<ToolbarButton icon={CalendarClock} label="鏃堕棿宸? colorClass="text-blue-600 bg-blue-50 hover:bg-blue-100" />
<ToolbarButton icon={ArrowLeftRight} label="妯<>旱杞<E697B1>崲" colorClass="text-cyan-600 bg-cyan-50 hover:bg-cyan-100" />
<div className="w-[1px] h-8 bg-slate-200 mx-2"></div>
<ToolbarButton icon={FileSearch} label="鏌ラ噸" colorClass="text-orange-600 bg-orange-50 hover:bg-orange-100" />
@@ -296,7 +296,7 @@ const Toolbar = () => {
<Search size={16} className="absolute left-3 top-1/2 -translate-y-1/2 text-slate-400" />
<input
className="pl-9 pr-4 py-1.5 text-sm bg-slate-100 border-none rounded-full w-48 focus:w-64 transition-all outline-none focus:ring-2 focus:ring-emerald-500/20"
placeholder="搜索值..."
placeholder="鎼滅储鍊?.."
/>
</div>
</div>
@@ -306,14 +306,14 @@ const Toolbar = () => {
export default Toolbar;
```
**交付物**
- Header完成(带返回按钮)
- Toolbar完成7个按钮
- ✅ 基础布局可见
**浜や粯鐗?*锛?
- 鉁?Header瀹屾垚锛堝甫杩斿洖鎸夐挳锛?
- 鉁?Toolbar瀹屾垚锛?涓<>寜閽<E5AF9C>
- 鉁?鍩虹<E98DA9>甯冨眬鍙<E79CAC><E98D99>
---
### 阶段3AG Grid集成3-4小时
### 闃舵<EFBFBD>3锛欰G Grid闆嗘垚锛?-4灏忔椂锛?
#### 3.1 鍒涘缓DataGrid缁勪欢
```typescript
@@ -352,7 +352,7 @@ const DataGrid: React.FC<DataGridProps> = ({ data, columns, onCellValueChanged }
}));
}, [columns]);
// 默认列配置
// 榛樿<EFBFBD>鍒楅厤缃?
const defaultColDef: ColDef = {
flex: 0,
sortable: true,
@@ -360,13 +360,13 @@ const DataGrid: React.FC<DataGridProps> = ({ data, columns, onCellValueChanged }
resizable: true,
};
// 如果没有数据,显示空状态
// 濡傛灉娌℃湁鏁版嵁锛屾樉绀虹┖鐘舵€?
if (data.length === 0) {
return (
<div className="bg-white border border-slate-200 shadow-sm rounded-xl p-12 text-center">
<div className="text-slate-400 text-sm">
<p className="mb-2"></p>
<p>AI助手中上传文件</p>
<p>AI<EFBFBD>?/p>
</div>
</div>
);
@@ -421,9 +421,9 @@ export default DataGrid;
```typescript
// 涓存椂娴嬭瘯锛氬湪index.tsx涓<78>‖缂栫爜娴嬭瘯鏁版嵁
const mockData = [
{ id: 'P001', age: 27, sex: '女', bmi: 23.1, smoke: '否' },
{ id: 'P002', age: 24, sex: '男', bmi: 16.7, smoke: '是' },
{ id: 'P003', age: null, sex: '男', bmi: null, smoke: '是' },
{ id: 'P001', age: 27, sex: '濂?, bmi: 23.1, smoke: '? },
{ id: 'P002', age: 24, sex: '鐢?, bmi: 16.7, smoke: '? },
{ id: 'P003', age: null, sex: '鐢?, bmi: null, smoke: '? },
];
const mockColumns = [
@@ -431,21 +431,21 @@ const mockColumns = [
{ id: 'age', name: '骞撮緞', type: 'number' },
{ id: 'sex', name: '鎬у埆', type: 'category' },
{ id: 'bmi', name: 'BMI', type: 'number' },
{ id: 'smoke', name: '吸烟史', type: 'category' },
{ id: 'smoke', name: '鍚哥儫鍙?, type: 'category' },
];
```
**交付物**
- AG Grid成功渲染
- ✅ 缺失值高亮显示
- ✅ 列排序/过滤可用
- ✅ 列宽可调整
**浜や粯鐗?*锛?
- 鉁?AG Grid鎴愬姛娓叉煋
- 鉁?缂哄け鍊奸珮浜<E78FAE>樉绀?
- 鉁?鍒楁帓搴?杩囨护鍙<E68AA4>
- 鉁?鍒楀<E98D92><EFBFBD>皟鏁?
---
## ⏱️ Day 5 开发计划6-8小时
## 鈴憋笍 Day 5 寮€鍙戣<EFBFBD>鍒掞紙6-8灏忔椂锛?
### 阶段4AI Chat面板3小时
### 闃舵<EFBFBD>4锛欰I Chat闈㈡澘锛?灏忔椂锛?
#### 4.1 鍒涘缓Sidebar缁勪欢
```typescript
@@ -549,8 +549,8 @@ const ChatPanel: React.FC<ChatPanelProps> = ({ messages, onSendMessage, isLoadin
<div className="flex-1 overflow-y-auto p-4 space-y-4">
{messages.length === 0 && (
<div className="text-center text-slate-400 text-sm py-12">
<p className="mb-2">👋 AI数据分析师</p>
<p>"把年龄大于60的标记为老年组"</p>
<p className="mb-2"> <EFBFBD>I鏁版嵁鍒嗘瀽甯?/p>
<p>"鎶婂勾榫勫ぇ浜?0鐨勬爣璁颁负鑰佸勾缁?</p>
</div>
)}
{messages.map((msg) => (
@@ -559,7 +559,7 @@ const ChatPanel: React.FC<ChatPanelProps> = ({ messages, onSendMessage, isLoadin
{isLoading && (
<div className="flex items-center gap-2 text-slate-400 text-sm">
<div className="animate-spin rounded-full h-4 w-4 border-2 border-emerald-500 border-t-transparent"></div>
<span>AI正在思考...</span>
<span>AI姝e湪鎬濊?..</span>
</div>
)}
<div ref={messagesEndRef} />
@@ -653,7 +653,7 @@ const MessageItem: React.FC<MessageItemProps> = ({ message }) => {
<Play size={12} /> ц<EFBFBD>
</>
)}
{code.status === 'running' && '执行中...'}
{code.status === 'running' && '鎵ц<EFBFBD>涓?..'}
{code.status === 'success' && (
<>
<CheckCircle2 size={12} /> ц<EFBFBD>
@@ -715,7 +715,7 @@ const CodeBlock: React.FC<CodeBlockProps> = ({ code, language = 'python' }) => {
>
{copied ? (
<>
<Check size={12} />
<Check size={12} /> <EFBFBD>?
</>
) : (
<>
@@ -771,7 +771,7 @@ const InputArea: React.FC<InputAreaProps> = ({ onSend, disabled }) => {
value={input}
onChange={(e) => setInput(e.target.value)}
onKeyDown={handleKeyDown}
placeholder="告诉AI你想做什么..."
placeholder="鍛婅瘔AI浣犳兂鍋氫粈涔?.."
className="flex-1 resize-none border border-slate-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-emerald-500/20 focus:border-emerald-500"
rows={3}
disabled={disabled}
@@ -785,7 +785,7 @@ const InputArea: React.FC<InputAreaProps> = ({ onSend, disabled }) => {
</button>
</div>
<div className="text-xs text-slate-400 mt-2">
<kbd className="px-1 py-0.5 bg-slate-100 rounded">Enter</kbd>
?<kbd className="px-1 py-0.5 bg-slate-100 rounded">Enter</kbd>
<kbd className="px-1 py-0.5 bg-slate-100 rounded">Shift + Enter</kbd> <EFBFBD>
</div>
</div>
@@ -795,15 +795,15 @@ const InputArea: React.FC<InputAreaProps> = ({ onSend, disabled }) => {
export default InputArea;
```
**交付物**
- Chat面板完整UI
- ✅ 消息列表渲染
- ✅ 代码块语法高亮
- ✅ 输入框交互
**浜や粯鐗?*锛?
- 鉁?Chat闈㈡澘瀹屾暣UI
- 鉁?娑堟伅鍒楄〃娓叉煋
- 鉁?浠爜鍧楄<E98DA7>娉曢珮浜?
- 鉁?杈撳叆妗嗕氦浜?
---
### 阶段5API集成2-3小时
### 闃舵<EFBFBD>5锛欰PI闆嗘垚锛?-3灏忔椂锛?
#### 5.1 鍒涘缓API灏佽<E7818F>
```typescript
@@ -911,7 +911,7 @@ export const useToolC = () => {
setMessages([{
id: Date.now(),
role: 'system',
content: `✅ 文件上传成功!共${preview.data.totalRows}x ${preview.data.totalCols}`,
content: `鉁?鏂囦欢涓婁紶鎴愬姛锛佸叡${preview.data.totalRows}琛?x ${preview.data.totalCols}鍒梎,
}]);
}
} catch (error: any) {
@@ -919,14 +919,14 @@ export const useToolC = () => {
setMessages([{
id: Date.now(),
role: 'system',
content: `❌ 上传失败: ${error.message}`,
content: `鉂?涓婁紶澶辫触: ${error.message}`,
}]);
} finally {
setIsLoading(false);
}
}, []);
// 发送AI消息一步到位生成+执行)
// 鍙戦€丄I娑堟伅锛堜竴姝ュ埌浣嶏細鐢熸垚+鎵ц<E98EB5>锛?
const handleSendMessage = useCallback(async (message: string) => {
if (!sessionId) {
alert('璇峰厛涓婁紶鏂囦欢');
@@ -943,7 +943,7 @@ export const useToolC = () => {
try {
setIsLoading(true);
// 调用process接口(生成+执行,一步到位)
// 璋冪敤process鎺ュ彛锛堢敓鎴?鎵ц<E98EB5>锛屼竴姝ュ埌浣嶏級
const result = await api.processMessage(sessionId, message);
if (result.success) {
@@ -958,20 +958,20 @@ export const useToolC = () => {
},
}]);
// 如果执行成功,更新表格数据
// 濡傛灉鎵ц<EFBFBD>鎴愬姛锛屾洿鏂拌〃鏍兼暟鎹?
if (result.data.executeResult.success && result.data.executeResult.newDataPreview) {
setData(result.data.executeResult.newDataPreview);
setMessages(prev => [...prev, {
id: Date.now() + 2,
role: 'system',
content: `✅ 代码执行成功!表格已更新。${result.data.retryCount > 0 ? `(重试${result.data.retryCount}次后成功)` : ''}`,
content: `?ц<EFBFBD>?{result.data.retryCount > 0 ? `锛堥噸璇?{result.data.retryCount}娆″悗鎴愬姛锛塦 : ''}`,
}]);
} else if (!result.data.executeResult.success) {
setMessages(prev => [...prev, {
id: Date.now() + 2,
role: 'system',
content: `❌ 执行失败: ${result.data.executeResult.error}`,
content: `鉂?鎵ц<E98EB5>澶辫触: ${result.data.executeResult.error}`,
}]);
}
}
@@ -980,7 +980,7 @@ export const useToolC = () => {
setMessages(prev => [...prev, {
id: Date.now() + 1,
role: 'system',
content: `❌ 处理失败: ${error.response?.data?.error || error.message}`,
content: `鉂?澶勭悊澶辫触: ${error.response?.data?.error || error.message}`,
}]);
} finally {
setIsLoading(false);
@@ -1038,14 +1038,14 @@ const ToolC = () => {
};
```
**交付物**
- ✅ 6个API方法封装
- useToolC核心Hook
- ✅ 端到端流程可用
**浜や粯鐗?*锛?
- 鉁?6涓狝PI鏂规硶灏佽<E7818F>
- 鉁?useToolC鏍稿績Hook
- 鉁?绔<>埌绔<E59F8C>祦绋嬪彲鐢?
---
### 阶段6文件上传 + InsightsPanel1小时
### 闃舵<EFBFBD>6锛氭枃浠朵笂浼?+ InsightsPanel锛?灏忔椂锛?
#### 6.1 娣诲姞鏂囦欢涓婁紶UI
```typescript
@@ -1072,7 +1072,7 @@ const ToolC = () => {
</label>
</div>
<p className="text-slate-400 text-sm">
CSV, XLSX, XLS10MB
<EFBFBD>SV, XLSX, XLS锛堟渶澶?0MB?
</p>
</div>
)}
@@ -1110,11 +1110,11 @@ const InsightsPanel: React.FC<InsightsPanelProps> = ({ dataStats }) => {
</div>
<div className="space-y-2 text-sm">
<div className="flex justify-between">
<span className="text-slate-600"></span>
<span className="text-slate-600"><EFBFBD>?/span>
<span className="font-medium">{dataStats.totalRows}</span>
</div>
<div className="flex justify-between">
<span className="text-slate-600"></span>
<span className="text-slate-600">?/span>
<span className="font-medium">{dataStats.totalCols}</span>
</div>
</div>
@@ -1123,7 +1123,7 @@ const InsightsPanel: React.FC<InsightsPanelProps> = ({ dataStats }) => {
<div className="bg-red-50 rounded-lg p-4">
<div className="flex items-center gap-2 mb-3">
<AlertCircle size={16} className="text-red-600" />
<h3 className="font-semibold text-sm text-red-900"></h3>
<h3 className="font-semibold text-sm text-red-900">?/h3>
</div>
<div className="space-y-2 text-sm">
<div className="flex justify-between">
@@ -1131,7 +1131,7 @@ const InsightsPanel: React.FC<InsightsPanelProps> = ({ dataStats }) => {
<span className="font-medium text-red-900">{dataStats.missingCount}</span>
</div>
<div className="flex justify-between">
<span className="text-red-700"></span>
<span className="text-red-700">?/span>
<span className="font-medium text-red-900">{dataStats.missingRate.toFixed(1)}%</span>
</div>
</div>
@@ -1143,26 +1143,26 @@ const InsightsPanel: React.FC<InsightsPanelProps> = ({ dataStats }) => {
export default InsightsPanel;
```
**交付物**
- ✅ 文件上传功能
- Insights面板
**浜や粯鐗?*锛?
- 鉁?鏂囦欢涓婁紶鍔熻兘
- 鉁?Insights闈㈡澘
---
## 馃幆 Day 4-5 楠屾敹鏍囧噯
### 必达目标MVP
- [x] **页面可访问**Portal可点击进入Tool C
### 蹇呰揪鐩<EFBFBD>爣锛圡VP锛?
- [x] **椤甸潰鍙<EFBFBD><EFBFBD>闂?*锛歅ortal鍙<6C>偣鍑昏繘鍏<E7B998>ool C
- [x] **鏂囦欢涓婁紶**锛氭敮鎸丆SV/Excel涓婁紶
- [x] **表格展示**AG Grid渲染真实数据cqol-demo.csv
- [x] **AI对话**右侧Chat面板可发送消息
- [x] **代码生成**AI生成Python代码并显示
- [x] **琛ㄦ牸灞曠ず**锛欰G Grid娓叉煋鐪熷疄鏁版嵁锛坈qol-demo.csv锛?
- [x] **AI瀵硅瘽**锛氬彸渚<E5BDB8>hat闈㈡澘鍙<E6BE98>彂閫佹秷鎭?
- [x] **浠g爜鐢熸垚**锛欰I鐢熸垚Python浠爜骞舵樉绀?
- [x] **浠爜鎵ц<E98EB5>**锛氱偣鍑绘墽琛屾寜閽<E5AF9C>紝琛ㄦ牸鏁版嵁鏇存柊
- [x] **对话历史**:多轮对话正常显示
- [x] **瀵硅瘽鍘嗗彶**锛氬<E9949B><EFBFBD><E69D9E>璇濇<E79287>甯告樉绀?
### 可选目标Day 6优化
- [ ] 单元格手动编辑
- [ ] 工具栏按钮功能
### <EFBFBD>€夌洰鏍囷紙Day 6浼樺寲锛?
- [ ] 鍗曞厓鏍兼墜鍔ㄧ紪杈?
- [ ] 宸ュ叿鏍忔寜閽<EFBFBD>姛鑳?
- [ ] 鎾ら攢/閲嶅仛
- [ ] 瀵煎嚭Excel
- [ ] 鏁版嵁娲炲療鍗$墖瀹屽杽
@@ -1172,40 +1172,40 @@ export default InsightsPanel;
## 馃摑 娴嬭瘯鍦烘櫙
### 场景1上传文件
### 鍦烘櫙1锛氫笂浼犳枃浠?
1. 璁块棶 `/data-cleaning/tool-c`
2. 鐐瑰嚮"涓婁紶CSV/Excel鏂囦欢"
3. 閫夋嫨 `cqol-demo.csv`
4. 验证表格显示21列x300+行数据
4. 楠岃瘉锛氳〃鏍兼樉绀?1鍒梮300+琛屾暟鎹?
### 场景2AI缺失值处理
1. 在Chat输入:"把sex列的缺失值填补为众数"
### 鍦烘櫙2锛欰I缂哄け鍊煎<EFBFBD>鐞?
1. 鍦–hat杈撳叆锛?鎶妔ex鍒楃殑缂哄け鍊煎琛ヤ负浼楁暟"
2. 楠岃瘉锛欰I鐢熸垚浠
3. 鐐瑰嚮"鎵ц<E98EB5>爜"
4. 验证:表格数据更新,缺失值消失
4. 楠岃瘉锛氳〃鏍兼暟鎹<EFBFBD>洿鏂帮紝缂哄け鍊兼秷澶?
### 鍦烘櫙3锛欰I骞撮緞鍒嗙粍
1. 在Chat输入:"把age列按18、60分为未成年、成年、老年三组"
1. 鍦–hat杈撳叆锛?鎶奱ge鍒楁寜18銆?0鍒嗕负鏈<E8B49F>垚骞淬€佹垚骞淬€佽€佸勾涓夌粍"
2. 楠岃瘉锛欰I鐢熸垚浠
3. 鐐瑰嚮"鎵ц<E98EB5>爜"
4. 验证表格新增age_group
4. 楠岃瘉锛氳〃鏍兼柊澧瀉ge_group鍒?
### 场景4对话历史
1. 发送多条消息
2. 验证:所有对话保留
### 鍦烘櫙4锛氬<EFBFBD>璇濆巻鍙?
1. 鍙戦€佸<EFBFBD>鏉℃秷鎭?
2. 楠岃瘉锛氭墍鏈夊<EFBFBD>璇濅繚鐣?
3. 鍒锋柊椤甸潰
4. 验证:对话历史加载正常
4. 楠岃瘉锛氬<EFBFBD>璇濆巻鍙插姞杞芥<EFBFBD>甯?
---
## 🚨 风险与应对
## 馃毃 椋庨櫓涓庡簲瀵?
| 椋庨櫓 | 姒傜巼 | 褰卞搷 | 搴斿<E690B4><EFBFBD>柦 |
|------|------|------|---------|
| AG Grid学习成本高 | 中 | 中 | Day 4上午集中学习官方文档 |
| API调试时间长 | 高 | 中 | 先用Mock数据再对接真实API |
| 代码语法高亮问题 | 低 | 低 | Prism.js配置不复杂有现成方案 |
| 性能问题300+行数据)| 低 | 低 | AG Grid自带虚拟滚动无需优化 |
| AG Grid瀛︿範鎴愭湰楂?| 涓?| 涓?| Day 4涓婂崍闆嗕腑瀛︿範瀹樻柟鏂囨。 |
| API璋冭瘯鏃堕棿闀?| 楂?| 涓?| 鍏堢敤Mock鏁版嵁锛屽啀瀵规帴鐪熷疄API |
| 爜璇<EFBFBD>硶楂樹寒闂<EFBFBD><EFBFBD> | 浣?| 浣?| Prism.js閰嶇疆涓嶅<E6B693>鏉傦紝鏈夌幇鎴愭柟妗?|
| 鎬ц兘闂<EFBFBD><EFBFBD>锛?00+琛屾暟鎹<E69A9F>級| 浣?| 浣?| AG Grid鑷<64>甫铏氭嫙婊氬姩锛屾棤闇€浼樺寲 |
---
@@ -1221,7 +1221,7 @@ npm install prismjs @types/prismjs
# Markdown娓叉煋锛堝彲閫夛級
npm install react-markdown
# 已有依赖(无需安装)
# 宸叉湁渚濊禆锛堟棤闇€瀹夎<EFBFBD>锛?
# - react
# - react-router-dom
# - lucide-react
@@ -1231,7 +1231,7 @@ npm install react-markdown
---
## 📚 参考资源
## 馃摎 鍙傝€冭祫婧?
- [AG Grid React Documentation](https://www.ag-grid.com/react-data-grid/)
- [Prism.js Syntax Highlighting](https://prismjs.com/)
@@ -1240,13 +1240,13 @@ npm install react-markdown
---
## ✅ 最终交付物清单
## 鉁?鏈€缁堜氦浠樼墿娓呭崟
### Day 4
- [x] 文件结构创建10个文件
- [x] 鏂囦欢缁撴瀯鍒涘缓锛?0涓<30>枃浠讹級
- [x] Header缁勪欢
- [x] Toolbar缁勪欢
- [x] DataGrid组件AG Grid
- [x] DataGrid缁勪欢锛圓G Grid锛?
- [x] 鍩虹<E98DA9>甯冨眬瀹屾垚
### Day 5
@@ -1256,20 +1256,20 @@ npm install react-markdown
- [x] CodeBlock缁勪欢
- [x] InputArea缁勪欢
- [x] InsightsPanel缁勪欢
- [x] API封装toolC.ts
- [x] API灏佽<EFBFBD>锛坱oolC.ts锛?
- [x] useToolC Hook
- [x]<>埌绔<E59F8C>祦绋嬫祴璇曢€氳繃
### 鏂囨。
- [x] 本开发计划
- [x] <EFBFBD>紑鍙戣<EFBFBD>鍒?
- [ ] Day 4-5寮€鍙戝畬鎴愭€荤粨锛圖ay 5缁撴潫鍚庯級
- [ ] API瀵规帴鏂囨。锛圖ay 5缁撴潫鍚庯級
---
**制定人**: AI Assistant
**确认人**: 用户
**开始时间**: Day 4上午
**鍒跺畾浜?*: AI Assistant
**<EFBFBD><EFBFBD>浜?*: 鐢ㄦ埛
**寮€濮嬫椂闂?*: Day 4涓婂崍
**棰勬湡瀹屾垚**: Day 5涓嬪崍
---
@@ -1326,5 +1326,6 @@ npm install react-markdown