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%)
12 KiB
12 KiB
鎶€鏈<EFBFBD>€哄姟锛氶€氱敤瀵硅瘽鏈嶅姟鎶藉彇璁″垝
鏂囨。绫诲瀷: 鎶€鏈<E282AC>€哄姟
鍒涘缓鏃ユ湡: 2025-12-06
**浼樺厛绾?*: P2锛堜腑鏈熶紭鍖栵級
棰勮<EFBFBD>宸ユ椂: 2-3澶? 褰卞搷妯″潡: AIA銆丳KB銆乀ool C銆佹湭鏉<E6B9AD>I鐭ヨ瘑搴撴ā鍧?
馃搵 闂<><E99782>鎻忚堪
褰撳墠鐜扮姸
鍚庣<EFBFBD>瀵硅瘽鑳藉姏鍒嗗竷锛?
鉁?閫氱敤鑳藉姏灞傦紙common/锛?
鈹溾攢鈹€ llm/adapters/ 鈫?LLM閫傞厤鍣<E58EA4>紙瀹屾暣锛?
鈹? 鈹溾攢鈹€ LLMFactory.ts 鈫?缁熶竴宸ュ巶绫?
鈹? 鈹溾攢鈹€ DeepSeekAdapter.ts
鈹? 鈹溾攢鈹€ QwenAdapter.ts
鈹? 鈹溾攢鈹€ GPT5Adapter.ts
鈹? 鈹斺攢鈹€ ClaudeAdapter.ts
鈹溾攢鈹€ rag/ 鈫?RAG妫€绱<E282AC>紙瀹屾暣锛?
鈹? 鈹斺攢鈹€ DifyClient.ts
鈹斺攢鈹€ storage/, logging/, cache/ 鈫?鍩虹<E98DA9>璁炬柦锛堝畬鏁达級
鈿狅笍 涓氬姟灞傦紙legacy/锛?
鈹斺攢鈹€ services/
鈹斺攢鈹€ conversationService.ts 鈫?瀵硅瘽绠$悊閫昏緫锛?25琛岋級
鈹溾攢鈹€ 鍒涘缓瀵硅瘽
鈹溾攢鈹€ 鍙戦€佹秷鎭?
鈹溾攢鈹€ 娴佸紡杈撳嚭
鈹溾攢鈹€ 涓婁笅鏂囩粍瑁?
鈹溾攢鈹€ 鍘嗗彶绠$悊
鈹斺攢鈹€ 鐭ヨ瘑搴撴<E690B4>绱㈤泦鎴?
鍓嶇<EFBFBD>缁勪欢鍒嗗竷锛?
鉂?缂哄皯閫氱敤瀵硅瘽缁勪欢
鍚勬ā鍧楅噸澶嶅疄鐜帮細
鈹溾攢鈹€ AIA妯″潡 - 鑷<>繁瀹炵幇瀵硅瘽UI
鈹溾攢鈹€ PKB妯″潡 - 鑷<>繁瀹炵幇瀵硅瘽UI
鈹斺攢鈹€ Tool C妯″潡 - 鑷<>繁瀹炵幇瀵硅瘽UI锛圖ay 3锛?
馃幆 闂<><E99782>鍒嗘瀽
浠g爜閲嶅<EFBFBD>
| 鍔熻兘 | 褰撳墠鐘舵€? | 閲嶅<EFBFBD>搴? |
|---|---|---|
| LLM璋冪敤 | 鉁?宸叉娊鍙栵紙common/llm锛? | 0% |
| 瀵硅瘽绠$悊 | 鈿狅笍 鏈<>娊鍙栵紙legacy涓<79>級 | 80% |
| 娑堟伅瀛樺偍 | 鈿狅笍 鍚勬ā鍧楃嫭绔嬭〃 | 60% |
| *涓婁笅鏂囩粍瑁? | 鈿狅笍 鍚勬ā鍧楅噸澶嶅疄鐜? | 70% |
| 娴佸紡杈撳嚭 | 鈿狅笍 鍚勬ā鍧楅噸澶嶅疄鐜? | 80% |
| 鍓嶇<EFBFBD>瀵硅瘽UI | 鉂?瀹屽叏鏈<E58F8F>娊鍙? | 90% |
褰卞搷鑼冨洿
鐜版湁妯″潡锛?
- AIA锛圓I鏅鸿兘闂<EFBFBD>瓟锛? 浣跨敤legacy/conversationService
- PKB锛堜釜浜虹煡璇嗗簱锛? 浣跨敤legacy/conversationService
- Tool C锛堟暟鎹<E69A9F>竻娲楋級- Day 3鑷<33>繁瀹炵幇锛垀150琛岄噸澶嶄唬鐮侊級
鏈<EFBFBD>潵妯″潡锛?
- AI鐭ヨ瘑搴撴ā鍧?- 闇€瑕侀噸澶嶅疄鐜?
- 鍏朵粬AI瀵硅瘽鍦烘櫙 - 闇€瑕侀噸澶嶅疄鐜?
馃挕 浼樺寲鏂规<E98F82>
鏂规<EFBFBD>锛氭娊鍙栭€氱敤瀵硅瘽鏈嶅姟
绗<EFBFBD>竴闃舵<EFBFBD>锛氬悗绔<EFBFBD>湇鍔℃娊鍙?
鍒涘缓閫氱敤瀵硅瘽鏈嶅姟锛?
// backend/src/common/conversation/ConversationService.ts
export class ConversationService {
/**
* 閫氱敤瀵硅瘽鎺ュ彛
* 鏀<>寔澶氱<E6BEB6>鍦烘櫙锛欰IA銆丳KB銆乀ool C绛?
*/
async chat(config: ChatConfig): Promise<ChatResponse> {
// 1. 鏋勫缓娑堟伅涓婁笅鏂?
const messages = await this.buildContext(config);
// 2. 璋冪敤LLM锛堝<E9949B>鐢↙LMFactory锛?
const llm = LLMFactory.createAdapter(config.modelType);
const response = await llm.chat(messages, config.options);
// 3. 淇濆瓨娑堟伅锛堟牴鎹<E789B4>厤缃<E58EA4>喅瀹氬瓨鍌ㄤ綅缃<E7B685>級
await this.saveMessage(config.conversationId, config.userMessage, response);
return response;
}
/**
* 娴佸紡瀵硅瘽
*/
async streamChat(config: ChatConfig): AsyncGenerator<StreamChunk> {
const messages = await this.buildContext(config);
const llm = LLMFactory.createAdapter(config.modelType);
for await (const chunk of llm.chatStream(messages, config.options)) {
yield chunk;
}
// 淇濆瓨瀹屾暣鍝嶅簲
await this.saveMessage(...);
}
/**
* 鑾峰彇瀵硅瘽鍘嗗彶
* 鏀<>寔澶氱<E6BEB6>瀛樺偍鏂瑰紡锛堢粺涓€鎺ュ彛锛屼笉鍚岃〃锛?
*/
async getHistory(conversationId: string, options?: HistoryOptions) {
// 鏍规嵁conversationType璺<65>敱鍒颁笉鍚岀殑琛?
const adapter = this.getStorageAdapter(options.conversationType);
return await adapter.getHistory(conversationId, options);
}
/**
* 淇濆瓨娑堟伅
* 鏀<>寔澶氱<E6BEB6>瀛樺偍鏂瑰紡
*/
async saveMessage(conversationId: string, userMsg: string, aiResponse: any) {
const adapter = this.getStorageAdapter(this.config.conversationType);
await adapter.saveMessage(conversationId, userMsg, aiResponse);
}
/**
* 鏋勫缓涓婁笅鏂?
* 鏀<>寔锛歋ystem Prompt + 鍘嗗彶娑堟伅 + 褰撳墠娑堟伅 + RAG妫€绱?
*/
private async buildContext(config: ChatConfig): Promise<Message[]> {
const messages: Message[] = [];
// 1. System Prompt
if (config.systemPrompt) {
messages.push({ role: 'system', content: config.systemPrompt });
}
// 2. 鍘嗗彶娑堟伅
if (config.includeHistory) {
const history = await this.getHistory(config.conversationId, {
limit: config.historyLimit || 5
});
messages.push(...history);
}
// 3. RAG妫€绱<E282AC>紙濡傛灉闇€瑕侊級
if (config.knowledgeBaseIds?.length > 0) {
const ragContext = await this.retrieveRAGContext(
config.userMessage,
config.knowledgeBaseIds
);
messages.push({ role: 'system', content: ragContext });
}
// 4. 褰撳墠鐢ㄦ埛娑堟伅
messages.push({ role: 'user', content: config.userMessage });
return messages;
}
}
// 閰嶇疆鎺ュ彛
interface ChatConfig {
conversationId: string;
conversationType: 'aia' | 'pkb' | 'tool-c' | 'knowledge-base'; // 璺<>敱鍒颁笉鍚岃〃
modelType: ModelType;
userMessage: string;
systemPrompt?: string;
includeHistory?: boolean;
historyLimit?: number;
knowledgeBaseIds?: string[];
options?: {
temperature?: number;
maxTokens?: number;
topP?: number;
};
}
**瀛樺偍閫傞厤鍣?*锛堟敮鎸佷笉鍚屾ā鍧楃殑涓嶅悓琛<E68293>級锛?
// backend/src/common/conversation/adapters/StorageAdapter.ts
interface ConversationStorageAdapter {
getHistory(conversationId: string, options?: HistoryOptions): Promise<Message[]>;
saveMessage(conversationId: string, userMsg: string, aiResponse: any): Promise<void>;
}
// AIA/PKB浣跨敤閫氱敤琛?
class GeneralStorageAdapter implements ConversationStorageAdapter {
async getHistory(conversationId: string) {
return await prisma.generalMessage.findMany({
where: { conversationId },
orderBy: { createdAt: 'desc' },
take: options.limit
});
}
}
// Tool C浣跨敤鐙<E695A4>珛琛?
class ToolCStorageAdapter implements ConversationStorageAdapter {
async getHistory(conversationId: string) {
return await prisma.dcToolCAiHistory.findMany({
where: { sessionId: conversationId },
orderBy: { createdAt: 'desc' },
take: options.limit
});
}
}
绗<EFBFBD>簩闃舵<EFBFBD>锛氬墠绔<EFBFBD>粍浠舵娊鍙?
**鍒涘缓閫氱敤瀵硅瘽缁勪欢搴?*锛?
// frontend-v2/src/shared/components/Chat/
鈹溾攢鈹€ ChatContainer.tsx // 瀵硅瘽瀹瑰櫒锛堝竷灞€锛?
鈹溾攢鈹€ MessageList.tsx // 娑堟伅鍒楄〃锛堣櫄鎷熸粴鍔<E7B2B4>級
鈹溾攢鈹€ MessageItem.tsx // 鍗曟潯娑堟伅锛堢敤鎴?AI锛?
鈹溾攢鈹€ MessageInput.tsx // 杈撳叆妗嗭紙鏀<E7B499>寔澶氳<E6BEB6>銆佸揩鎹烽敭锛?
鈹溾攢鈹€ StreamingMessage.tsx // 娴佸紡娓叉煋锛堟墦瀛楁満鏁堟灉锛?
鈹溾攢鈹€ CitationBadge.tsx // 寮曠敤鏍囪<E98F8D>
鈹溾攢鈹€ LoadingIndicator.tsx // 鍔犺浇鍔ㄧ敾
鈹斺攢鈹€ index.ts
// 浣跨敤绀轰緥
import { ChatContainer } from '@/shared/components/Chat';
<ChatContainer
conversationId={sessionId}
conversationType="tool-c"
systemPrompt={buildSystemPrompt()}
onSendMessage={handleSendMessage}
enableHistory={true}
enableRAG={false}
/>
**缁勪欢鐗规€?*锛?
- 鉁?鏀<>寔娴佸紡/闈炴祦寮忔覆鏌?
- 鉁?鏀<>寔寮曠敤璺宠浆
- 鉁?鏀<>寔鍘嗗彶娑堟伅鍔犺浇
- 鉁?鏀<>寔Markdown娓叉煋
- 鉁?鏀<>寔浠g爜楂樹寒
- 鉁?鍝嶅簲寮忓竷灞€
馃搳 鏀归€犲墠鍚庡<E98D9A>姣?
浠g爜閲忓<EFBFBD>姣?
| 妯″潡 | 鏀归€犲墠 | 鏀归€犲悗 | 鍑忓皯 |
|---|---|---|---|
| 鍚庣<EFBFBD> | |||
| AIA瀵硅瘽閫昏緫 | 200琛? | 50琛岋紙璋冪敤閫氱敤鏈嶅姟锛? | -75% |
| PKB瀵硅瘽閫昏緫 | 180琛? | 50琛? | -72% |
| Tool C瀵硅瘽閫昏緫 | 150琛? | 50琛? | -67% |
| 閫氱敤鏈嶅姟 | 0琛? | 300琛岋紙鏂板缓锛? | +300琛? |
| 鎬昏<EFBFBD> | 530琛? | 450琛? | -15% |
| 鍓嶇<EFBFBD> | |||
| 鍚勬ā鍧楀<EFBFBD>璇漊I | 600琛屆? | 200琛屆?锛堣皟鐢ㄩ€氱敤缁勪欢锛? | -67% |
| 閫氱敤缁勪欢 | 0琛? | 500琛岋紙鏂板缓锛? | +500琛? |
| 鎬昏<EFBFBD> | 1800琛? | 1100琛? | -39% |
| 鍏ㄩ儴鍚堣<EFBFBD> | 2330琛? | 1550琛? | -33% |
璐ㄩ噺鎻愬崌
| 鎸囨爣 | 鏀归€犲墠 | 鏀归€犲悗 | 鎻愬崌 |
|---|---|---|---|
| 浠g爜澶嶇敤鐜? | 20% | 80% | +300% |
| 缁熶竴浜や簰浣撻獙 | 鉂? | 鉁? | 100% |
| 鏈<EFBFBD>潵鎵╁睍鎴愭湰 | 楂橈紙姣忔<EFBFBD>閲嶅<EFBFBD>锛? | 浣庯紙鐩存帴澶嶇敤锛? | -80% |
| 缁存姢鎴愭湰 | 楂橈紙澶氬<EFBFBD>淇<EFBFBD>敼锛? | 浣庯紙鍗曠偣淇<EFBFBD>敼锛? | -70% |
馃殌 瀹炴柦璁″垝
闃舵<EFBFBD>1锛氬悗绔<EFBFBD>湇鍔℃娊鍙栵紙1.5澶╋級
*Day 1涓婂崍锛氳<E9949B>璁?
- 璁捐<EFBFBD>ConversationService鎺ュ彛
- 璁捐<EFBFBD>StorageAdapter鎺ュ彛
- 璁捐<EFBFBD>ChatConfig閰嶇疆缁撴瀯
*Day 1涓嬪崍锛氬疄鐜版牳蹇冩湇鍔?
- 瀹炵幇ConversationService鏍稿績閫昏緫
- 瀹炵幇GeneralStorageAdapter
- 瀹炵幇ToolCStorageAdapter
*Day 2涓婂崍锛氳縼绉荤幇鏈夋ā鍧?
- AIA妯″潡鏀归€狅紙浣跨敤閫氱敤鏈嶅姟锛?
- PKB妯″潡鏀归€狅紙浣跨敤閫氱敤鏈嶅姟锛?
- Tool C妯″潡鏀归€狅紙浣跨敤閫氱敤鏈嶅姟锛?
*Day 2涓嬪崍锛氭祴璇?
- 鍗曞厓娴嬭瘯
- 闆嗘垚娴嬭瘯
- 鍥炲綊娴嬭瘯锛堢‘淇濆師鍔熻兘姝e父锛?
闃舵<EFBFBD>2锛氬墠绔<EFBFBD>粍浠舵娊鍙栵紙1澶╋級
Day 3涓婂崍锛氳<E9949B>璁′笌瀹炵幇
- 璁捐<EFBFBD>ChatContainer API
- 瀹炵幇鏍稿績缁勪欢锛?涓<>級
- 鏍峰紡缁熶竴
Day 3涓嬪崍锛氳縼绉讳笌娴嬭瘯
- AIA妯″潡鍓嶇<EFBFBD>鏀归€?
- PKB妯″潡鍓嶇<EFBFBD>鏀归€?
- Tool C妯″潡鍓嶇<E98D93>鏀归€?
- UI娴嬭瘯
闃舵<EFBFBD>3锛氭枃妗d笌鍩硅<EFBFBD>锛?.5澶╋級
- 缂栧啓浣跨敤鏂囨。
- 缂栧啓鏈€浣冲疄璺?
- 鍥㈤槦鍩硅<EFBFBD>
馃摑 楠屾敹鏍囧噯
鍔熻兘楠屾敹
- AIA妯″潡瀵硅瘽鍔熻兘姝e父
- PKB妯″潡瀵硅瘽鍔熻兘姝e父
- Tool C妯″潡瀵硅瘽鍔熻兘姝e父
- 娴佸紡杈撳嚭姝e父
- 鍘嗗彶娑堟伅鍔犺浇姝e父
- RAG妫€绱㈤泦鎴愭<EFBFBD>甯?
浠g爜璐ㄩ噺
- 浠g爜澶嶇敤鐜団墺80%
- 鍗曞厓娴嬭瘯瑕嗙洊鐜団墺80%
- 鏃燭ypeScript閿欒<EFBFBD>
- 鏃燛SLint璀﹀憡
鐢ㄦ埛浣撻獙
- 瀵硅瘽浜や簰娴佺晠锛堝搷搴?2绉掞級
- 娴佸紡杈撳嚭娴佺晠锛堟棤鍗¢】锛?
- UI缁熶竴缇庤<EFBFBD>
- 绉诲姩绔<EFBFBD>€傞厤鑹<EFBFBD>ソ
馃挵 鏀剁泭鍒嗘瀽
鐭<EFBFBD>湡鏀剁泭锛?涓<>湀鍐咃級
-
浠g爜璐ㄩ噺鎻愬崌
- 鍑忓皯閲嶅<EFBFBD>浠g爜33%
- 鎻愬崌浠g爜澶嶇敤鐜囪嚦80%
- 闄嶄綆缁存姢鎴愭湰70%
-
*寮€鍙戞晥鐜囨彁鍗?
- 鏂版ā鍧楀<EFBFBD>璇濆姛鑳藉紑鍙戞椂闂达細浠?澶┾啋0.5澶╋紙-75%锛?
- Bug淇<EFBFBD><EFBFBD>鏁堢巼锛氬崟鐐逛慨鏀癸紝褰卞搷鍏ㄥ眬锛?200%锛?
-
鐢ㄦ埛浣撻獙缁熶竴
- 缁熶竴浜や簰妯″紡
- 缁熶竴瑙嗚<EFBFBD>椋庢牸
- 缁熶竴鎬ц兘鏍囧噯
闀挎湡鏀剁泭锛?-6涓<36>湀锛?
-
鏀<EFBFBD>寔鏈<EFBFBD>潵妯″潡
- AI鐭ヨ瘑搴撴ā鍧楋細鐩存帴澶嶇敤锛?棰濆<E6A3B0>寮€鍙?
- 鍏朵粬AI瀵硅瘽鍦烘櫙锛氬揩閫熷疄鐜?
-
*鎶€鏈<EFBFBD>灦鏋勪紭鍖?
- 鐪熸<EFBFBD>瀹炵幇鍒嗗眰鏋舵瀯锛堜笟鍔″眰鈫掗€氱敤灞傦級
- 涓哄井鏈嶅姟鎷嗗垎鍋氬噯澶?
-
*鍟嗕笟浠峰€?
- 妯″潡鐙<EFBFBD>珛閮ㄧ讲鏇村<EFBFBD>鏄?
- 妯″潡鐙<EFBFBD>珛鍞<EFBFBD>崠鏇寸伒娲?
- 瀹㈡埛瀹氬埗鎴愭湰闄嶄綆
鈿狅笍 椋庨櫓涓庡簲瀵?
椋庨櫓1锛氬洖褰掓祴璇曞伐浣滈噺澶?
**搴斿<E690B4>**锛?
- 浼樺厛瀹炵幇鑷<EFBFBD>姩鍖栨祴璇?
- 鍒嗘ā鍧楅€愭<EFBFBD>杩佺Щ
- 淇濈暀鍘熶唬鐮佷綔涓哄<EFBFBD>浠?
椋庨櫓2锛氬巻鍙叉暟鎹<EFBFBD>縼绉?
**搴斿<E690B4>**锛?
- 涓嶉渶瑕佽縼绉绘暟鎹?
- 鍙<EFBFBD>縼绉讳唬鐮侀€昏緫
- 鍚勬ā鍧椾繚鐣欑嫭绔嬭〃
椋庨櫓3锛氬墠绔<EFBFBD>粍浠跺<EFBFBD>鏉傚害
**搴斿<E690B4>**锛?
- 閲囩敤娓愯繘寮忛噸鏋?
- 鍏堟娊鍙栨牳蹇冪粍浠?
- 鍚庣画杩<EFBFBD>唬浼樺寲
馃搮 寤鸿<E5AFA4>鎵ц<E98EB5>鏃堕棿
鎺ㄨ崘鏃堕棿绐楀彛锛?
- 閫夐」1锛歍ool C MVP瀹屾垚鍚庯紙Day 10-13锛?
- 閫夐」2锛氭墍鏈塂C妯″潡瀹屾垚鍚庯紙Week 8-9锛?
- 閫夐」3锛欰I鐭ヨ瘑搴撴ā鍧楀惎鍔ㄥ墠锛圦uarter 2锛?
褰撳墠鍐崇瓥锛氬欢鍚庤嚦Tool C MVP瀹屾垚鍚?
馃敆 鐩稿叧鏂囨。
- 绯荤粺鏋舵瀯鍒嗗眰璁捐<EFBFBD>
- [浜戝師鐢熷紑鍙戣<E98D99>鑼僝(../../04-寮€鍙戣<E98D99>鑼?08-浜戝師鐢熷紑鍙戣<E98D99>鑼?md)
- [Tool C Day 3寮€鍙戣<E98D99>鍒抅(../../03-涓氬姟妯″潡/DC-鏁版嵁娓呮礂鏁寸悊/04-寮€鍙戣<E98D99>鍒?宸ュ叿C_Day3寮€鍙戣<E98D99>鍒?md)
馃摑 鏇存柊璁板綍
| 鏃ユ湡 | 鐗堟湰 | 鏇存柊鍐呭<EFBFBD> | 鏇存柊浜? |
|---|---|---|---|
| 2025-12-06 | V1.0 | 鍒濆<EFBFBD>鍒涘缓 | AI Assistant |
**鏂囨。鐘舵€?: 鉁?宸插垱寤?
**浼樺厛绾?: P2锛堜腑鏈熶紭鍖栵級
**涓嬩竴姝?*: 瀹屾垚Tool C Day 3 MVP鍚庨噸鏂拌瘎浼?