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:
@@ -2,43 +2,43 @@
|
||||
|
||||
## 📋 问题æ<CB9C><C3A6>è¿°
|
||||
|
||||
**用户需求**:长宽转换后,列的排序应该与上传文件时的列顺序保持一致。
|
||||
**用户需æ±?*:长宽转æ<C2AC>¢å<C2A2>Žï¼Œåˆ—的排åº<C3A5>åº”è¯¥ä¸Žä¸Šä¼ æ–‡ä»¶æ—¶çš„åˆ—é¡ºåº<C3A5>ä¿<C3A4>æŒ<C3A6>一致ã€?
|
||||
|
||||
**当前问题**:系统按字母顺序排列转换后的列,导致顺序与原文件不一致。
|
||||
**当å‰<EFBFBD>问题**ï¼šç³»ç»ŸæŒ‰å—æ¯<C3A6>顺åº<C3A5>排列转æ<C2AC>¢å<C2A2>Žçš„列,导致顺åº<C3A5>与原文件ä¸<C3A4>一致ã€?
|
||||
|
||||
---
|
||||
|
||||
## 🎯 解决方案:方案A - Python端排序
|
||||
## 🎯 解决方案:方案A - Python端排�
|
||||
|
||||
### æ ¸å¿ƒæ€<C3A6>è·¯
|
||||
1. Node.js后端从session获取**原始列顺序**
|
||||
2. Node.js后端从数据中提取**透视列值的原始顺序**(按首次出现顺序)
|
||||
1. Node.jså<EFBFBD>Žç«¯ä»Žsession获å<EFBFBD>–**原始列顺åº?*
|
||||
2. Node.jså<EFBFBD>Žç«¯ä»Žæ•°æ<EFBFBD>®ä¸æ<EFBFBD><EFBFBD>å<EFBFBD>–**é€<C3A9>视列值的原始顺åº<C3A5>**(按首次出现顺åº<C3A5>ï¼?
|
||||
3. ä¼ é€’ç»™Python
|
||||
4. Python在pivotå<74>Žï¼ŒæŒ‰åŽŸå§‹é¡ºåº<C3A5>é‡<C3A9>排列
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ 实现细节
|
||||
## 🛠�实现细节
|
||||
|
||||
### 1. Python端(pivot.py)
|
||||
### 1. Python端(pivot.py�
|
||||
|
||||
**新增参数**:
|
||||
- `original_column_order: List[str]`:原始列顺序(如`['Record ID', 'Event Name', 'FMA', '体重', '收缩压', ...]`)
|
||||
- `pivot_value_order: List[str]`:透视列值的原始顺序(如`['基线', '1个月', '2个月', ...]`)
|
||||
**新增å<EFBFBD>‚æ•°**ï¼?
|
||||
- `original_column_order: List[str]`:原始列顺åº<EFBFBD>(如`['Record ID', 'Event Name', 'FMA', '体é‡<EFBFBD>', '收缩åŽ?, ...]`ï¼?
|
||||
- `pivot_value_order: List[str]`:é€<EFBFBD>视列值的原始顺åº<EFBFBD>(如`['基线', '1个月', '2个月', ...]`ï¼?
|
||||
|
||||
**排序逻辑**:
|
||||
**排åº<EFBFBD>逻辑**ï¼?
|
||||
```python
|
||||
if original_column_order:
|
||||
# 1. 索引列始终在最å‰<C3A5>é<EFBFBD>¢
|
||||
final_cols = [index_column]
|
||||
|
||||
# 2. 按原始列顺序添加转换后的列
|
||||
# 2. 按原始列顺åº<EFBFBD>æ·»åŠ è½¬æ<EFBFBD>¢å<EFBFBD>Žçš„åˆ?
|
||||
for orig_col in original_column_order:
|
||||
if orig_col in value_columns:
|
||||
# 找出所有属于这个原列的新列
|
||||
related_cols = [c for c in df_pivot.columns if c.startswith(f'{orig_col}___')]
|
||||
|
||||
# ✨ 按透视列的原始顺序排序
|
||||
# âœ?按é€<C3A9>视列的原始顺åº<C3A5>排åº<C3A5>
|
||||
if pivot_value_order:
|
||||
pivot_order_map = {val: idx for idx, val in enumerate(pivot_value_order)}
|
||||
related_cols_sorted = sorted(
|
||||
@@ -56,21 +56,21 @@ if original_column_order:
|
||||
if orig_col in df_pivot.columns and orig_col not in final_cols:
|
||||
final_cols.append(orig_col)
|
||||
|
||||
# 4. 重排列
|
||||
# 4. é‡<EFBFBD>排åˆ?
|
||||
df_pivot = df_pivot[final_cols]
|
||||
```
|
||||
|
||||
### 2. Python端(main.py)
|
||||
### 2. Python端(main.py�
|
||||
|
||||
**PivotRequest模型**:
|
||||
**PivotRequest模型**�
|
||||
```python
|
||||
class PivotRequest(BaseModel):
|
||||
# ... åŽŸæœ‰å—æ®µ ...
|
||||
original_column_order: List[str] = [] # ✨ 新增
|
||||
pivot_value_order: List[str] = [] # ✨ 新增
|
||||
original_column_order: List[str] = [] # �新增
|
||||
pivot_value_order: List[str] = [] # �新增
|
||||
```
|
||||
|
||||
**调用pivot_long_to_wide**:
|
||||
**调用pivot_long_to_wide**�
|
||||
```python
|
||||
result_df = pivot_long_to_wide(
|
||||
df,
|
||||
@@ -81,19 +81,19 @@ result_df = pivot_long_to_wide(
|
||||
request.column_mapping,
|
||||
request.keep_unused_columns,
|
||||
request.unused_agg_method,
|
||||
request.original_column_order, # ✨ 新增
|
||||
request.pivot_value_order # ✨ 新增
|
||||
request.original_column_order, # �新增
|
||||
request.pivot_value_order # �新增
|
||||
)
|
||||
```
|
||||
|
||||
### 3. Node.js后端(QuickActionController.ts)
|
||||
### 3. Node.jså<EFBFBD>Žç«¯ï¼ˆQuickActionController.tsï¼?
|
||||
|
||||
**获取原始列顺序**:
|
||||
**获å<EFBFBD>–原始列顺åº?*ï¼?
|
||||
```typescript
|
||||
const originalColumnOrder = session.columns || [];
|
||||
```
|
||||
|
||||
**获取透视列值的原始顺序**:
|
||||
**获å<EFBFBD>–é€<EFBFBD>视列值的原始顺åº<EFBFBD>**ï¼?
|
||||
```typescript
|
||||
const pivotColumn = params.pivotColumn;
|
||||
const seenPivotValues = new Set();
|
||||
@@ -108,36 +108,36 @@ for (const row of fullData) {
|
||||
}
|
||||
```
|
||||
|
||||
**传递给QuickActionService**:
|
||||
**ä¼ é€’ç»™QuickActionService**ï¼?
|
||||
```typescript
|
||||
executeResult = await quickActionService.executePivot(
|
||||
fullData,
|
||||
params,
|
||||
session.columnMapping,
|
||||
originalColumnOrder, // ✨ 新增
|
||||
pivotValueOrder // ✨ 新增
|
||||
originalColumnOrder, // �新增
|
||||
pivotValueOrder // �新增
|
||||
);
|
||||
```
|
||||
|
||||
### 4. Node.js后端(QuickActionService.ts)
|
||||
### 4. Node.jså<EFBFBD>Žç«¯ï¼ˆQuickActionService.tsï¼?
|
||||
|
||||
**方法签名**:
|
||||
**方法ç¾å<EFBFBD><EFBFBD>**ï¼?
|
||||
```typescript
|
||||
async executePivot(
|
||||
data: any[],
|
||||
params: PivotParams,
|
||||
columnMapping?: any[],
|
||||
originalColumnOrder?: string[], // ✨ 新增
|
||||
pivotValueOrder?: string[] // ✨ 新增
|
||||
originalColumnOrder?: string[], // �新增
|
||||
pivotValueOrder?: string[] // �新增
|
||||
): Promise<OperationResult>
|
||||
```
|
||||
|
||||
**传递给Python**:
|
||||
**ä¼ é€’ç»™Python**ï¼?
|
||||
```typescript
|
||||
const response = await axios.post(`${PYTHON_SERVICE_URL}/api/operations/pivot`, {
|
||||
// ... 原有å<E280B0>‚æ•° ...
|
||||
original_column_order: originalColumnOrder || [], // ✨ 新增
|
||||
pivot_value_order: pivotValueOrder || [], // ✨ 新增
|
||||
original_column_order: originalColumnOrder || [], // �新增
|
||||
pivot_value_order: pivotValueOrder || [], // �新增
|
||||
});
|
||||
```
|
||||
|
||||
@@ -148,45 +148,46 @@ const response = await axios.post(`${PYTHON_SERVICE_URL}/api/operations/pivot`,
|
||||
### 修改å‰<C3A5>ï¼ˆæŒ‰å—æ¯<C3A6>顺åº<C3A5>)
|
||||
```
|
||||
Record ID | FMA___基线 | FMA___1个月 | 收缩压___基线 | 收缩压___1个月 | 体é‡<C3A9>___基线 | 体é‡<C3A9>___1个月
|
||||
↑ ↑ ↑ ↑ ↑ ↑ ↑
|
||||
索引列 F开头 F开头 S开头(拼音) S开头 T开头 T开头
|
||||
� � � � � � �
|
||||
索引� F开� F开� S开�拼音) S开� T开� T开�
|
||||
```
|
||||
|
||||
### 修改å<C2B9>Žï¼ˆæŒ‰åŽŸå§‹é¡ºåº<C3A5>)
|
||||
```
|
||||
Record ID | FMA___基线 | FMA___1个月 | 体é‡<C3A9>___基线 | 体é‡<C3A9>___1个月 | 收缩压___基线 | 收缩压___1个月
|
||||
↑ ↑ ↑ ↑ ↑ ↑ ↑
|
||||
索引列 原文件第3列 原文件第3列 原文件第4列 原文件第4列 原文件第5列 原文件第5列
|
||||
� � � � � � �
|
||||
索引� 原文件第3� 原文件第3� 原文件第4� 原文件第4� 原文件第5� 原文件第5�
|
||||
```
|
||||
|
||||
### é€<C3A9>视值内部顺åº<C3A5>(按原始出现顺åº<C3A5>)
|
||||
```
|
||||
FMA___基线 | FMA___1个月 | FMA___2个月
|
||||
↑ ↑ ↑
|
||||
首次出现 第二次出现 第三次出现
|
||||
(而不是按"1个月"、"2个月"、"基线"的字母顺序)
|
||||
� � �
|
||||
首次出现 第二次出� 第三次出�
|
||||
(而ä¸<EFBFBD>是按"1个月"ã€?2个月"ã€?基线"çš„å—æ¯<C3A6>顺åº<C3A5>)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ✅ 开发完成
|
||||
## âœ?å¼€å<E282AC>‘完æˆ?
|
||||
|
||||
### 修改文件清å<E280A6>•
|
||||
1. ✅ `extraction_service/operations/pivot.py`
|
||||
2. ✅ `extraction_service/main.py`
|
||||
3. ✅ `backend/src/modules/dc/tool-c/controllers/QuickActionController.ts`
|
||||
4. ✅ `backend/src/modules/dc/tool-c/services/QuickActionService.ts`
|
||||
1. �`extraction_service/operations/pivot.py`
|
||||
2. �`extraction_service/main.py`
|
||||
3. �`backend/src/modules/dc/tool-c/controllers/QuickActionController.ts`
|
||||
4. �`backend/src/modules/dc/tool-c/services/QuickActionService.ts`
|
||||
|
||||
### 优势
|
||||
- ✅ 列顺序与原文件一致(用户熟悉)
|
||||
- ✅ 透视值顺序按时间顺序(基线→1个月→2个月)
|
||||
- ✅ 未选择的列也保持原始顺序
|
||||
- ✅ 导出Excel时顺序正确
|
||||
- âœ?列顺åº<C3A5>与原文件一致(用户熟悉ï¼?
|
||||
- âœ?é€<C3A9>视值顺åº<C3A5>按时间顺åº<C3A5>(基线→1个月â†?个月ï¼?
|
||||
- âœ?未选择的列也ä¿<C3A4>æŒ<C3A6>原始顺åº?
|
||||
- âœ?导出Excel时顺åº<C3A5>æ£ç¡?
|
||||
|
||||
---
|
||||
|
||||
**开发时间**:2025-12-09
|
||||
**状态**:✅ 已完成,等待测试
|
||||
**å¼€å<EFBFBD>‘æ—¶é—?*ï¼?025-12-09
|
||||
**状æ€?*:✅ 已完æˆ<C3A6>,ç‰å¾…测试
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user