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

Major Updates:
- Add StreamingService with OpenAI Compatible format (backend/common/streaming)
- Upgrade Chat component V2 with Ant Design X integration
- Implement AIA module with 12 intelligent agents
- Create AgentHub with 100% prototype V11 restoration
- Create ChatWorkspace with streaming response support
- Add ThinkingBlock for deep thinking display
- Add useAIStream Hook for OpenAI Compatible stream handling

Backend Common Capabilities (~400 lines):
- OpenAIStreamAdapter: SSE adapter with OpenAI format
- StreamingService: unified streaming service
- Support content and reasoning_content dual streams
- Deep thinking tag processing (<think>...</think>)

Frontend Common Capabilities (~2000 lines):
- AIStreamChat: modern streaming chat component
- ThinkingBlock: collapsible deep thinking display
- ConversationList: conversation management with grouping
- useAIStream: OpenAI Compatible stream handler Hook
- useConversations: conversation state management Hook
- Modern design styles (Ultramodern theme)

AIA Module Frontend (~1500 lines):
- AgentHub: 12 agent cards with timeline design
- ChatWorkspace: fullscreen immersive chat interface
- AgentCard: theme-colored cards (blue/yellow/teal/purple)
- 5 phases, 12 agents configuration
- Responsive layout (desktop + mobile)

AIA Module Backend (~900 lines):
- agentService: 12 agents config with system prompts
- conversationService: refactored with StreamingService
- attachmentService: file upload skeleton (30k token limit)
- 12 API endpoints with authentication
- Full CRUD for conversations and messages

Documentation:
- AIA module status and development guide
- Universal capabilities catalog (11 services)
- Quick reference card for developers
- System overview updates

Testing:
- Stream response verified (HTTP 200)
- Authentication working correctly
- Auto conversation creation working
- Deep thinking display working
- Message input and send working

Status: Core features completed (85%), attachment and history loading pending
This commit is contained in:
2026-01-14 19:09:28 +08:00
parent 4ed67a8846
commit 3d35e9c58b
38 changed files with 8448 additions and 335 deletions

View File

