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,25 +1,25 @@
# CloseAI髮<49><E9ABAE><EFBFBD>
> **文档版本:** v1.0
> **创建日期:** 2025-11-09
> **<EFBFBD>。」迚域悽<EFBFBD>?* v1.0
> **蛻帛サコ譌・譛滂シ?* 2025-11-09
> **逕ィ騾費シ<E8B2BB>** 騾夊ソ④loseAI莉」逅<EFBDA3>ケウ蜿ー隶ソ髣ョOpenAI GPT-5蜥靴laude-4.5
> **适用场景:** AI智能文献双模型筛选、高质量文本生成
> **騾ら畑蝨コ譎ッ<EFBFBD>?* AI譎コ閭ス譁<EFBDBD>鍵蜿梧ィ。蝙狗ュ幃€€<E5B3A8>ォ倩エィ驥乗枚譛ャ逕滓<E98095>
---
## 📋 CloseAI简介
## <EFBFBD> CloseAI邂€莉?
### 什么是CloseAI
### 莉€荵域弍CloseAI<EFBFBD>?
CloseAI是一个**API代理平台**,为中国用户提供稳定的OpenAI和Claude API访问服务。
CloseAI譏ッ荳€荳?*API莉」逅<EFBDA3>ケウ蜿ー**<2A>御クコ荳ュ蝗ス逕ィ謌キ謠蝉セ帷ィウ螳夂噪OpenAI蜥靴laude API隶ソ髣ョ譛榊苅縲?
**核心优势:**
- ✅ 国内直连,无需科学上网
- ✅ 一个API Key同时调用OpenAI和Claude
- ✅ 兼容OpenAI SDK标准接口
- ✅ 支持最新模型GPT-5、Claude-4.5
**譬ク蠢<EFBFBD>シ伜漢<EFBFBD>?*
- 笨?蝗ス蜀<EFBDBD>峩霑橸シ梧裏髴€遘大ュヲ荳顔ス<E9A194>
- 笨?荳€荳ェAPI Key蜷梧慮隹<EFBFBD>OpenAI蜥靴laude
- 笨?蜈シ螳ケOpenAI SDK<EFBFBD>㊥謗・蜿」
- 笨?謾ッ謖∵怙譁ー讓。蝙具シ<E585B7>PT-5縲,laude-4.5<EFBFBD>?
**官网:** https://platform.openai-proxy.org
**螳倡ス托シ?* https://platform.openai-proxy.org
---
@@ -38,15 +38,15 @@ CLOSEAI_OPENAI_BASE_URL=https://api.openai-proxy.org/v1
CLOSEAI_CLAUDE_BASE_URL=https://api.openai-proxy.org/anthropic
```
### 支持的模型
### 謾ッ謖∫噪讓。蝙?
| 讓。蝙<EFBDA1> | Model ID | 隸エ譏<EFBDB4> | 騾ら畑蝨コ譎ッ |
|------|---------|------|---------|
| **GPT-5-Pro** | `gpt-5-pro` | 最新GPT-5 ⭐ | 文献精准筛选、复杂推理 |
| GPT-4-Turbo | `gpt-4-turbo-preview` | GPT-4高性能版 | 质量要求高的任务 |
| GPT-3.5-Turbo | `gpt-3.5-turbo` | 快速经济版 | 简单任务、成本优化 |
| **Claude-4.5-Sonnet** | `claude-sonnet-4-5-20250929` | 最新Claude ⭐ | 第三方仲裁、结构化输出 |
| Claude-3.5-Sonnet | `claude-3-5-sonnet-20241022` | Claude-3.5稳定版 | 高质量文本生成 |
| **GPT-5-Pro** | `gpt-5-pro` | 譛€譁ーGPT-5 箝?| 譁<>鍵邊セ蜃<EFBDBE>ュ幃€€∝、肴揩謗ィ逅?|
| GPT-4-Turbo | `gpt-4-turbo-preview` | GPT-4鬮俶€ァ閭ス迚?| 雍ィ驥剰ヲ∵アるォ倡噪莉サ蜉。 |
| GPT-3.5-Turbo | `gpt-3.5-turbo` | 蠢ォ騾溽サ乗オ守沿 | 邂€蜊穂ササ蜉。縲∵<E7B8B2>譛ャ莨伜<E88EA8>?|
| **Claude-4.5-Sonnet** | `claude-sonnet-4-5-20250929` | 譛€譁ーClaude 箝?| 隨ャ荳画婿莉イ陬√€∫サ捺桷蛹冶セ灘<EFBDBE> |
| Claude-3.5-Sonnet | `claude-3-5-sonnet-20241022` | Claude-3.5遞ウ螳夂<EFBFBD>?| 鬮倩エィ驥乗枚譛ャ逕滓<E98095>?|
---
@@ -58,9 +58,9 @@ CLOSEAI_CLAUDE_BASE_URL=https://api.openai-proxy.org/anthropic
npm install openai
```
### 2. 创建LLM服务类
### 2. 蛻帛サコLLM譛榊苅邀?
**文件位置:** `backend/src/common/llm/closeai.service.ts`
**<EFBFBD>サカ菴咲スョ<EFBFBD>?* `backend/src/common/llm/closeai.service.ts`
```typescript
import OpenAI from 'openai';
@@ -71,13 +71,13 @@ export class CloseAIService {
private claudeClient: OpenAI;
constructor() {
// OpenAI客户端通过CloseAI
// OpenAI螳「謌キ遶ッ<EFBFBD>€夊ソ④loseAI<EFBFBD>?
this.openaiClient = new OpenAI({
apiKey: config.closeaiApiKey,
baseURL: config.closeaiOpenaiBaseUrl,
});
// Claude客户端通过CloseAI
// Claude螳「謌キ遶ッ<EFBFBD>€夊ソ④loseAI<EFBFBD>?
this.claudeClient = new OpenAI({
apiKey: config.closeaiApiKey,
baseURL: config.closeaiClaudeBaseUrl,
@@ -135,7 +135,7 @@ export class CloseAIService {
}
/**
* 流式响应GPT-5
* 豬∝シ丞桃蠎費シ<EFBFBD>PT-5<EFBFBD>?
*/
async *streamGPT5(prompt: string, systemPrompt?: string) {
const messages: any[] = [];
@@ -165,7 +165,7 @@ export class CloseAIService {
### 3. 扈滉ク€LLM譛榊苅<E6A68A>亥性4荳ェ讓。蝙具シ<E585B7>
**文件位置:** `backend/src/common/llm/llm.service.ts`
**<EFBFBD>サカ菴咲スョ<EFBFBD>?* `backend/src/common/llm/llm.service.ts`
```typescript
import OpenAI from 'openai';
@@ -258,7 +258,7 @@ export class UnifiedLLMService {
### 蝨コ譎ッ1<EFBDAF>壼曙讓。蝙句ッケ豈皮ュ幃€会シ域耳闕撰シ俄ュ<E4BF84>
**策略:** DeepSeek(快速初筛) + GPT-5质量复核
**遲也払<EFBFBD>?* DeepSeek<EFBFBD>亥ソォ騾溷<EFBFBD>遲幢シ<EFBFBD> + GPT-5<>郁エィ驥丞、肴<EFBDA4><EFBFBD><EFBDB8>
```typescript
export class LiteratureScreeningService {
@@ -269,23 +269,23 @@ export class LiteratureScreeningService {
}
/**
* 双模型文献筛选
* 蜿梧ィ。蝙区枚迪ョ遲幃€?
*/
async screenLiterature(title: string, abstract: string, picoConfig: any) {
const prompt = `
隸キ譬ケ謐ョ莉・荳輝ICO譬<EFBFBD><EFBFBD>悟愛譁ュ霑咏ッ<EFBFBD>枚迪ョ譏ッ蜷ヲ蠎碑ッ・郤ウ蜈・<EFBFBD><EFBFBD>
**PICO标准:**
**PICO<EFBFBD><EFBFBD>?*
- Population: ${picoConfig.population}
- Intervention: ${picoConfig.intervention}
- Comparison: ${picoConfig.comparison}
- Outcome: ${picoConfig.outcome}
**文献信息:**
标题:${title}
摘要:${abstract}
**<EFBFBD>鍵菫。諱ッ<EFBFBD>?*
<EFBFBD>「假シ?{title}
鞫倩ヲ<EFBFBD>シ?{abstract}
请输出JSON格式
隸キ霎灘<EFBFBD>JSON譬シ蠑擾シ?
{
"decision": "include/exclude/uncertain",
"reason": "蛻、譁ュ逅<EFBDAD>罰",
@@ -325,11 +325,11 @@ export class LiteratureScreeningService {
### 蝨コ譎ッ2<EFBDAF>壻ク画ィ。蝙句<E89D99><EFBFBD>サイ陬<EFBDB2>
**策略:** 当两个模型冲突时启用Claude作为第三方仲裁
**遲也払<EFBFBD>?* 蠖謎ク、荳ェ讓。蝙句<E89D99>遯∵慮<E288B5>悟星逕ィClaude菴應クコ隨ャ荳画婿莉イ陬?
```typescript
async screenWithArbitration(title: string, abstract: string, picoConfig: any) {
// 第一轮:双模型筛选
// 隨ャ荳€霓ョ<EFBFBD>壼曙讓。蝙狗ュ幃€?
const initialScreen = await this.screenLiterature(title, abstract, picoConfig);
// 螯よ棡荳€閾エ<E996BE>檎峩謗・霑泌屓
@@ -343,7 +343,7 @@ async screenWithArbitration(title: string, abstract: string, picoConfig: any) {
const claudeResult = await this.llm.chat('claude', prompt);
const claudeDecision = JSON.parse(claudeResult.content);
// 三模型投票
// 荳画ィ。蝙区兜逾?
const decisions = [
initialScreen.models[0].decision,
initialScreen.models[1].decision,
@@ -356,7 +356,7 @@ async screenWithArbitration(title: string, abstract: string, picoConfig: any) {
uncertain: decisions.filter(d => d === 'uncertain').length,
};
// 多数决
// 螟壽焚蜀?
const finalDecision = Object.keys(voteCount).reduce((a, b) =>
voteCount[a] > voteCount[b] ? a : b
);
@@ -370,13 +370,13 @@ async screenWithArbitration(title: string, abstract: string, picoConfig: any) {
}
```
### 场景3成本优化策略
### 蝨コ譎ッ3<EFBFBD><EFBFBD>譛ャ莨伜喧遲也<EFBFBD>?
**策略:** 只对不确定的结果使用GPT-5复核
**遲也払<EFBFBD>?* 蜿ェ蟇ケ荳咲。ョ螳夂噪扈捺棡菴ソ逕ィGPT-5螟肴<EFBFBD>
```typescript
async screenWithCostOptimization(title: string, abstract: string, picoConfig: any) {
// 第一轮用DeepSeek快速初筛便宜
// 隨ャ荳€霓ョ<EFBFBD>夂畑DeepSeek蠢ォ騾溷<EFBFBD>遲幢シ井セソ螳懶シ?
const quickScreen = await this.llm.chat('deepseek', prompt);
const quickDecision = JSON.parse(quickScreen.content);
@@ -405,39 +405,39 @@ async screenWithCostOptimization(title: string, abstract: string, picoConfig: an
---
## 📊 性能和成本对比
## <EFBFBD>投 諤ァ閭ス蜥梧<E89CA5>譛ャ蟇ケ豈?
### 讓。蝙区€ァ閭ス蟇ケ豈<EFBDB9>
| 謖<><E8AC96><EFBFBD> | DeepSeek-V3 | GPT-5-Pro | Claude-4.5 | Qwen-Max |
|------|------------|-----------|-----------|----------|
| **准确率** | 85% | **95%** | 93% | 82% |
| **速度** | **** ⭐ | 中等 | 中等 | |
| **成本** | **¥0.001/1K** ⭐ | ¥0.10/1K | ¥0.021/1K | ¥0.004/1K |
| **中文理解** | **优秀** ⭐ | 优秀 | 良好 | 优秀 |
| **结构化输出** | 良好 | 优秀 | **优秀** ⭐ | 良好 |
| **<EFBFBD>。ョ邇?* | 85% | **95%** 箝?| 93% | 82% |
| **騾溷コヲ** | **蠢?* 箝?| 荳ュ遲<EFBDAD> | 荳ュ遲<EFBDAD> | 蠢?|
| **謌先悽** | **ツ・0.001/1K** 箝?| ツ・0.10/1K | ツ・0.021/1K | ツ・0.004/1K |
| **荳ュ譁<EFBFBD>炊隗」** | **莨倡ァ€** 箝?| 莨倡ァ€ | 濶ッ螂ス | 莨倡ァ€ |
| **扈捺桷蛹冶セ灘<EFBFBD>?* | 濶ッ螂ス | 莨倡ァ€ | **莨倡ァ€** 箝?| 濶ッ螂ス |
### 筛选1000篇文献的成本估算
### 遲幃€?000遽<30>枚迪ョ逧<EFBDAE><E980A7>譛ャ莨ー邂<EFBDB0>
**遲也払A<E68995>壼宵逕ィDeepSeek**
- 成本¥20-30
- 謌先悽<EFBFBD>堋?0-30
-<>。ョ邇<EFBDAE><EFBFBD>85%
- 适用:预算有限,可接受一定误差
- 騾ら畑<EFBFBD>夐「<EFBFBD>ョ玲怏髯撰シ悟庄謗・蜿嶺ク€螳夊ッッ蟾?
**策略BDeepSeek + GPT-5 双模型**
- 成本¥150-200
**遲也払B<EFBFBD>eepSeek + GPT-5 蜿梧ィ。蝙?*
- 謌先悽<EFBFBD>堋?50-200
-<>。ョ邇<EFBDAE><EFBFBD>92%
- 适用:质量要求高,预算充足 ⭐ 推荐
- 騾ら畑<EFBFBD>夊エィ驥剰ヲ∵アるォ假シ碁「<EFBFBD>ョ怜<EFBFBD>雜?箝?謗ィ闕<EFBDA8>
**策略C三模型共识20%冲突启用Claude**
- 成本¥180-220
**遲也払C<EFBFBD>壻ク画ィ。蝙句<EFBFBD><EFBFBD>シ?0%蜀イ遯∝星逕ィClaude<64>?*
- 謌先悽<EFBFBD>堋?80-220
-<>。ョ邇<EFBDAE><EFBFBD>95%
- 适用:最高质量要求
- 騾ら畑<EFBFBD>壽怙鬮倩エィ驥剰ヲ∵ア?
**策略D成本优化80%DeepSeek20%用GPT-5**
- 成本¥50-80
**遲也払D<EFBFBD><EFBFBD>譛ャ莨伜喧<EFBFBD><EFBFBD>80%逕ィDeepSeek<EFBFBD>?0%逕ィGPT-5<>?*
- 謌先悽<EFBFBD>堋?0-80
-<>。ョ邇<EFBDAE><EFBFBD>90%
- 适用:质量和成本平衡 ⭐ 性价比最高
- 騾ら畑<EFBFBD>夊エィ驥丞柱謌先悽蟷ウ陦。 箝?諤ァ莉キ豈疲怙鬮?
---
@@ -446,12 +446,12 @@ async screenWithCostOptimization(title: string, abstract: string, picoConfig: an
### 1. API Key螳牙<E89EB3>
```typescript
// ❌ 错误硬编码API Key
// 笶?髞呵ッッ<EFBDAF>夂。ャ郛也<E9839B>PI Key
const client = new OpenAI({
apiKey: 'sk-cu0iepbXYGGx2jc7BqP6ogtSWmP6fk918qV3RUdtGC3Edlpo',
});
// ✅ 正确:从环境变量读取
// 笨?豁」遑ョ<E98191>壻サ守識蠅<E8AD98>序驥剰ッサ蜿<EFBDBB>
const client = new OpenAI({
apiKey: process.env.CLOSEAI_API_KEY,
});
@@ -465,15 +465,15 @@ async chat(provider: LLMProvider, prompt: string) {
const response = await this.llm.chat(provider, prompt);
return response;
} catch (error) {
// CloseAI可能返回的错误
// CloseAI蜿ッ閭ス霑泌屓逧<EFBFBD>漠隸?
if (error.status === 429) {
// 騾溽紫髯仙宛
console.error('API隹<49>畑騾溽紫雜<E7B4AB><EFBFBD>瑚ッキ遞榊錘驥崎ッ<E5B48E>');
} else if (error.status === 401) {
// 隶、隸∝、ア雍・
console.error('API Key无效,请检查配置');
console.error('API Key<EFBFBD>謨茨シ瑚ッキ譽€譟・驟咲ス?);
} else if (error.status === 500) {
// 服务端错误
// 譛榊苅遶ッ髞呵ッ?
console.error('CloseAI譛榊苅蠑ょクク<EFBFBD><EFBFBD>');
}
throw error;
@@ -491,7 +491,7 @@ async chatWithRetry(provider: LLMProvider, prompt: string, maxRetries = 3) {
} catch (error) {
if (i === maxRetries - 1) throw error;
// 指数退避
// <EFBFBD>焚騾€驕?
const delay = Math.pow(2, i) * 1000;
await new Promise(resolve => setTimeout(resolve, delay));
}
@@ -509,9 +509,9 @@ async chatWithRetry(provider: LLMProvider, prompt: string, maxRetries = 3) {
---
**更新日志:**
**譖エ譁ー譌・蠢暦シ?*
- 2025-11-09: 蛻帛サコ譁<EFBDBA>。」<EFBDA1>梧キサ蜉<EFBDBB>CloseAI髮<49><E9ABAE><EFBFBD>
- 支持GPT-5-Pro和Claude-4.5-Sonnet最新模型
- 謾ッ謖;PT-5-Pro蜥靴laude-4.5-Sonnet譛€譁ー讓。蝙?