@@ -0,0 +1,172 @@
/**
* AIA 模块常量配置
*
* 12个智能体模块配置100%还原原型图V11
*/
import type { AgentConfig, PhaseConfig } from './types';
/**
* 阶段配置
*/
export const PHASES: PhaseConfig[] = [
{ phase: 1, name: '选题优化智能体', theme: 'blue' },
{ phase: 2, name: '方案设计智能体', theme: 'blue' },
{ phase: 3, name: '方案预评审', theme: 'yellow' },
{ phase: 4, name: '数据处理与统计分析', theme: 'teal', isTool: true },
{ phase: 5, name: '写作助手', theme: 'purple' },
];
/**
* 12个智能体配置
*/
export const AGENTS: AgentConfig[] = [
// Phase 1: 选题优化智能体 (3个每行3个)
{
id: 'TOPIC_01',
name: '科学问题梳理',
icon: 'list-tree',
description: '从科学问题的清晰度、系统性、可验证性等角度使用科学理论对您的科学问题进行全面的评价。',
theme: 'blue',
phase: 1,
order: 1,
},
{
id: 'TOPIC_02',
name: 'PICO 梳理',
icon: 'target',
description: '基于科学问题梳理研究对象、干预(暴露)、对照和结局指标,并评价并给出合理化的建议。',
theme: 'blue',
phase: 1,
order: 2,
},
{
id: 'TOPIC_03',
name: '选题评价',
icon: 'clipboard-check',
description: '从创新性、临床价值、科学性和可行性等方面使用科学理论对您的临床问题进行全面的评价。',
theme: 'blue',
phase: 1,
order: 3,
},
// Phase 2: 方案设计智能体 (4个每行3个)
{
id: 'DESIGN_04',
name: '观察指标设计',
icon: 'eye',
description: '基于研究设计和因果关系提供可能的观察指标集。',
theme: 'blue',
phase: 2,
order: 4,
},
{
id: 'DESIGN_05',
name: '病例报告表设计',
icon: 'table',
description: '基于研究方案设计梳理观察指标集并给出建议的病例报告表框架。',
theme: 'blue',
phase: 2,
order: 5,
},
{
id: 'DESIGN_06',
name: '样本量计算',
icon: 'calculator',
description: '基于研究阶段和研究设计为研究提供科学合理的样本量估算结果。',
theme: 'blue',
phase: 2,
order: 6,
},
{
id: 'DESIGN_07',
name: '临床研究方案撰写',
icon: 'file-text',
description: '基于科学问题、PICOS等信息给出一个初步的临床研究设计方案请尽量多给一些信息和需求。',
theme: 'blue',
phase: 2,
order: 7,
},
// Phase 3: 方案预评审 (1个)
{
id: 'REVIEW_08',
name: '方法学评审智能体',
icon: 'shield-check',
description: '从研究问题、研究方案和临床意义方面,对研究进行临床研究方法学的全面评价。',
theme: 'yellow',
phase: 3,
order: 8,
},
// Phase 4: 数据处理与统计分析 (2个工具类)
{
id: 'TOOL_09',
name: '数据评价与预处理',
icon: 'database',
description: '对现有数据的质量进行自动评价,并给出数据质量报告,包括缺失值、异常值、定量分析等。',
theme: 'teal',
phase: 4,
order: 9,
isTool: true,
toolUrl: '/dc',
},
{
id: 'TOOL_10',
name: '智能统计分析',
icon: 'bar-chart-2',
description: '内置3条智能研究路径队列研究、预测模型、RCT研究以及近百种统计分析工具。',
theme: 'teal',
phase: 4,
order: 10,
isTool: true,
toolUrl: '/dc/analysis',
},
// Phase 5: 写作助手 (2个)
{
id: 'WRITING_11',
name: '论文润色',
icon: 'pen-tool',
description: '结合目标杂志,提供专业化的润色服务,给出合理化的修改建议。',
theme: 'purple',
phase: 5,
order: 11,
},
{
id: 'WRITING_12',
name: '论文翻译',
icon: 'languages',
description: '结合目标杂志,提供专业化的翻译并进行润色,给出合理化的修改建议。',
theme: 'purple',
phase: 5,
order: 12,
},
];
/**
* 智能体欢迎语配置
*/
export const AGENT_PROMPTS: Record<string, string> = {
'TOPIC_01': '你好!我是**科学问题梳理助手**。请告诉我你感兴趣的研究方向,我将从科学性、创新性等维度帮你梳理。',
'TOPIC_02': '你好!我是**PICO梳理助手**。请描述你的研究想法,我来帮你拆解为 P (人群)、I (干预)、C (对照)、O (结局)。',
'TOPIC_03': '你好!我是**选题评价助手**。请提供你的初步选题,我将从创新性、临床价值等方面进行评估。',
'DESIGN_04': '你好!我是**观察指标设计助手**。请告诉我你的研究目的,我来帮你推荐主要和次要观察指标。',
'DESIGN_05': '你好!我是**CRF设计助手**。我可以帮你构建病例报告表的框架。',
'DESIGN_06': '你好需要计算样本量吗请告诉我研究类型如RCT、队列研究和主要指标的预期值。',
'DESIGN_07': '你好!欢迎来到**方案设计工作台**。我们将基于科学问题和PICOS信息共同撰写一份完整的临床研究方案。',
'REVIEW_08': '你好!我是**方法学评审助手**。请上传你的方案草稿,我将模拟审稿人视角进行方法学审查。',
'WRITING_11': 'Please paste the text you want to polish. I will check grammar, flow, and academic tone.',
'WRITING_12': '你好!请贴入需要翻译的段落,我将为你提供地道的学术英语翻译。',
};
/**
* 品牌配色
*/
export const BRAND_COLORS = {
blue: '#4F6EF2',
teal: '#0D9488',
purple: '#9333EA',
yellow: '#CA8A04',
} as const;