feat(admin): Add user management and upgrade to module permission system
Features - User Management (Phase 4.1): - Database: Add user_modules table for fine-grained module permissions - Database: Add 4 user permissions (view/create/edit/delete) to role_permissions - Backend: UserService (780 lines) - CRUD with tenant isolation - Backend: UserController + UserRoutes (648 lines) - 13 API endpoints - Backend: Batch import users from Excel - Frontend: UserListPage (412 lines) - list/filter/search/pagination - Frontend: UserFormPage (341 lines) - create/edit with module config - Frontend: UserDetailPage (393 lines) - details/tenant/module management - Frontend: 3 modal components (592 lines) - import/assign/configure - API: GET/POST/PUT/DELETE /api/admin/users/* endpoints Architecture Upgrade - Module Permission System: - Backend: Add getUserModules() method in auth.service - Backend: Login API returns modules array in user object - Frontend: AuthContext adds hasModule() method - Frontend: Navigation filters modules based on user.modules - Frontend: RouteGuard checks requiredModule instead of requiredVersion - Frontend: Remove deprecated version-based permission system - UX: Only show accessible modules in navigation (clean UI) - UX: Smart redirect after login (avoid 403 for regular users) Fixes: - Fix UTF-8 encoding corruption in ~100 docs files - Fix pageSize type conversion in userService (String to Number) - Fix authUser undefined error in TopNavigation - Fix login redirect logic with role-based access check - Update Git commit guidelines v1.2 with UTF-8 safety rules Database Changes: - CREATE TABLE user_modules (user_id, tenant_id, module_code, is_enabled) - ADD UNIQUE CONSTRAINT (user_id, tenant_id, module_code) - INSERT 4 permissions + role assignments - UPDATE PUBLIC tenant with 8 module subscriptions Technical: - Backend: 5 new files (~2400 lines) - Frontend: 10 new files (~2500 lines) - Docs: 1 development record + 2 status updates + 1 guideline update - Total: ~4900 lines of code Status: User management 100% complete, module permission system operational
This commit is contained in:
@@ -655,3 +655,5 @@ const DEFAULT_MODEL = 'qwen-max'; // 或 'gpt-5', 'claude-4.5'
|
||||
|
||||
**文档维护:** 请在每次重大更新后及时更新本文档,保持与代码同步。
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,123 +1,135 @@
|
||||
# **憯寡<EFBFBD>敺芰<EFBFBD><EFBFBD><EFBFBD> \- AI<41>箄<EFBFBD><E7AE84>桃<EFBFBD> (AIA) V2.1 鈭批<EFBFBD><EFBFBD><EFBFBD>瘙<EFBFBD><EFBFBD>獢?*
|
||||
# **壹证循科技 \- AI智能问答 (AIA) V2.1 产品需求文档**
|
||||
|
||||
**文档状态:** Draft (V2.1)
|
||||
|
||||
**<EFBFBD>唾<EFBFBD><EFBFBD>笔<EFBFBD>嚗?* AI<41>桃<EFBFBD><E6A183>笔<EFBFBD><E7AC94>銼11.html
|
||||
**关联原型:** AI问答原型图V11.html
|
||||
|
||||
**<EFBFBD>嗆<EFBFBD><EFBFBD><EFBFBD><EFBFBD>嚗?* Postgres-Only | Ant Design X | Schema Isolation
|
||||
**架构标准:** Postgres-Only | Ant Design X | Schema Isolation
|
||||
|
||||
**最后更新:** 2026-01-11
|
||||
|
||||
**<EFBFBD>祆活<EFBFBD>湔鰵嚗?* <20>啣<EFBFBD>蝘餃𢆡蝡舫<E89DA1><E888AB><EFBFBD><EFBFBD><EFBFBD>楛摨行<E691A8>肽<EFBFBD><E882BD>芋撘譌<E69298><E8AD8C>I/UX 蝏<><E89D8F>閫<EFBFBD><E996AB>
|
||||
**本次更新:** 新增移动端适配、深度思考模式、UI/UX 细节规范
|
||||
|
||||
## **1\. 璁<EFBFBD>膩銝𡒊𤌍<EFBFBD>?*
|
||||
## **1\. 概述与目标**
|
||||
|
||||
### **1.1 背景**
|
||||
|
||||
<EFBFBD>?AIA 璅∪<EFBFBD><EFBFBD>蠘<EFBFBD>颲<EFBFBD>蛹<EFBFBD>蓥<EFBFBD><EFBFBD><EFBFBD>2.0+ <20><>𧋦<EFBFBD>典銁<E585B8><E98A81>遣銝<E981A3>銝?*<2A>冽<EFBFBD>蝔钅店<E99285>函<EFBFBD>蝘𤑳<E89D98><F0A491B3>箄<EFBFBD>雿枏之<E69E8F>?(Agent Hub)**嚗<EFBFBD>笆<EFBFBD>?ChatGPT/Gemini <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>撉䕘<EFBFBD>撟嗆楛摨衣<EFBFBD><EFBFBD><EFBFBD>龫摮衣<EFBFBD><EFBFBD>𥪜㦤<EFBFBD>胯<EFBFBD>?
|
||||
### **1.2 <20>詨<EFBFBD>隞瑕<E99A9E>?*
|
||||
原 AIA 模块功能较为单一。V2.0+ 版本旨在构建一个**全流程驱动的科研智能体大厅 (Agent Hub)**,对标 ChatGPT/Gemini 的流畅体验,并深度结合医学科研场景。
|
||||
|
||||
### **1.2 核心价值**
|
||||
|
||||
1. **流程化引导**:打破“只有一个对话框”的迷茫感,通过 5 个阶段引导用户逐步推进研究。
|
||||
2. **专业分工**:不同的智能体加载不同的 System Prompt 和知识库。
|
||||
3. **全端体验**:提供桌面端到移动端的无缝衔接,随时随地记录科研灵感。
|
||||
|
||||
1. **瘚<><E7989A><EFBFBD>硋<EFBFBD>撖?*嚗𡁏<E59A97><F0A1818F>氯<EFBFBD>𨅯蘨<F0A885AF>劐<EFBFBD>銝芸笆霂脲<E99C82><E884B2>萘<EFBFBD>餈瑁𤨓<E79181><F0A4A893><EFBFBD><EFBFBD>朞<EFBFBD> 5 銝芷𧫴畾萄<E795BE>撖潛鍂<E6BD9B>琿<EFBFBD>鞉郊<E99E89>刻<EFBFBD><E588BB>𠉛弦<F0A0899B>?
|
||||
2. **銝㮖<E98A9D><E3AE96><EFBFBD>極**嚗帋<E59A97><E5B88B>𣬚<EFBFBD><F0A3AC9A>箄<EFBFBD>雿枏<E99BBF>頧賭<E9A0A7><E8B3AD>𣬚<EFBFBD> System Prompt <20>𣬚䰻霂<E4B0BB><E99C82><EFBFBD>?
|
||||
3. **<EFBFBD>函垢雿㯄<EFBFBD>**嚗𡁏<E59A97>靘𥟇<E99D98><F0A59F87>Y垢<EFBCB9>啁宏<E59581>函垢<E587BD><E59EA2><EFBFBD>蝻肽<E89DBB><E882BD>伐<EFBFBD><E4BC90>𤩺𧒄<F0A4A9BA>誩𧑐霈啣<E99C88>蝘𤑳<E89D98><F0A491B3>菜<EFBFBD><E88F9C>?
|
||||
## **2\. 核心业务流程 (User Flow)**
|
||||
|
||||
1. **餈𥕦<EFBFBD>憭批<EFBFBD> (Dashboard)**嚗?
|
||||
* 憿園<EFBFBD><EFBFBD>𣂷<EFBFBD><EFBFBD>𨅯<EFBFBD>撅<EFBFBD><EFBFBD>誩㦛<EFBFBD>𦦵揣獢<EFBFBD><EFBFBD>嘅<EFBFBD><EFBFBD>冽<EFBFBD>颲枏<EFBFBD>璅∠<EFBFBD><EFBFBD><EFBFBD>瘙<EFBFBD><EFBFBD>?
|
||||
* 蝟餌<EFBFBD>霂<EFBFBD><EFBFBD><EFBFBD>誩㦛嚗諹䌊<EFBFBD>刻歲頧砍<EFBFBD>撖孵<EFBFBD><EFBFBD><EFBFBD>惣<EFBFBD>賭<EFBFBD><EFBFBD>?
|
||||
2. **<EFBFBD>㗇𥋘<EFBFBD>箄<EFBFBD>雿?*嚗?
|
||||
* <EFBFBD>冽<EFBFBD>銋笔虾隞亦凒<EFBFBD>亦<EFBFBD><EFBFBD>餃<EFBFBD>雿梶<EFBFBD><EFBFBD>∠<EFBFBD>嚗<EFBFBD><EFBFBD><EFBFBD>?6 <20>瑟𧋦<E7919F>讛恣蝞轁<E89D9E>嘅<EFBFBD><E59885>?
|
||||
3. **瘝㗇絡撘誩極雿𨅯蝱 (Workspace)**嚗?
|
||||
* 餈𥕦<EFBFBD><EFBFBD>瑚<EFBFBD><EFBFBD><EFBFBD>笆霂萘<EFBFBD><EFBFBD>U<EFBFBD>?
|
||||
* **獢屸𢒰蝡?*嚗帋<E59A97><E5B88B>誩<EFBFBD>撅<EFBFBD>嚗<EFBFBD><E59A97><EFBFBD>脰扇敶?\+ 撖寡<E69296><E5AFA1>?\+ 憒<><E68692><EFBFBD>匧𢰧靘批<E99D98><E689B9>冽<EFBFBD>嚗剹<E59A97>?
|
||||
* **蝘餃𢆡蝡?*嚗𡁜<E59A97><F0A1819C>誩<EFBFBD>撅<EFBFBD>嚗<EFBFBD><E59A97><EFBFBD>脰扇敶閙<E695B6><E99699>牐蛹<E78990>賢<EFBFBD><E8B3A2>?
|
||||
4. **蝏𤘪<EFBFBD>鈭批枂**嚗?
|
||||
* AI 撅閧內**<2A>肽<EFBFBD><E882BD><EFBFBD>蝔?(Thinking Process)** <EFBFBD>舘<EFBFBD><EFBFBD>箸<EFBFBD>蝏<EFBFBD><EFBFBD>獢<EFBFBD><EFBFBD>?
|
||||
* <EFBFBD>冽<EFBFBD><EFBFBD>臭<EFBFBD><EFBFBD>桀紡<EFBFBD>?Word <20>亙<EFBFBD><E4BA99>?
|
||||
## **3\. <20>蠘<EFBFBD><E8A098><EFBFBD>瘙<EFBFBD>祕<EFBFBD>?*
|
||||
1. **进入大厅 (Dashboard)**:
|
||||
* 顶部提供“全局意图搜索框”,用户输入模糊需求。
|
||||
* 系统识别意图,自动跳转到对应的智能体。
|
||||
2. **选择智能体**:
|
||||
* 用户也可以直接点击具体的卡片(如“06 样本量计算”)。
|
||||
3. **沉浸式工作台 (Workspace)**:
|
||||
* 进入具体的对话界面。
|
||||
* **桌面端**:三栏布局(历史记录 \+ 对话区 \+ 如果有右侧引用栏)。
|
||||
* **移动端**:单栏布局,历史记录折叠为抽屉。
|
||||
4. **结果产出**:
|
||||
* AI 展示**思考过程 (Thinking Process)** 后输出最终答案。
|
||||
* 用户可一键导出 Word 报告。
|
||||
|
||||
### **F1. <20>箄<EFBFBD>雿枏之<E69E8F>?(Dashboard) \- <20>箔<EFBFBD> V11 <20>笔<EFBFBD>**
|
||||
## **3\. 功能需求详情**
|
||||
|
||||
### **F1. 智能体大厅 (Dashboard) \- 基于 V11 原型**
|
||||
|
||||
#### **F1.1 全局意图路由 (Intent Router)**
|
||||
|
||||
* **UI**嚗𡁻▲<EFBFBD>典之<EFBFBD>𦦵揣獢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>𡏭<EFBFBD><EFBFBD>亦<EFBFBD>蝛嗆<EFBFBD>瘜?..<2E>腈<EFBFBD>?
|
||||
* **<EFBFBD>餉<EFBFBD>**嚗𡁜<E59A97>蝡航<E89DA1><E888AA>?Router Agent 霂<><E99C82><EFBFBD>誩㦛 \-\> 頝唾蓮<E594BE>格<EFBFBD> Agent \-\> <EFBFBD>芸𢆡憛怠<EFBFBD> Prompt<EFBFBD>?
|
||||
* **UI**:顶部大搜索框,文案“输入研究想法...”。
|
||||
* **逻辑**:后端调用 Router Agent 识别意图 \-\> 跳转目标 Agent \-\> 自动填入 Prompt。
|
||||
|
||||
#### **F1.2 智能体流水线展示 (Agent Pipeline)**
|
||||
|
||||
銝交聢餈睃<EFBFBD> V11 <20>笔<EFBFBD><E7AC94>?**5 <20>嗆挾撣<E68CBE><E692A3>** <20>?**3 <20>脰<EFBFBD>閫劐<E996AB>蝟?*嚗<>祕閫<E7A595><E996AB><EFBFBD>见㦛嚗剹<E59A97>?
|
||||
* **頝唾蓮<E594BE>餉<EFBFBD>**嚗?
|
||||
* **撣貉<EFBFBD><EFBFBD>∠<EFBFBD>**嚗朞<E59A97><E69C9E>?Chat Workspace<63>?
|
||||
* **撌亙<EFBFBD><EFBFBD>∠<EFBFBD> (09, 10\)**嚗朞歲頧?/dc/portal <20>?/st/dashboard<72>?
|
||||
严格还原 V11 原型的 **5 阶段布局** 和 **3 色视觉体系**(详见原型图)。
|
||||
|
||||
* **跳转逻辑**:
|
||||
* **常规卡片**:进入 Chat Workspace。
|
||||
* **工具卡片 (09, 10\)**:跳转 /dc/portal 或 /st/dashboard。
|
||||
|
||||
### **F2. 沉浸式对话工作台 (Chat Workspace)**
|
||||
|
||||
#### **F2.1 <EFBFBD>屸𢒰撣<EFBFBD><EFBFBD>銝𡡞<EFBFBD><EFBFBD>?(UI/UX)**
|
||||
#### **F2.1 界面布局与风格 (UI/UX)**
|
||||
|
||||
* **设计理念**:参考 Gemini 的“大留白”风格,减少分割线,使用卡片投影区分层级。
|
||||
* **左侧侧边栏 (Sidebar)**:
|
||||
* **桌面端**:固定显示,可折叠(图标化)。
|
||||
* **移动端**:默认隐藏,通过左上角“汉堡菜单”滑出(Drawer 组件)。
|
||||
* **内容**:按时间分组的历史会话(今天、昨天、7天前)。
|
||||
* **主对话区 (Main Area)**:
|
||||
* **Header**:显示当前智能体名称 \+ 状态("思考中..." / "输入中...")。
|
||||
* **Input**:底部悬浮,支持多行自动增高。
|
||||
|
||||
* **霈曇恣<E69B87><E681A3>艙**嚗𡁜<E59A97><F0A1819C>?Gemini <20><><EFBFBD>𨅯之<F0A885AF>嗵蒾<E597B5>嗪<EFBFBD><E597AA>潘<EFBFBD><E6BD98>誩<EFBFBD><E8AAA9><EFBFBD>𠧧蝥選<E89DA5>雿輻鍂<E8BCBB>∠<EFBFBD><E288A0>訫蔣<E8A8AB>箏<EFBFBD>撅<EFBFBD>漣<EFBFBD>?
|
||||
* **撌虫儒靘扯器<E689AF>?(Sidebar)**嚗?
|
||||
* **獢屸𢒰蝡?*嚗𡁜𤐄摰𡁏遬蝷綽<E89DB7><E7B6BD>舀<EFBFBD><E88880>𩤃<EFBFBD><F0A9A483>暹<EFBFBD><E69AB9>吔<EFBFBD><E59094>?
|
||||
* **蝘餃𢆡蝡?*嚗𡁻<E59A97>霈日<E99C88><E697A5>𧶏<EFBFBD><F0A7B68F>朞<EFBFBD>撌虫<E6928C>閫圝<E996AB>𨀣<EFBFBD><F0A880A3>∟<EFBFBD><E2889F>𨰝<EFBFBD>脲<EFBFBD><E884B2>綽<EFBFBD>Drawer 蝏<>辣嚗剹<E59A97>?
|
||||
* **<2A><>捆**嚗𡁏<E59A97><F0A1818F>園𡢿<E59C92><F0A1A2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>脖<EFBFBD>霂嘅<E99C82>隞𠰴予<F0A0B0B4><E4BA88>㿥憭押<E686AD>?憭拙<E686AD>嚗剹<E59A97>?
|
||||
* **銝餃笆霂嘥躹 (Main Area)**嚗?
|
||||
* **Header**嚗𡁏遬蝷箏<E89DB7><E7AE8F>齿惣<E9BDBF>賭<EFBFBD><E8B3AD>滨妍 \+ <20>嗆<EFBFBD><E59786><EFBFBD>"<22>肽<EFBFBD><E882BD>葉..." / "颲枏<E9A2B2>銝?.."嚗剹<E59A97>?
|
||||
* **Input**嚗𡁜<E59A97><F0A1819C>冽<EFBFBD>瘚殷<E7989A><E6AEB7>舀<EFBFBD>憭朞<E686AD><E69C9E>芸𢆡憓鮋<E68693><E9AE8B>?
|
||||
#### **F2.2 核心对话能力增强**
|
||||
|
||||
* **瘛勗漲<EFBFBD>肽<EFBFBD><EFBFBD>芋撘?(Thinking Process)**嚗?
|
||||
* **<EFBFBD><EFBFBD>瘙?*嚗𡁻<E59A97>撖嫖<E69296>𦦵<EFBFBD>摮阡䔮憸䀹4<E480B9><EFBC94><EFBFBD>萘<EFBFBD>憭齿<E686AD>隞餃𦛚嚗淾I <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>箸綫<E7AEB8><E7B6AB><EFBFBD>蝔卝<E89D94>?
|
||||
* **鈭支<EFBFBD>**嚗朞<E59A97><E69C9E>?\<think\>...\</think\> <EFBFBD><EFBFBD>捆<EFBFBD>塚<EFBFBD><EFBFBD>滨垢<EFBFBD>曄內銝?*<2A>舀<EFBFBD><E88880>删<EFBFBD><E588A0>啗𠧧撘閧鍂<E996A7>?*嚗屸<E59A97>霈文<E99C88>撘<EFBFBD>嚗𣬚<E59A97><F0A3AC9A>鞟<EFBFBD><E99E9F>笔<EFBFBD><E7AC94>芸𢆡<E88AB8>嗉絲嚗<E7B5B2>蘨<EFBFBD>曄內<E69B84>𨅯歇瘛勗漲<E58B97>肽<EFBFBD>?(<28>埈𧒄 12s)<EFBFBD>腈<EFBFBD>?
|
||||
* **Markdown 皜脫<EFBFBD>憓𧼮撩**嚗?
|
||||
* **<EFBFBD>砍<EFBFBD>**嚗帋蝙<E5B88B>?Katex 皜脫<EFBFBD> LaTeX <EFBFBD>餃郎<EFBFBD>砍<EFBFBD><EFBFBD>?
|
||||
* **銵冽聢**嚗𡁏𣈲<F0A1818F><F0A388B2>赤<EFBFBD>烐<EFBFBD><E78390>剁<EFBFBD><E58981>脫迫<E884AB>𧢲㦤蝡舀<E89DA1><E88880>游<EFBFBD>撅<EFBFBD><E69285>?
|
||||
* **隞<EFBFBD><EFBFBD>**嚗𡁏𣈲<F0A1818F><F0A388B2><EFBFBD><EFBFBD>桀<EFBFBD><E6A180>塚<EFBFBD>霂剜<E99C82>擃䀝漁<E4809D>?
|
||||
* **敹急㭘<EFBFBD><EFBFBD>誘 (Slash Commands)**嚗?
|
||||
* 颲枏<EFBFBD> / 撘孵枂敹急㭘<E680A5>𨅯<EFBFBD>嚗?瘨西𠧧, /<2F>拙<EFBFBD>, /蝧餉<E89DA7>, /撖澆枂Word<EFBFBD>?
|
||||
* **深度思考模式 (Thinking Process)**:
|
||||
* **需求**:针对“科学问题梳理”等复杂任务,AI 需先输出推理过程。
|
||||
* **交互**:输出 \<think\>...\</think\> 内容时,前端显示为**可折叠的灰色引用块**,默认展开,生成结束后自动收起,只显示“已深度思考 (耗时 12s)”。
|
||||
* **Markdown 渲染增强**:
|
||||
* **公式**:使用 Katex 渲染 LaTeX 医学公式。
|
||||
* **表格**:支持横向滚动,防止手机端撑破布局。
|
||||
* **代码**:支持一键复制,语法高亮。
|
||||
* **快捷指令 (Slash Commands)**:
|
||||
* 输入 / 弹出快捷菜单:/润色, /扩写, /翻译, /导出Word。
|
||||
|
||||
#### **F2.3 附件上传 (Attachment)**
|
||||
|
||||
* **<EFBFBD>澆<EFBFBD>**嚗䥪DF, Word, TXT, Excel (<EFBFBD>𣂼<EFBFBD> 20MB)<EFBFBD>?
|
||||
* **憭<EFBFBD><EFBFBD> (Postgres-Only)**嚗?
|
||||
1. 銝𠹺<EFBFBD> OSS \-\> common\_schema.files<EFBFBD>?
|
||||
2. <EFBFBD>𡒊垢<EFBFBD>𣂼<EFBFBD><EFBFBD><EFBFBD>𧋦 \-\> <20>芸<EFBFBD>瘜典<E7989C> LLM Context<EFBFBD>?
|
||||
3. **UI <EFBFBD>曄內**嚗𡁜銁瘞娍部銝𧢲䲮<F0A7A2B2>曄內<E69B84><E585A7>辣撠誩㨃<E8AAA9><E3A883><EFBFBD><EFBFBD>暹<EFBFBD>+<2B><>辣<EFBFBD>㵪<EFBFBD><E3B5AA>?
|
||||
#### **F2.4 蝏𤘪<E89D8F><F0A498AA>滢<EFBFBD><E6BBA2>?(Action Bar)**
|
||||
* **格式**:PDF, Word, TXT, Excel (限制 20MB)。
|
||||
* **处理 (Postgres-Only)**:
|
||||
1. 上传 OSS \-\> common\_schema.files。
|
||||
2. 后端提取文本 \-\> 截取注入 LLM Context。
|
||||
3. **UI 显示**:在气泡下方显示附件小卡片(图标+文件名)。
|
||||
|
||||
#### **F2.4 结果操作栏 (Action Bar)**
|
||||
|
||||
每条 AI 回答下方提供微型工具栏(Hover 显示):
|
||||
|
||||
* **憭滚<EFBFBD>**嚗𡁜<E59A97><F0A1819C>?Markdown 皞鞟<EFBFBD><EFBFBD>?
|
||||
* **<EFBFBD>齿鰵<EFBFBD><EFBFBD><EFBFBD>**嚗帋<E59A97>皛⊥<E79A9B>敶枏<E695B6><E69E8F>䂿<EFBFBD>嚗諹圻<E8ABB9>煾<EFBFBD>霂𨰻<E99C82>?
|
||||
* **撖澆枂 Word**嚗朞<EFBFBD><EFBFBD>?RVW 璅∪<E79285><E288AA>?docx 撖澆枂<E6BE86>滚𦛚嚗<F0A69B9A><E59A97>敶枏<E695B6><E69E8F>閗蔭撖寡<E69296>撖澆枂銝箸<E98A9D>獢<EFBFBD><E78DA2>?
|
||||
* **复制**:复制 Markdown 源码。
|
||||
* **重新生成**:不满意当前回答,触发重试。
|
||||
* **导出 Word**:调用 RVW 模块的 docx 导出服务,将当前单轮对话导出为文档。
|
||||
|
||||
### **F3. 移动端适配 (Mobile Adaptation)**
|
||||
|
||||
#### **F3.1 响应式布局**
|
||||
|
||||
* **<EFBFBD>剔<EFBFBD>**嚗饢d (768px)<EFBFBD>?
|
||||
* **Dashboard**嚗?
|
||||
* <EFBFBD>鞱<EFBFBD>憿園<EFBFBD>憭齿<EFBFBD>撖潸⏛嚗<EFBFBD>蘨靽萘<EFBFBD> Logo <20>?<3F>冽<EFBFBD>憭游<E686AD><E6B8B8>?
|
||||
* <EFBFBD>箄<EFBFBD>雿枏㨃<EFBFBD><EFBFBD>眏 3 <20>堒<EFBFBD>銝?1 <20>埈<EFBFBD>撘誩<E69298>撅<EFBFBD><E69285>?
|
||||
* 撌虫儒<EFBFBD>園𡢿頧湛<EFBFBD>Timeline嚗匧銁蝘餃𢆡蝡舫<EFBFBD>靚<EFBFBD>㟲<EFBFBD>瑕<EFBFBD>嚗屸<EFBFBD><EFBFBD>滚<EFBFBD><EFBFBD>刻<EFBFBD>憭𡁏偌撟喟征<EFBFBD>湛<EFBFBD><EFBFBD>舀㺿銝粹▲<EFBFBD>冽赤<EFBFBD>烐郊撉斗辺<EFBFBD>𣇉<EFBFBD><EFBFBD>硋椰靘抒瑪<EFBFBD>∴<EFBFBD><EFBFBD>?
|
||||
* **断点**:md (768px)。
|
||||
* **Dashboard**:
|
||||
* 隐藏顶部复杂导航,只保留 Logo 和 用户头像。
|
||||
* 智能体卡片由 3 列变为 1 列流式布局。
|
||||
* 左侧时间轴(Timeline)在移动端需调整样式,避免占用过多水平空间(可改为顶部横向步骤条或简化左侧线条)。
|
||||
|
||||
#### **F3.2 交互优化**
|
||||
|
||||
* **颲枏<EFBFBD>雿㯄<EFBFBD>**嚗?
|
||||
* 颲枏<EFBFBD>獢<EFBFBD><EFBFBD><EFBFBD>行𧒄嚗𣬚&靽苷<EFBFBD>鋡?iOS/Android 頧舫睸<EFBFBD>㗛<EFBFBD><EFBFBD>∴<EFBFBD>scrollIntoView嚗剹<EFBFBD>?
|
||||
* <EFBFBD>煾<EFBFBD><EFBFBD><EFBFBD><EFBFBD>桀銁蝘餃𢆡蝡舫<EFBFBD>憪讠<EFBFBD><EFBFBD>航<EFBFBD><EFBFBD>?
|
||||
* **閫行綉<EFBFBD>漤<EFBFBD>**嚗𡁏<E59A97><F0A1818F>桀<EFBFBD><E6A180>∠<EFBFBD>憓𧼮<E68693> active <20><><EFBFBD><EFBFBD>航𠧧<E888AA>睃<EFBFBD><E79D83>?
|
||||
* **输入体验**:
|
||||
* 输入框聚焦时,确保不被 iOS/Android 软键盘遮挡(scrollIntoView)。
|
||||
* 发送按钮在移动端需始终可见。
|
||||
* **触控反馈**:按钮和卡片增加 active 态背景色变化。
|
||||
|
||||
## **4\. 数据架构 (Postgres-Only)**
|
||||
|
||||
*(靽脲<EFBFBD>銝滚<EFBFBD>嚗<EFBFBD><EFBFBD><EFBFBD>?V2.0 摰帋<EFBFBD>)*
|
||||
*(保持不变,复用 V2.0 定义)*
|
||||
|
||||
// schema.prisma (新增字段)
|
||||
|
||||
model AiaMessage {
|
||||
// ... 现有字段
|
||||
thinkingContent String? @db.Text // 摮睃<EFBFBD><EFBFBD>萘輕<EFBFBD>曉<EFBFBD>摰?(\<think\>...\</think\>)
|
||||
thinkingContent String? @db.Text // 存储思维链内容 (\<think\>...\</think\>)
|
||||
// ...
|
||||
}
|
||||
|
||||
## **5\. <EFBFBD>滨蔭<EFBFBD>硋<EFBFBD><EFBFBD>𤑳<EFBFBD><EFBFBD>?*
|
||||
## **5\. 配置化开发策略**
|
||||
|
||||
*(保持不变)*
|
||||
|
||||
## **6\. <EFBFBD>𧼮<EFBFBD><EFBFBD>賣<EFBFBD>折<EFBFBD>瘙?*
|
||||
## **6\. 非功能性需求**
|
||||
|
||||
* **瘚<EFBFBD><EFBFBD>雿㯄<EFBFBD>**嚗関TFB (擐硋<E69390><E7A18B>滚<EFBFBD><E6BB9A>園𡢿) \< 1.5s<EFBFBD>?
|
||||
* **蝘餃𢆡蝡舀<EFBFBD>扯<EFBFBD>**嚗𡁻<E59A97>撅誩<E69285>頧?\< 1s (LCP)<EFBFBD>?
|
||||
* **<EFBFBD>脫<EFBFBD>**嚗𡁏<E59A97><F0A1818F>暹<EFBFBD>蝝X<E89D9D><EFBCB8><EFBFBD>憓𧼮<E68693> 500ms <20>脫<EFBFBD>嚗屸<E59A97><E5B1B8>漤<EFBFBD>蝜<EFBFBD>窈瘙?Router Agent<EFBFBD>
|
||||
* **流式体验**:TTFB (首字响应时间) \< 1.5s。
|
||||
* **移动端性能**:首屏加载 \< 1s (LCP)。
|
||||
* **防抖**:意图搜索框需增加 500ms 防抖,避免频繁请求 Router Agent。
|
||||
@@ -1,9 +1,9 @@
|
||||
# AIA - AI智能问答模块:数据库设计
|
||||
|
||||
> **<EFBFBD><EFBFBD>𧋦嚗?* v1.0
|
||||
> **<EFBFBD>湔鰵<EFBFBD>園𡢿嚗?* 2025-11-12
|
||||
> **<EFBFBD>唳旿摨廍chema嚗?* `aia_schema`
|
||||
> **<EFBFBD>嗆<EFBFBD><EFBFBD><EFBFBD>** <20>?撌脣<E6928C><E884A3>賢僎餈<E5838E>宏
|
||||
> **版本:** v1.0
|
||||
> **更新时间:** 2025-11-12
|
||||
> **数据库Schema:** `aia_schema`
|
||||
> **状态:** ✅ 已实施并迁移
|
||||
|
||||
---
|
||||
|
||||
@@ -23,19 +23,19 @@
|
||||
|
||||
### 功能定位
|
||||
|
||||
**AIA嚗㇁I Intelligent Assistant嚗? AI<EFBFBD>箄<EFBFBD><EFBFBD>桃<EFBFBD>璅∪<EFBFBD>**<EFBFBD>臬像<EFBFBD>啁<EFBFBD><EFBFBD>詨<EFBFBD>撖寡<EFBFBD>撘閙<EFBFBD>嚗峕<EFBFBD>靘𨥈<EFBFBD>
|
||||
**AIA(AI Intelligent Assistant)- AI智能问答模块**是平台的核心对话引擎,提供:
|
||||
|
||||
1. **项目管理** - 研究项目的创建和管理
|
||||
2. **<EFBFBD>箄<EFBFBD>撖寡<EFBFBD>** - <EFBFBD>箔<EFBFBD>LLM<EFBFBD><EFBFBD><EFBFBD>銝𡁻<EFBFBD><EFBFBD>笔笆霂?
|
||||
2. **智能对话** - 基于LLM的专业领域对话
|
||||
3. **通用问答** - 不绑定项目的通用AI对话
|
||||
4. **瘨<EFBFBD><EFBFBD>蝞∠<EFBFBD>** - 撖寡<EFBFBD><EFBFBD><EFBFBD>蟮霈啣<EFBFBD><EFBFBD>峕<EFBFBD>蝝?
|
||||
4. **消息管理** - 对话历史记录和检索
|
||||
|
||||
### 核心业务场景
|
||||
|
||||
- 用户创建临床研究项目
|
||||
- 在项目内与AI进行专业对话
|
||||
- 雿輻鍂<EFBFBD>𡁶鍂撖寡<EFBFBD><EFBFBD>蠘<EFBFBD>敹恍<EFBFBD>笔倮霂?
|
||||
- <EFBFBD>亦<EFBFBD><EFBFBD>𣬚恣<EFBFBD><EFBFBD>笆霂嘥<EFBFBD><EFBFBD>?
|
||||
- 使用通用对话功能快速咨询
|
||||
- 查看和管理对话历史
|
||||
|
||||
---
|
||||
|
||||
@@ -53,45 +53,45 @@ GRANT ALL ON SCHEMA aia_schema TO aiclinical_admin;
|
||||
```
|
||||
|
||||
### 数据迁移
|
||||
- **餈<EFBFBD>宏<EFBFBD>園𡢿嚗?* 2025-11-12
|
||||
- **皞𠩐chema嚗?* public
|
||||
- **餈<EFBFBD>宏<EFBFBD>𡁏𧋦嚗?* `docs/09-<EFBFBD>嗆<EFBFBD>摰墧鴌/migration-scripts/003-migrate-aia.sql`
|
||||
- **<EFBFBD>唳旿摰峕㟲<EFBFBD>改<EFBFBD>** <EFBFBD>?100%餈<EFBFBD>宏<EFBFBD>𣂼<EFBFBD>
|
||||
- **迁移时间:** 2025-11-12
|
||||
- **源Schema:** public
|
||||
- **迁移脚本:** `docs/09-架构实施/migration-scripts/003-migrate-aia.sql`
|
||||
- **数据完整性:** ✅ 100%迁移成功
|
||||
|
||||
---
|
||||
|
||||
## 数据库表设计
|
||||
|
||||
### 銵典<EFBFBD>銵?
|
||||
### 表列表
|
||||
|
||||
| 銵典<EFBFBD> | <20>券<EFBFBD>?| 銵峕㺭嚗<E3BAAD>摯霈∴<E99C88> | <20>嗆<EFBFBD>?|
|
||||
| 表名 | 用途 | 行数(估计) | 状态 |
|
||||
|------|------|------------|------|
|
||||
| `projects` | <EFBFBD>𠉛弦憿寧𤌍 | 1-100/<EFBFBD>冽<EFBFBD> | <20>?撌脤<E6928C>蝵?|
|
||||
| `conversations` | 憿寧𤌍撖寡<EFBFBD> | 10-500/憿寧𤌍 | <20>?撌脤<E6928C>蝵?|
|
||||
| `messages` | 撖寡<EFBFBD>瘨<EFBFBD><EFBFBD> | 10-1000/撖寡<EFBFBD> | <20>?撌脤<E6928C>蝵?|
|
||||
| `general_conversations` | <EFBFBD>𡁶鍂撖寡<EFBFBD> | 10-100/<EFBFBD>冽<EFBFBD> | <20>?撌脤<E6928C>蝵?|
|
||||
| `general_messages` | <EFBFBD>𡁶鍂撖寡<EFBFBD>瘨<EFBFBD><EFBFBD> | 10-1000/撖寡<EFBFBD> | <20>?撌脤<E6928C>蝵?|
|
||||
| `projects` | 研究项目 | 1-100/用户 | ✅ 已部署 |
|
||||
| `conversations` | 项目对话 | 10-500/项目 | ✅ 已部署 |
|
||||
| `messages` | 对话消息 | 10-1000/对话 | ✅ 已部署 |
|
||||
| `general_conversations` | 通用对话 | 10-100/用户 | ✅ 已部署 |
|
||||
| `general_messages` | 通用对话消息 | 10-1000/对话 | ✅ 已部署 |
|
||||
|
||||
**<EFBFBD>餉恣嚗?* 5銝芾”
|
||||
**总计:** 5个表
|
||||
|
||||
---
|
||||
|
||||
### 1. projects - <EFBFBD>𠉛弦憿寧𤌍銵?
|
||||
### 1. projects - 研究项目表
|
||||
|
||||
**<EFBFBD>券<EFBFBD>䈑<EFBFBD>** 摮睃<E691AE><E79D83>冽<EFBFBD><E586BD>𥕦遣<F0A595A6><E981A3>葩摨羓<E691A8>蝛園★<E59C92>?
|
||||
**用途:** 存储用户创建的临床研究项目
|
||||
|
||||
#### 銵函<EFBFBD><EFBFBD>?
|
||||
#### 表结构
|
||||
|
||||
| 摮埈挾<EFBFBD>?| <20>唳旿蝐餃<E89D90> | 蝥行<E89DA5> | 霂湔<E99C82> |
|
||||
| 字段名 | 数据类型 | 约束 | 说明 |
|
||||
|--------|---------|------|------|
|
||||
| id | TEXT | PRIMARY KEY | 憿寧𤌍<EFBFBD>臭<EFBFBD><EFBFBD><EFBFBD><EFBFBD>嚗㇎UID嚗?|
|
||||
| id | TEXT | PRIMARY KEY | 项目唯一标识(UUID) |
|
||||
| user_id | TEXT | NOT NULL, FK | 所属用户ID |
|
||||
| name | TEXT | NOT NULL | 项目名称 |
|
||||
| background | TEXT | NULL | 研究背景 |
|
||||
| research_type | TEXT | NULL | 研究类型(observational/experimental等) |
|
||||
| created_at | TIMESTAMPTZ | NOT NULL, DEFAULT now() | 创建时间 |
|
||||
| updated_at | TIMESTAMPTZ | NOT NULL | 更新时间 |
|
||||
| deleted_at | TIMESTAMPTZ | NULL | 頧臬<EFBFBD><EFBFBD>斗𧒄<EFBFBD>?|
|
||||
| deleted_at | TIMESTAMPTZ | NULL | 软删除时间 |
|
||||
|
||||
#### Prisma Model
|
||||
|
||||
@@ -120,32 +120,32 @@ model Project {
|
||||
|
||||
#### 业务规则
|
||||
|
||||
1. **頧臬<EFBFBD><EFBFBD>斗㦤<EFBFBD>?* - 雿輻鍂`deleted_at`<EFBFBD><EFBFBD>扇<EFBFBD>𣳇膄嚗䔶<EFBFBD><EFBFBD>拍<EFBFBD><EFBFBD>𣳇膄
|
||||
1. **软删除机制** - 使用`deleted_at`标记删除,不物理删除
|
||||
2. **级联删除** - 删除项目时,关联的对话也被软删除
|
||||
3. **用户隔离** - 通过`user_id`实现数据隔离
|
||||
|
||||
---
|
||||
|
||||
### 2. conversations - 憿寧𤌍撖寡<EFBFBD>銵?
|
||||
### 2. conversations - 项目对话表
|
||||
|
||||
**用途:** 存储项目内的AI对话会话
|
||||
|
||||
#### 銵函<EFBFBD><EFBFBD>?
|
||||
#### 表结构
|
||||
|
||||
| 摮埈挾<EFBFBD>?| <20>唳旿蝐餃<E89D90> | 蝥行<E89DA5> | 霂湔<E99C82> |
|
||||
| 字段名 | 数据类型 | 约束 | 说明 |
|
||||
|--------|---------|------|------|
|
||||
| id | TEXT | PRIMARY KEY | 撖寡<EFBFBD><EFBFBD>臭<EFBFBD><EFBFBD><EFBFBD><EFBFBD>嚗㇎UID嚗?|
|
||||
| id | TEXT | PRIMARY KEY | 对话唯一标识(UUID) |
|
||||
| user_id | TEXT | NOT NULL, FK | 所属用户ID |
|
||||
| project_id | TEXT | NULL, FK | 所属项目ID(可选) |
|
||||
| agent_id | TEXT | NOT NULL | 智能体ID |
|
||||
| title | TEXT | NOT NULL | 对话标题 |
|
||||
| model_name | TEXT | NOT NULL, DEFAULT 'deepseek-v3' | 使用的LLM模型 |
|
||||
| message_count | INTEGER | NOT NULL, DEFAULT 0 | 消息数量 |
|
||||
| total_tokens | INTEGER | NOT NULL, DEFAULT 0 | 蝝航恣token<EFBFBD>?|
|
||||
| metadata | JSONB | NULL | <EFBFBD>拙<EFBFBD><EFBFBD><EFBFBD>㺭<EFBFBD>?|
|
||||
| total_tokens | INTEGER | NOT NULL, DEFAULT 0 | 累计token数 |
|
||||
| metadata | JSONB | NULL | 扩展元数据 |
|
||||
| created_at | TIMESTAMPTZ | NOT NULL, DEFAULT now() | 创建时间 |
|
||||
| updated_at | TIMESTAMPTZ | NOT NULL | 更新时间 |
|
||||
| deleted_at | TIMESTAMPTZ | NULL | 頧臬<EFBFBD><EFBFBD>斗𧒄<EFBFBD>?|
|
||||
| deleted_at | TIMESTAMPTZ | NULL | 软删除时间 |
|
||||
|
||||
#### Prisma Model
|
||||
|
||||
@@ -181,28 +181,28 @@ model Conversation {
|
||||
|
||||
#### 业务规则
|
||||
|
||||
1. **憿寧𤌍<EFBFBD>唾<EFBFBD><EFBFBD>舫<EFBFBD>?* - `project_id`<EFBFBD>臭蛹蝛綽<EFBFBD><EFBFBD>舀<EFBFBD>憿寧𤌍<EFBFBD><EFBFBD><EFBFBD>撖寡<EFBFBD>
|
||||
2. **霈⊥㺭<EFBFBD>典<EFBFBD>畾?* - `message_count`<EFBFBD>䈣total_tokens`<EFBFBD>其<EFBFBD>蝏蠘恣嚗屸<EFBFBD>閬<EFBFBD><EFBFBD><EFBFBD>嗆凒<EFBFBD>?
|
||||
1. **项目关联可选** - `project_id`可为空,支持项目内外对话
|
||||
2. **计数器字段** - `message_count`和`total_tokens`用于统计,需要实时更新
|
||||
3. **模型选择** - 支持多种LLM模型(deepseek-v3/gpt-5-pro/claude-4.5等)
|
||||
4. **<EFBFBD>拙<EFBFBD><EFBFBD><EFBFBD>㺭<EFBFBD>?* - `metadata`<EFBFBD>其<EFBFBD>摮睃<EFBFBD><EFBFBD>滨蔭<EFBFBD><EFBFBD>㺭<EFBFBD><EFBFBD><EFBFBD>銝𧢲<EFBFBD>蝑?
|
||||
4. **扩展元数据** - `metadata`用于存储配置参数、上下文等
|
||||
|
||||
---
|
||||
|
||||
### 3. messages - 撖寡<EFBFBD>瘨<EFBFBD><EFBFBD>銵?
|
||||
### 3. messages - 对话消息表
|
||||
|
||||
**用途:** 存储对话中的每条消息
|
||||
|
||||
#### 銵函<EFBFBD><EFBFBD>?
|
||||
#### 表结构
|
||||
|
||||
| 摮埈挾<EFBFBD>?| <20>唳旿蝐餃<E89D90> | 蝥行<E89DA5> | 霂湔<E99C82> |
|
||||
| 字段名 | 数据类型 | 约束 | 说明 |
|
||||
|--------|---------|------|------|
|
||||
| id | TEXT | PRIMARY KEY | 瘨<EFBFBD><EFBFBD><EFBFBD>臭<EFBFBD><EFBFBD><EFBFBD><EFBFBD>嚗㇎UID嚗?|
|
||||
| id | TEXT | PRIMARY KEY | 消息唯一标识(UUID) |
|
||||
| conversation_id | TEXT | NOT NULL, FK | 所属对话ID |
|
||||
| role | TEXT | NOT NULL | 閫坿𠧧嚗óser/assistant/system嚗?|
|
||||
| role | TEXT | NOT NULL | 角色(user/assistant/system) |
|
||||
| content | TEXT | NOT NULL | 消息内容 |
|
||||
| model | TEXT | NULL | 雿輻鍂<EFBFBD><EFBFBD>芋<EFBFBD>页<EFBFBD>assistant瘨<EFBFBD><EFBFBD>嚗?|
|
||||
| metadata | JSONB | NULL | <EFBFBD>拙<EFBFBD><EFBFBD><EFBFBD>㺭<EFBFBD>?|
|
||||
| tokens | INTEGER | NULL | 瘨<EFBFBD><EFBFBD>token<EFBFBD>?|
|
||||
| model | TEXT | NULL | 使用的模型(assistant消息) |
|
||||
| metadata | JSONB | NULL | 扩展元数据 |
|
||||
| tokens | INTEGER | NULL | 消息token数 |
|
||||
| is_pinned | BOOLEAN | NOT NULL, DEFAULT false | 是否置顶 |
|
||||
| created_at | TIMESTAMPTZ | NOT NULL, DEFAULT now() | 创建时间 |
|
||||
|
||||
@@ -234,27 +234,27 @@ model Message {
|
||||
#### 业务规则
|
||||
|
||||
1. **角色类型** - `role`固定为`user`、`assistant`或`system`
|
||||
2. **<EFBFBD>芾粉<EFBFBD>?* - 瘨<><E798A8>銝<EFBFBD><E98A9D>血<EFBFBD>撱箔<E692B1><E7AE94>臭耨<E887AD>對<EFBFBD><E5B08D>芣<EFBFBD>`is_pinned`<EFBFBD>臭耨<EFBFBD>對<EFBFBD>
|
||||
2. **只读性** - 消息一旦创建不可修改(只有`is_pinned`可修改)
|
||||
3. **级联删除** - 删除对话时,消息自动删除
|
||||
4. **置顶功能** - 重要消息可通过`is_pinned`标记
|
||||
|
||||
---
|
||||
|
||||
### 4. general_conversations - <EFBFBD>𡁶鍂撖寡<EFBFBD>銵?
|
||||
### 4. general_conversations - 通用对话表
|
||||
|
||||
**用途:** 存储不绑定项目的通用AI对话
|
||||
|
||||
#### 銵函<EFBFBD><EFBFBD>?
|
||||
#### 表结构
|
||||
|
||||
| 摮埈挾<EFBFBD>?| <20>唳旿蝐餃<E89D90> | 蝥行<E89DA5> | 霂湔<E99C82> |
|
||||
| 字段名 | 数据类型 | 约束 | 说明 |
|
||||
|--------|---------|------|------|
|
||||
| id | TEXT | PRIMARY KEY | 撖寡<EFBFBD><EFBFBD>臭<EFBFBD><EFBFBD><EFBFBD><EFBFBD>嚗㇎UID嚗?|
|
||||
| id | TEXT | PRIMARY KEY | 对话唯一标识(UUID) |
|
||||
| user_id | TEXT | NOT NULL, FK | 所属用户ID |
|
||||
| title | TEXT | NOT NULL | 对话标题 |
|
||||
| model_name | TEXT | NOT NULL, DEFAULT 'qwen-long' | 使用的LLM模型 |
|
||||
| created_at | TIMESTAMPTZ | NOT NULL, DEFAULT now() | 创建时间 |
|
||||
| updated_at | TIMESTAMPTZ | NOT NULL | 更新时间 |
|
||||
| deleted_at | TIMESTAMPTZ | NULL | 頧臬<EFBFBD><EFBFBD>斗𧒄<EFBFBD>?|
|
||||
| deleted_at | TIMESTAMPTZ | NULL | 软删除时间 |
|
||||
|
||||
#### Prisma Model
|
||||
|
||||
@@ -282,25 +282,25 @@ model GeneralConversation {
|
||||
|
||||
#### 业务规则
|
||||
|
||||
1. **頧駁<EFBFBD>蝥批笆霂?* - 銝漤<E98A9D>閬<EFBFBD>★<EFBFBD>桀<EFBFBD><E6A180>箄<EFBFBD>雿枏<E99BBF><E69E8F>?
|
||||
2. **敹恍<EFBFBD>笔倮霂?* - <20>其<EFBFBD><E585B6>冽<EFBFBD><E586BD><EFBFBD>葩<EFBFBD>園䔮憸睃<E686B8>敹恍<E695B9><E6818D>䰻霂?
|
||||
1. **轻量级对话** - 不需要项目和智能体关联
|
||||
2. **快速咨询** - 用于用户的临时问题和快速查询
|
||||
3. **独立管理** - 与项目对话分开管理
|
||||
|
||||
---
|
||||
|
||||
### 5. general_messages - <EFBFBD>𡁶鍂撖寡<EFBFBD>瘨<EFBFBD><EFBFBD>銵?
|
||||
### 5. general_messages - 通用对话消息表
|
||||
|
||||
**用途:** 存储通用对话中的每条消息
|
||||
|
||||
#### 銵函<EFBFBD><EFBFBD>?
|
||||
#### 表结构
|
||||
|
||||
| 摮埈挾<EFBFBD>?| <20>唳旿蝐餃<E89D90> | 蝥行<E89DA5> | 霂湔<E99C82> |
|
||||
| 字段名 | 数据类型 | 约束 | 说明 |
|
||||
|--------|---------|------|------|
|
||||
| id | TEXT | PRIMARY KEY | 瘨<EFBFBD><EFBFBD><EFBFBD>臭<EFBFBD><EFBFBD><EFBFBD><EFBFBD>嚗㇎UID嚗?|
|
||||
| id | TEXT | PRIMARY KEY | 消息唯一标识(UUID) |
|
||||
| conversation_id | TEXT | NOT NULL, FK | 所属对话ID |
|
||||
| role | TEXT | NOT NULL | 閫坿𠧧嚗óser/assistant/system嚗?|
|
||||
| role | TEXT | NOT NULL | 角色(user/assistant/system) |
|
||||
| content | TEXT | NOT NULL | 消息内容 |
|
||||
| metadata | JSONB | NULL | <EFBFBD>拙<EFBFBD><EFBFBD><EFBFBD>㺭<EFBFBD>?|
|
||||
| metadata | JSONB | NULL | 扩展元数据 |
|
||||
| created_at | TIMESTAMPTZ | NOT NULL, DEFAULT now() | 创建时间 |
|
||||
|
||||
#### Prisma Model
|
||||
@@ -326,7 +326,7 @@ model GeneralMessage {
|
||||
|
||||
#### 业务规则
|
||||
|
||||
1. **蝞<EFBFBD><EFBFBD>𤥁挽霈?* - <20>豢<EFBFBD>憿寧𤌍瘨<F0A48C8D><E798A8>嚗<EFBFBD>縧<EFBFBD>劐<EFBFBD>token蝏蠘恣<E8A098>𣬚蔭憿嗅<E686BF><E59785>?
|
||||
1. **简化设计** - 相比项目消息,去掉了token统计和置顶功能
|
||||
2. **级联删除** - 删除对话时,消息自动删除
|
||||
|
||||
---
|
||||
@@ -398,51 +398,51 @@ erDiagram
|
||||
|
||||
### 跨Schema引用
|
||||
|
||||
**憭㚚睸<EFBFBD>喟頂嚗?*
|
||||
- `projects.user_id` <EFBFBD>?`platform_schema.users.id`
|
||||
- `conversations.user_id` <EFBFBD>?`platform_schema.users.id`
|
||||
- `general_conversations.user_id` <EFBFBD>?`platform_schema.users.id`
|
||||
**外键关系:**
|
||||
- `projects.user_id` → `platform_schema.users.id`
|
||||
- `conversations.user_id` → `platform_schema.users.id`
|
||||
- `general_conversations.user_id` → `platform_schema.users.id`
|
||||
|
||||
**霂湔<EFBFBD>嚗?* Prisma<6D>芸𢆡憭<F0A286A1><E686AD>頝沒chema憭㚚睸嚗<E79DB8><E59A97><EFBFBD>其誨<E585B6><E8AAA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>喳<EFBFBD>Schema<EFBFBD>滨<EFBFBD>
|
||||
**说明:** Prisma自动处理跨Schema外键,应用代码无需关心Schema前缀
|
||||
|
||||
---
|
||||
|
||||
## 索引设计
|
||||
|
||||
### 主键索引
|
||||
<EFBFBD><EFBFBD><EFBFBD>㕑”<EFBFBD><EFBFBD>id`摮埈挾<E59F88>芸𢆡<E88AB8>𥕦遣B-tree銝駁睸蝝W<E89D9D><EFBCB7>?
|
||||
所有表的`id`字段自动创建B-tree主键索引。
|
||||
|
||||
### 外键索引
|
||||
|
||||
| 銵典<EFBFBD> | 蝝W<E89D9D>摮埈挾 | <20>券<EFBFBD>?|
|
||||
| 表名 | 索引字段 | 用途 |
|
||||
|------|---------|------|
|
||||
| projects | user_id | <EFBFBD>亥砭<EFBFBD>冽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>厰★<EFBFBD>?|
|
||||
| conversations | user_id | <EFBFBD>亥砭<EFBFBD>冽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>匧笆霂?|
|
||||
| projects | user_id | 查询用户的所有项目 |
|
||||
| conversations | user_id | 查询用户的所有对话 |
|
||||
| conversations | project_id | 查询项目内的对话 |
|
||||
| conversations | agent_id | 按智能体过滤对话 |
|
||||
| messages | conversation_id | <EFBFBD>亥砭撖寡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㗇<EFBFBD><EFBFBD>?|
|
||||
| messages | conversation_id | 查询对话的所有消息 |
|
||||
| general_conversations | user_id | 查询用户的通用对话 |
|
||||
| general_messages | conversation_id | <EFBFBD>亥砭撖寡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㗇<EFBFBD><EFBFBD>?|
|
||||
| general_messages | conversation_id | 查询对话的所有消息 |
|
||||
|
||||
### 时间索引
|
||||
|
||||
| 銵典<EFBFBD> | 蝝W<E89D9D>摮埈挾 | <20>券<EFBFBD>?|
|
||||
| 表名 | 索引字段 | 用途 |
|
||||
|------|---------|------|
|
||||
| projects | created_at | <EFBFBD>㗇𧒄<EFBFBD>湔<EFBFBD>摨誯★<EFBFBD>?|
|
||||
| projects | deleted_at | 餈<EFBFBD>誘撌脣<EFBFBD><EFBFBD>日★<EFBFBD>?|
|
||||
| conversations | created_at | <EFBFBD>㗇𧒄<EFBFBD>湔<EFBFBD>摨誩笆霂?|
|
||||
| conversations | updated_at | <EFBFBD>㗇凒<EFBFBD>唳𧒄<EFBFBD>湔<EFBFBD>摨?|
|
||||
| conversations | deleted_at | 餈<EFBFBD>誘撌脣<EFBFBD><EFBFBD>文笆霂?|
|
||||
| messages | created_at | <EFBFBD>㗇𧒄<EFBFBD>湔<EFBFBD>摨𤩺<EFBFBD><EFBFBD>?|
|
||||
| general_conversations | created_at | <EFBFBD>㗇𧒄<EFBFBD>湔<EFBFBD>摨誩笆霂?|
|
||||
| general_conversations | updated_at | <EFBFBD>㗇凒<EFBFBD>唳𧒄<EFBFBD>湔<EFBFBD>摨?|
|
||||
| general_messages | created_at | <EFBFBD>㗇𧒄<EFBFBD>湔<EFBFBD>摨𤩺<EFBFBD><EFBFBD>?|
|
||||
| projects | created_at | 按时间排序项目 |
|
||||
| projects | deleted_at | 过滤已删除项目 |
|
||||
| conversations | created_at | 按时间排序对话 |
|
||||
| conversations | updated_at | 按更新时间排序 |
|
||||
| conversations | deleted_at | 过滤已删除对话 |
|
||||
| messages | created_at | 按时间排序消息 |
|
||||
| general_conversations | created_at | 按时间排序对话 |
|
||||
| general_conversations | updated_at | 按更新时间排序 |
|
||||
| general_messages | created_at | 按时间排序消息 |
|
||||
|
||||
### 功能索引
|
||||
|
||||
| 銵典<EFBFBD> | 蝝W<E89D9D>摮埈挾 | <20>券<EFBFBD>?|
|
||||
| 表名 | 索引字段 | 用途 |
|
||||
|------|---------|------|
|
||||
| messages | is_pinned | 敹恍<EFBFBD><EFBFBD>䰻霂Y蔭憿嗆<EFBFBD><EFBFBD>?|
|
||||
| messages | is_pinned | 快速查询置顶消息 |
|
||||
|
||||
---
|
||||
|
||||
@@ -450,18 +450,18 @@ erDiagram
|
||||
|
||||
### 主键类型:TEXT vs UUID
|
||||
|
||||
**敶枏<EFBFBD>摰䂿緵嚗?* TEXT
|
||||
**当前实现:** TEXT
|
||||
```sql
|
||||
id TEXT PRIMARY KEY
|
||||
```
|
||||
|
||||
**UUID<EFBFBD><EFBFBD><EFBFBD>嚗?* Prisma `@default(uuid())`
|
||||
**UUID生成:** Prisma `@default(uuid())`
|
||||
```prisma
|
||||
id String @id @default(uuid())
|
||||
```
|
||||
|
||||
**霂湔<EFBFBD>嚗?*
|
||||
- 摮睃<E691AE><E79D83>澆<EFBFBD>嚗𡁜<E59A97>蝚虫葡敶W<E695B6><EFBCB7><EFBFBD>UID嚗<44><E59A97>`"a6ce8b46-bac6-4284-a9ae-031d636086bc"`嚗?
|
||||
**说明:**
|
||||
- 存储格式:字符串形式的UUID(如`"a6ce8b46-bac6-4284-a9ae-031d636086bc"`)
|
||||
- 优点:与现有代码兼容,无需迁移
|
||||
- 索引性能:与原生UUID类型相当
|
||||
|
||||
@@ -479,46 +479,46 @@ id String @id @default(uuid())
|
||||
- `messages.metadata`
|
||||
- `general_messages.metadata`
|
||||
|
||||
**隡条<EFBFBD>嚗?*
|
||||
- <EFBFBD>菜暑<EFBFBD><EFBFBD>㺭<EFBFBD>桃<EFBFBD><EFBFBD>?
|
||||
- <EFBFBD>舀<EFBFBD>GIN蝝W<EFBFBD>嚗<EFBFBD><EFBFBD><EFBFBD><EFBFBD>瘛餃<EFBFBD>嚗?
|
||||
- <EFBFBD>舀<EFBFBD>JSONB<EFBFBD>滢<EFBFBD>蝚行䰻霂?
|
||||
**优点:**
|
||||
- 灵活的数据结构
|
||||
- 支持GIN索引(按需添加)
|
||||
- 支持JSONB操作符查询
|
||||
|
||||
---
|
||||
|
||||
## 变更历史
|
||||
|
||||
### v1.0 - 2025-11-12 - <EFBFBD>嘥<EFBFBD><EFBFBD><EFBFBD>𧋦 <20>?
|
||||
### v1.0 - 2025-11-12 - 初始版本 ✅
|
||||
|
||||
**<EFBFBD>䀹凒<EFBFBD><EFBFBD>捆嚗?*
|
||||
**变更内容:**
|
||||
1. 从`public` schema迁移到`aia_schema`
|
||||
2. 5銝芾”<EFBFBD>券<EFBFBD>餈<EFBFBD>宏嚗?
|
||||
2. 5个表全部迁移:
|
||||
- projects
|
||||
- conversations
|
||||
- messages
|
||||
- general_conversations
|
||||
- general_messages
|
||||
3. 在Prisma中添加`@@schema("aia_schema")`标签
|
||||
4. <EFBFBD><EFBFBD><EFBFBD>㗇㺭<EFBFBD>?00%摰峕㟲餈<E39FB2>宏
|
||||
4. 所有数据100%完整迁移
|
||||
|
||||
**餈<EFBFBD>宏<EFBFBD>𡁏𧋦嚗?* `docs/09-<EFBFBD>嗆<EFBFBD>摰墧鴌/migration-scripts/003-migrate-aia.sql`
|
||||
**迁移脚本:** `docs/09-架构实施/migration-scripts/003-migrate-aia.sql`
|
||||
|
||||
**撉諹<EFBFBD><EFBFBD>嗆<EFBFBD><EFBFBD><EFBFBD>** <20>?撌脤<E6928C>霂<EFBFBD><E99C82><EFBFBD>蠘<EFBFBD>甇<EFBFBD>虜
|
||||
**验证状态:** ✅ 已验证,功能正常
|
||||
|
||||
---
|
||||
|
||||
## 📚 相关文档
|
||||
|
||||
- [Schema<EFBFBD>𠉛氖<EFBFBD>嗆<EFBFBD>霈曇恣](../../../09-<EFBFBD>嗆<EFBFBD>摰墧鴌/01-Schema<EFBFBD>𠉛氖<EFBFBD>嗆<EFBFBD>霈曇恣嚗?0銝迎<E98A9D>.md)
|
||||
- [Schema隔离架构设计](../../../09-架构实施/01-Schema隔离架构设计(10个).md)
|
||||
- [Schema迁移完成报告](../../../09-架构实施/Schema迁移完成报告.md)
|
||||
- [Prisma配置完成报告](../../../09-架构实施/Prisma配置完成报告.md)
|
||||
- [敹恍<EFBFBD>笔<EFBFBD><EFBFBD>賣<EFBFBD>霂閙𥁒<EFBFBD>𠺖(../../../09-<2D>嗆<EFBFBD>摰墧鴌/敹恍<E695B9>笔<EFBFBD><E7AC94>賣<EFBFBD>霂閙𥁒<E99699>?md)
|
||||
- [快速功能测试报告](../../../09-架构实施/快速功能测试报告.md)
|
||||
|
||||
---
|
||||
|
||||
**文档维护者:** AI助手
|
||||
**最后更新:** 2025-11-12
|
||||
**<EFBFBD><EFBFBD>﹝<EFBFBD>嗆<EFBFBD><EFBFBD><EFBFBD>** <20>?撌脣<E6928C><E884A3>𣂼僎撉諹<E69289>
|
||||
**文档状态:** ✅ 已完成并验证
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,161 +1,161 @@
|
||||
# AIA 妯″潡 V2.1 寮€鍙戣<EFBFBD>鍒?
|
||||
# AIA 模块 V2.1 开发计划
|
||||
|
||||
> **版本**:V2.1
|
||||
> **鍒涘缓鏃ユ湡**锛?026-01-11
|
||||
> **璁″垝鍛ㄦ湡**锛氱害 8-11 澶?
|
||||
> **绛栫暐**锛氶噸鍐欏悗绔?+ 澶嶇敤鏁版嵁搴?+ 鏂板紑鍙戝墠绔?
|
||||
> **鍏宠仈PRD**锛歚01-闇€姹傚垎鏋?AIA妯″潡PRD.md`
|
||||
> **鍏宠仈鍘熷瀷**锛歚01-闇€姹傚垎鏋?AI鏅鸿兘闂<E58598>瓟V2.html`
|
||||
> **创建日期**:2026-01-11
|
||||
> **计划周期**:约 8-11 天
|
||||
> **策略**:重写后端 + 复用数据库 + 新开发前端
|
||||
> **关联PRD**:`01-需求分析/AIA模块PRD.md`
|
||||
> **关联原型**:`01-需求分析/AI智能问答V2.html`
|
||||
|
||||
---
|
||||
|
||||
## 馃搵 寮€鍙戠瓥鐣ユ<E990A3>杩?
|
||||
## 📋 开发策略概述
|
||||
|
||||
### 核心决策
|
||||
|
||||
| 组件 | 策略 | 理由 |
|
||||
|------|------|------|
|
||||
| **鍚庣<EFBFBD>** | 馃敶 **閲嶅啓** | 鏃х増涓嶇<EFBFBD>鍚堜簯鍘熺敓瑙勮寖锛坈onsole.log銆佹湭浣跨敤骞冲彴鑳藉姏锛?|
|
||||
| **鏁版嵁搴?* | 鉁?**澶嶇敤** | aia_schema 宸插畬鍠勶紝瀛楁<EFBFBD>婊¤冻闇€姹?|
|
||||
| **鍓嶇<EFBFBD>** | 馃敶 **鏂板紑鍙?* | 澶嶇敤 shared/components/Chat 閫氱敤缁勪欢锛屽叏鏂癠I |
|
||||
| **后端** | 🔴 **重写** | 旧版不符合云原生规范(console.log、未使用平台能力) |
|
||||
| **数据库** | ✅ **复用** | aia_schema 已完善,字段满足需求 |
|
||||
| **前端** | 🔴 **新开发** | 复用 shared/components/Chat 通用组件,全新UI |
|
||||
|
||||
### 鎶€鏈<EFBFBD><EFBFBD>鑼?
|
||||
### 技术规范
|
||||
|
||||
| 规范 | 要求 |
|
||||
|------|------|
|
||||
| **鏃ュ織** | 浣跨敤 `logger` from `@/common/logging`锛堢<EFBFBD>姝?console.log锛?|
|
||||
| **日志** | 使用 `logger` from `@/common/logging`(禁止 console.log) |
|
||||
| **存储** | 使用 `storage` from `@/common/storage` |
|
||||
| **缓存** | 使用 `cache` from `@/common/cache` |
|
||||
| **队列** | 使用 `jobQueue` from `@/common/jobs` |
|
||||
| **Prompt** | 使用 `promptService.get()` from `@/common/prompts` |
|
||||
| **代码位置** | `backend/src/modules/aia/` |
|
||||
| **API璺<EFBFBD>敱** | `/api/v1/aia/*` |
|
||||
| **API路由** | `/api/v2/aia/*` |
|
||||
|
||||
---
|
||||
|
||||
## 馃搳 鏁版嵁搴撶姸鎬侊紙鉁?宸插畬鎴愶級
|
||||
## 📊 数据库状态(✅ 已完成)
|
||||
|
||||
### 琛ㄧ粨鏋勶紙3涓<EFBFBD>〃锛?
|
||||
### 表结构(3个表)
|
||||
|
||||
```
|
||||
aia_schema.projects 鉁?淇濈暀
|
||||
aia_schema.conversations 鉁?淇濈暀
|
||||
aia_schema.messages 鉁?淇濈暀 + 鏂板<E98F82>瀛楁<E7809B>
|
||||
aia_schema.projects ✅ 保留
|
||||
aia_schema.conversations ✅ 保留
|
||||
aia_schema.messages ✅ 保留 + 新增字段
|
||||
```
|
||||
|
||||
### 鏂板<EFBFBD>瀛楁<EFBFBD>锛?026-01-11 宸茶縼绉伙級
|
||||
### 新增字段(2026-01-11 已迁移)
|
||||
|
||||
| 琛?| 瀛楁<E7809B> | 绫诲瀷 | 璇存槑 |
|
||||
| 表 | 字段 | 类型 | 说明 |
|
||||
|----|------|------|------|
|
||||
| messages | `thinking_content` | TEXT | 娣卞害鎬濊€冨唴瀹?`<think>...</think>` |
|
||||
| messages | `attachments` | JSONB | 闄勪欢鏁扮粍锛堜笂闄?涓<>紝鍗曚釜鈮?0MB锛屾枃鏈<E69E83>墹30K tokens锛?|
|
||||
| messages | `thinking_content` | TEXT | 深度思考内容 `<think>...</think>` |
|
||||
| messages | `attachments` | JSONB | 附件数组(上限5个,单个≤20MB,文本≤30K tokens) |
|
||||
|
||||
### 已删除表
|
||||
|
||||
| 琛?| 鍘熷洜 |
|
||||
| 表 | 原因 |
|
||||
|----|------|
|
||||
| `general_conversations` | 鍔熻兘閲嶅彔锛屼娇鐢?conversations.project_id = NULL |
|
||||
| `general_conversations` | 功能重叠,使用 conversations.project_id = NULL |
|
||||
| `general_messages` | 功能重叠 |
|
||||
|
||||
---
|
||||
|
||||
## 馃棑锔?寮€鍙戦樁娈?
|
||||
## 🗓️ 开发阶段
|
||||
|
||||
### Phase 1: 鍚庣<EFBFBD>閲嶅啓锛?-4澶╋級
|
||||
### Phase 1: 后端重写(3-4天)
|
||||
|
||||
#### Day 1: 模块骨架 + 核心服务
|
||||
|
||||
**目标**:搭建模块结构,迁移核心对话服务
|
||||
|
||||
**浠诲姟娓呭崟**锛?
|
||||
**任务清单**:
|
||||
|
||||
- [ ] **1.1 创建模块目录结构**
|
||||
```
|
||||
backend/src/modules/aia/
|
||||
├── controllers/
|
||||
鈹? 鈹溾攢鈹€ conversationController.ts
|
||||
鈹? 鈹溾攢鈹€ agentController.ts
|
||||
鈹? 鈹斺攢鈹€ projectController.ts
|
||||
│ ├── conversationController.ts
|
||||
│ ├── agentController.ts
|
||||
│ └── projectController.ts
|
||||
├── services/
|
||||
鈹? 鈹溾攢鈹€ conversationService.ts
|
||||
鈹? 鈹溾攢鈹€ agentService.ts
|
||||
鈹? 鈹斺攢鈹€ projectService.ts
|
||||
│ ├── conversationService.ts
|
||||
│ ├── agentService.ts
|
||||
│ └── projectService.ts
|
||||
├── routes/
|
||||
鈹? 鈹斺攢鈹€ index.ts
|
||||
│ └── index.ts
|
||||
├── types/
|
||||
鈹? 鈹斺攢鈹€ index.ts
|
||||
│ └── index.ts
|
||||
└── index.ts
|
||||
```
|
||||
|
||||
- [ ] **1.2 重写 conversationService**
|
||||
- 浠?legacy 澶嶅埗鏍稿績閫昏緫
|
||||
- 鏇挎崲 `console.log` 鈫?`logger`
|
||||
- 浣跨敤 `prisma.message`锛堝凡鍦?aia_schema锛?
|
||||
- 从 legacy 复制核心逻辑
|
||||
- 替换 `console.log` → `logger`
|
||||
- 使用 `prisma.message`(已在 aia_schema)
|
||||
- 添加 `thinkingContent` 处理逻辑
|
||||
- 保持流式输出能力
|
||||
|
||||
- [ ] **1.3 重写 agentService**
|
||||
- 改用 `promptService.get()` 获取 Prompt
|
||||
- 缂撳瓨鏅鸿兘浣撻厤缃<EFBFBD>紙浣跨敤 `cache`锛?
|
||||
- 缓存智能体配置(使用 `cache`)
|
||||
|
||||
- [ ] **1.4 注册 v2 路由**
|
||||
- 娉ㄥ唽鍒?`/api/v1/aia/*`
|
||||
- 淇濇寔 legacy 璺<EFBFBD>敱鍏煎<EFBFBD>锛堥€愭<EFBFBD>杩佺Щ锛?
|
||||
- 注册到 `/api/v2/aia/*`
|
||||
- 保持 legacy 路由兼容(逐步迁移)
|
||||
|
||||
**楠屾敹鏍囧噯**锛?
|
||||
**验收标准**:
|
||||
- [ ] 基础对话功能可用
|
||||
- [ ] 流式输出正常
|
||||
- [ ] 鏃ュ織杈撳嚭鍒?logger
|
||||
- [ ] 日志输出到 logger
|
||||
|
||||
---
|
||||
|
||||
#### Day 2: 娣卞害鎬濊€?+ 闄勪欢涓婁紶
|
||||
#### Day 2: 深度思考 + 附件上传
|
||||
|
||||
**鐩<EFBFBD>爣**锛氬疄鐜?V2.1 鏂板<E98F82>鍔熻兘
|
||||
**目标**:实现 V2.1 新增功能
|
||||
|
||||
**浠诲姟娓呭崟**锛?
|
||||
**任务清单**:
|
||||
|
||||
- [ ] **2.1 娣卞害鎬濊€冩ā寮?*
|
||||
- 妫€娴?LLM 杈撳嚭涓<E59AAD>殑 `<think>...</think>` 鏍囩<EFBFBD>
|
||||
- [ ] **2.1 深度思考模式**
|
||||
- 检测 LLM 输出中的 `<think>...</think>` 标签
|
||||
- 提取并存储到 `messages.thinking_content`
|
||||
- 浠?`content` 涓<EFBFBD>Щ闄?think 鏍囩<EFBFBD>
|
||||
- 娴佸紡杈撳嚭鏃跺垎绂?thinking 鍜?content
|
||||
- 从 `content` 中移除 think 标签
|
||||
- 流式输出时分离 thinking 和 content
|
||||
|
||||
- [ ] **2.2 附件上传服务**
|
||||
- 浣跨敤 `storage.upload()` 涓婁紶鍒?OSS
|
||||
- 璋冪敤 Python 寰<EFBFBD>湇鍔℃彁鍙栨枃鏈?
|
||||
- Token 璁℃暟锛堜娇鐢?tiktoken锛?
|
||||
- 鎴<EFBFBD>柇澶勭悊锛堣秴杩?30K tokens锛?
|
||||
- 瀛樺偍闄勪欢淇℃伅鍒?`messages.attachments`
|
||||
- 使用 `storage.upload()` 上传到 OSS
|
||||
- 调用 Python 微服务提取文本
|
||||
- Token 计数(使用 tiktoken)
|
||||
- 截断处理(超过 30K tokens)
|
||||
- 存储附件信息到 `messages.attachments`
|
||||
|
||||
- [ ] **2.3 闄勪欢娉ㄥ叆 LLM 涓婁笅鏂?*
|
||||
- 缁勮<EFBFBD>闄勪欢鏂囨湰鍒?User Prompt
|
||||
- 鎺у埗鎬?Token 闀垮害
|
||||
- [ ] **2.3 附件注入 LLM 上下文**
|
||||
- 组装附件文本到 User Prompt
|
||||
- 控制总 Token 长度
|
||||
|
||||
**鎶€鏈<EFBFBD><EFBFBD>鏍?*锛?
|
||||
**技术规格**:
|
||||
|
||||
```typescript
|
||||
// 附件处理配置
|
||||
const ATTACHMENT_CONFIG = {
|
||||
maxCount: 5, // 姣忔潯娑堟伅鏈€澶?涓<>檮浠?
|
||||
maxCount: 5, // 每条消息最多5个附件
|
||||
maxSizePerFile: 20 * 1024 * 1024, // 单个文件20MB
|
||||
maxTokens: 30000, // 鎻愬彇鏂囨湰鏈€澶?0K tokens
|
||||
maxTokens: 30000, // 提取文本最多30K tokens
|
||||
supportedTypes: ['pdf', 'docx', 'txt', 'xlsx'],
|
||||
};
|
||||
```
|
||||
|
||||
**楠屾敹鏍囧噯**锛?
|
||||
- [ ] 娣卞害鎬濊€冨唴瀹规<EFBFBD>纭<EFBFBD>垎绂诲瓨鍌?
|
||||
**验收标准**:
|
||||
- [ ] 深度思考内容正确分离存储
|
||||
- [ ] 附件上传成功
|
||||
- [ ] 附件文本正确注入 LLM
|
||||
|
||||
---
|
||||
|
||||
#### Day 3: 鎰忓浘璺<EFBFBD>敱 + 鐭ヨ瘑搴撻泦鎴?
|
||||
#### Day 3: 意图路由 + 知识库集成
|
||||
|
||||
**目标**:实现全局意图路由,完善知识库引用
|
||||
|
||||
**浠诲姟娓呭崟**锛?
|
||||
**任务清单**:
|
||||
|
||||
- [ ] **3.1 意图路由服务**
|
||||
- 新建 `intentRouterService.ts`
|
||||
@@ -163,27 +163,27 @@ const ATTACHMENT_CONFIG = {
|
||||
- 返回目标 Agent ID + 预填 Prompt
|
||||
- 添加 500ms 防抖(前端实现)
|
||||
|
||||
- [ ] **3.2 瀹屽杽鐭ヨ瘑搴撻泦鎴?*
|
||||
- 澶嶇敤 PKB 妯″潡鐨?RAG 妫€绱?
|
||||
- 鏅鸿兘寮曠敤绯荤粺锛圼鏉ユ簮N]锛?
|
||||
- 寮曠敤娓呭崟鏍煎紡鍖?
|
||||
- [ ] **3.2 完善知识库集成**
|
||||
- 复用 PKB 模块的 RAG 检索
|
||||
- 智能引用系统([来源N])
|
||||
- 引用清单格式化
|
||||
|
||||
- [ ] **3.3 API 端点完善**
|
||||
```
|
||||
POST /api/v1/aia/intent/route # 鎰忓浘璺<EFBFBD>敱
|
||||
POST /api/v1/aia/conversations # 鍒涘缓瀵硅瘽
|
||||
GET /api/v1/aia/conversations # 瀵硅瘽鍒楄〃
|
||||
GET /api/v1/aia/conversations/:id # 瀵硅瘽璇︽儏
|
||||
POST /api/v1/aia/conversations/:id/messages/stream # 鍙戦€佹秷鎭<EFBFBD>紙娴佸紡锛?
|
||||
POST /api/v1/aia/conversations/:id/attachments # 涓婁紶闄勪欢
|
||||
GET /api/v1/aia/agents # 鏅鸿兘浣撳垪琛?
|
||||
GET /api/v1/aia/agents/:id # 鏅鸿兘浣撹<EFBFBD>鎯?
|
||||
POST /api/v2/aia/intent/route # 意图路由
|
||||
POST /api/v2/aia/conversations # 创建对话
|
||||
GET /api/v2/aia/conversations # 对话列表
|
||||
GET /api/v2/aia/conversations/:id # 对话详情
|
||||
POST /api/v2/aia/conversations/:id/messages/stream # 发送消息(流式)
|
||||
POST /api/v2/aia/conversations/:id/attachments # 上传附件
|
||||
GET /api/v2/aia/agents # 智能体列表
|
||||
GET /api/v2/aia/agents/:id # 智能体详情
|
||||
```
|
||||
|
||||
**楠屾敹鏍囧噯**锛?
|
||||
- [ ] 鎰忓浘璺<EFBFBD>敱姝g‘璇嗗埆骞惰烦杞?
|
||||
- [ ] 鐭ヨ瘑搴撳紩鐢ㄦ<EFBFBD>纭<EFBFBD>樉绀?
|
||||
- [ ] 鎵€鏈?API 绔<>偣鍙<E581A3>敤
|
||||
**验收标准**:
|
||||
- [ ] 意图路由正确识别并跳转
|
||||
- [ ] 知识库引用正确显示
|
||||
- [ ] 所有 API 端点可用
|
||||
|
||||
---
|
||||
|
||||
@@ -191,23 +191,23 @@ const ATTACHMENT_CONFIG = {
|
||||
|
||||
**目标**:完成后端测试和文档
|
||||
|
||||
**浠诲姟娓呭崟**锛?
|
||||
**任务清单**:
|
||||
|
||||
- [ ] **4.1 单元测试**
|
||||
- conversationService 测试
|
||||
- 娣卞害鎬濊€冭В鏋愭祴璇?
|
||||
- 深度思考解析测试
|
||||
- 附件处理测试
|
||||
|
||||
- [ ] **4.2 集成测试**
|
||||
- 完整对话流程
|
||||
- 附件上传流程
|
||||
- 鐭ヨ瘑搴撴<EFBFBD>绱㈡祦绋?
|
||||
- 知识库检索流程
|
||||
|
||||
- [ ] **4.3 API 文档**
|
||||
- 更新 REST Client 测试文件
|
||||
- 编写 API 使用示例
|
||||
|
||||
**楠屾敹鏍囧噯**锛?
|
||||
**验收标准**:
|
||||
- [ ] 测试覆盖核心功能
|
||||
- [ ] API 文档完整
|
||||
|
||||
@@ -215,66 +215,66 @@ const ATTACHMENT_CONFIG = {
|
||||
|
||||
### Phase 2: 前端开发(5-7天)
|
||||
|
||||
#### Day 5-6: 鏅鸿兘浣撳ぇ鍘咃紙Dashboard锛?
|
||||
#### Day 5-6: 智能体大厅(Dashboard)
|
||||
|
||||
**目标**:实现首页智能体大厅
|
||||
|
||||
**浠诲姟娓呭崟**锛?
|
||||
**任务清单**:
|
||||
|
||||
- [ ] **5.1 创建模块目录结构**
|
||||
```
|
||||
frontend-v2/src/modules/aia/
|
||||
├── pages/
|
||||
鈹? 鈹溾攢鈹€ Dashboard.tsx # 鏅鸿兘浣撳ぇ鍘?
|
||||
鈹? 鈹斺攢鈹€ Workspace.tsx # 瀵硅瘽宸ヤ綔鍙?
|
||||
│ ├── Dashboard.tsx # 智能体大厅
|
||||
│ └── Workspace.tsx # 对话工作台
|
||||
├── components/
|
||||
鈹? 鈹溾攢鈹€ AgentPipeline.tsx # 5闃舵<EFBFBD>娴佹按绾?
|
||||
鈹? 鈹溾攢鈹€ AgentCard.tsx # 鏅鸿兘浣撳崱鐗?
|
||||
鈹? 鈹溾攢鈹€ IntentSearch.tsx # 鎰忓浘鎼滅储妗?
|
||||
鈹? 鈹溾攢鈹€ ConversationList.tsx # 鍘嗗彶浼氳瘽鍒楄〃
|
||||
鈹? 鈹溾攢鈹€ ThinkingBlock.tsx # 娣卞害鎬濊€冩姌鍙犲潡
|
||||
鈹? 鈹溾攢鈹€ AttachmentUpload.tsx # 闄勪欢涓婁紶
|
||||
鈹? 鈹溾攢鈹€ AttachmentCard.tsx # 闄勪欢鍗$墖
|
||||
鈹? 鈹斺攢鈹€ SlashCommands.tsx # 蹇<EFBFBD>嵎鎸囦护
|
||||
│ ├── AgentPipeline.tsx # 5阶段流水线
|
||||
│ ├── AgentCard.tsx # 智能体卡片
|
||||
│ ├── IntentSearch.tsx # 意图搜索框
|
||||
│ ├── ConversationList.tsx # 历史会话列表
|
||||
│ ├── ThinkingBlock.tsx # 深度思考折叠块
|
||||
│ ├── AttachmentUpload.tsx # 附件上传
|
||||
│ ├── AttachmentCard.tsx # 附件卡片
|
||||
│ └── SlashCommands.tsx # 快捷指令
|
||||
├── hooks/
|
||||
鈹? 鈹溾攢鈹€ useConversation.ts
|
||||
鈹? 鈹溾攢鈹€ useAgents.ts
|
||||
鈹? 鈹斺攢鈹€ useIntentRouter.ts
|
||||
│ ├── useConversation.ts
|
||||
│ ├── useAgents.ts
|
||||
│ └── useIntentRouter.ts
|
||||
├── api/
|
||||
鈹? 鈹斺攢鈹€ index.ts
|
||||
│ └── index.ts
|
||||
├── types/
|
||||
鈹? 鈹斺攢鈹€ index.ts
|
||||
│ └── index.ts
|
||||
└── index.tsx
|
||||
```
|
||||
|
||||
- [ ] **5.2 鏅鸿兘浣撴祦姘寸嚎锛圓gentPipeline锛?*
|
||||
- 5闃舵<EFBFBD>甯冨眬锛堜弗鏍艰繕鍘?V11 鍘熷瀷锛?
|
||||
- 3鑹茶<EFBFBD>瑙変綋绯?
|
||||
- [ ] **5.2 智能体流水线(AgentPipeline)**
|
||||
- 5阶段布局(严格还原 V11 原型)
|
||||
- 3色视觉体系
|
||||
- 卡片点击跳转 Workspace
|
||||
- 宸ュ叿鍗$墖璺宠浆澶栭儴妯″潡锛圖C/ST锛?
|
||||
- 工具卡片跳转外部模块(DC/ST)
|
||||
|
||||
- [ ] **5.3 鎰忓浘鎼滅储妗嗭紙IntentSearch锛?*
|
||||
- [ ] **5.3 意图搜索框(IntentSearch)**
|
||||
- 顶部大搜索框
|
||||
- 500ms 防抖
|
||||
- 调用意图路由 API
|
||||
- 自动跳转目标 Agent
|
||||
|
||||
**楠屾敹鏍囧噯**锛?
|
||||
- [ ] 5闃舵<EFBFBD>娴佹按绾挎<EFBFBD>纭<EFBFBD>睍绀?
|
||||
**验收标准**:
|
||||
- [ ] 5阶段流水线正确展示
|
||||
- [ ] 意图搜索功能可用
|
||||
- [ ] 涓庡師鍨嬪浘涓€鑷?
|
||||
- [ ] 与原型图一致
|
||||
|
||||
---
|
||||
|
||||
#### Day 7-8: 瀵硅瘽宸ヤ綔鍙帮紙Workspace锛?
|
||||
#### Day 7-8: 对话工作台(Workspace)
|
||||
|
||||
**目标**:实现沉浸式对话界面
|
||||
|
||||
**浠诲姟娓呭崟**锛?
|
||||
**任务清单**:
|
||||
|
||||
- [ ] **7.1 工作台布局**
|
||||
- Gemini 风格(大留白、少分割线)
|
||||
- 宸︿晶渚ц竟鏍忥紙鍘嗗彶浼氳瘽锛屽彲鎶樺彔锛?
|
||||
- 左侧侧边栏(历史会话,可折叠)
|
||||
- 主对话区(Header + 消息列表 + 输入框)
|
||||
|
||||
- [ ] **7.2 复用 Chat 通用组件**
|
||||
@@ -283,17 +283,17 @@ const ATTACHMENT_CONFIG = {
|
||||
|
||||
<ChatContainer
|
||||
providerConfig={{
|
||||
apiEndpoint: '/api/v1/aia/conversations/:id/messages/stream',
|
||||
apiEndpoint: '/api/v2/aia/conversations/:id/messages/stream',
|
||||
requestFn: sendMessageWithStream,
|
||||
}}
|
||||
customMessageRenderer={renderAIAMessage}
|
||||
/>
|
||||
```
|
||||
|
||||
- [ ] **7.3 娣卞害鎬濊€冩姌鍙犲潡锛圱hinkingBlock锛?*
|
||||
- [ ] **7.3 深度思考折叠块(ThinkingBlock)**
|
||||
- 可折叠灰色引用块
|
||||
- 生成中展开,完成后自动收起
|
||||
- 鏄剧ず"宸叉繁搴︽€濊€?(鑰楁椂 Xs)"
|
||||
- 显示"已深度思考 (耗时 Xs)"
|
||||
|
||||
- [ ] **7.4 附件上传组件**
|
||||
- 支持拖拽上传
|
||||
@@ -302,13 +302,13 @@ const ATTACHMENT_CONFIG = {
|
||||
- 消息气泡下方附件卡片
|
||||
|
||||
- [ ] **7.5 历史会话列表**
|
||||
- 鎸夋椂闂村垎缁勶紙浠婂ぉ銆佹槰澶┿€?澶╁墠锛?
|
||||
- 妗岄潰绔<EFBFBD>浐瀹氭樉绀?
|
||||
- 绉诲姩绔<EFBFBD>娊灞夋粦鍑?
|
||||
- 按时间分组(今天、昨天、7天前)
|
||||
- 桌面端固定显示
|
||||
- 移动端抽屉滑出
|
||||
|
||||
**楠屾敹鏍囧噯**锛?
|
||||
**验收标准**:
|
||||
- [ ] Gemini 风格 UI
|
||||
- [ ] 娣卞害鎬濊€冩<EFBFBD>纭<EFBFBD>睍绀?
|
||||
- [ ] 深度思考正确展示
|
||||
- [ ] 附件上传完整流程
|
||||
- [ ] 历史会话切换
|
||||
|
||||
@@ -316,30 +316,30 @@ const ATTACHMENT_CONFIG = {
|
||||
|
||||
#### Day 9: Markdown 增强 + 快捷指令
|
||||
|
||||
**鐩<EFBFBD>爣**锛氬<E9949B>寮哄<E5AFAE>璇濅綋楠?
|
||||
**目标**:增强对话体验
|
||||
|
||||
**浠诲姟娓呭崟**锛?
|
||||
**任务清单**:
|
||||
|
||||
- [ ] **9.1 Markdown 渲染增强**
|
||||
- KaTeX 公式渲染(医学公式)
|
||||
- 表格横向滚动
|
||||
- 浠g爜鍧楄<EFBFBD>娉曢珮浜?+ 涓€閿<E282AC><E996BF>鍒?
|
||||
- 代码块语法高亮 + 一键复制
|
||||
|
||||
- [ ] **9.2 蹇<EFBFBD>嵎鎸囦护锛圫lashCommands锛?*
|
||||
- [ ] **9.2 快捷指令(SlashCommands)**
|
||||
- 输入 `/` 弹出菜单
|
||||
- 鏀<EFBFBD>寔锛?娑﹁壊, /鎵╁啓, /缈昏瘧, /瀵煎嚭Word
|
||||
- 支持:/润色, /扩写, /翻译, /导出Word
|
||||
- 键盘导航
|
||||
|
||||
- [ ] **9.3 缁撴灉鎿嶄綔鏍?*
|
||||
- Hover 鏄剧ず宸ュ叿鏍?
|
||||
- 澶嶅埗锛圡arkdown 婧愮爜锛?
|
||||
- [ ] **9.3 结果操作栏**
|
||||
- Hover 显示工具栏
|
||||
- 复制(Markdown 源码)
|
||||
- 重新生成
|
||||
- 瀵煎嚭 Word锛堣皟鐢?RVW 瀵煎嚭鏈嶅姟锛?
|
||||
- 导出 Word(调用 RVW 导出服务)
|
||||
|
||||
**楠屾敹鏍囧噯**锛?
|
||||
**验收标准**:
|
||||
- [ ] 公式正确渲染
|
||||
- [ ] 快捷指令可用
|
||||
- [ ] 鎿嶄綔鏍忓姛鑳藉畬鏁?
|
||||
- [ ] 操作栏功能完整
|
||||
|
||||
---
|
||||
|
||||
@@ -347,25 +347,25 @@ const ATTACHMENT_CONFIG = {
|
||||
|
||||
**目标**:响应式布局适配
|
||||
|
||||
**浠诲姟娓呭崟**锛?
|
||||
**任务清单**:
|
||||
|
||||
- [ ] **10.1 Dashboard 绉诲姩绔?*
|
||||
- [ ] **10.1 Dashboard 移动端**
|
||||
- 隐藏复杂导航
|
||||
- 卡片单列流式布局
|
||||
- 鏃堕棿杞存牱寮忚皟鏁?
|
||||
- 时间轴样式调整
|
||||
|
||||
- [ ] **10.2 Workspace 绉诲姩绔?*
|
||||
- 渚ц竟鏍忔敼涓烘娊灞?
|
||||
- 杈撳叆妗嗛敭鐩橀€傞厤锛坰crollIntoView锛?
|
||||
- 鍙戦€佹寜閽<EFBFBD><EFBFBD>缁堝彲瑙?
|
||||
- [ ] **10.2 Workspace 移动端**
|
||||
- 侧边栏改为抽屉
|
||||
- 输入框键盘适配(scrollIntoView)
|
||||
- 发送按钮始终可见
|
||||
|
||||
- [ ] **10.3 触控优化**
|
||||
- 鎸夐挳 active 鎬?
|
||||
- 按钮 active 态
|
||||
- 触控区域优化
|
||||
|
||||
**楠屾敹鏍囧噯**锛?
|
||||
**验收标准**:
|
||||
- [ ] md (768px) 断点响应正确
|
||||
- [ ] 绉诲姩绔<EFBFBD>氦浜掓祦鐣?
|
||||
- [ ] 移动端交互流畅
|
||||
|
||||
---
|
||||
|
||||
@@ -373,27 +373,27 @@ const ATTACHMENT_CONFIG = {
|
||||
|
||||
**目标**:完成整体测试和优化
|
||||
|
||||
**浠诲姟娓呭崟**锛?
|
||||
**任务清单**:
|
||||
|
||||
- [ ] **11.1 绔<EFBFBD>埌绔<EFBFBD>祴璇?*
|
||||
- [ ] **11.1 端到端测试**
|
||||
- 完整对话流程
|
||||
- 附件上传流程
|
||||
- 娣卞害鎬濊€冩祦绋?
|
||||
- 鐭ヨ瘑搴撳紩鐢ㄦ祦绋?
|
||||
- 深度思考流程
|
||||
- 知识库引用流程
|
||||
|
||||
- [ ] **11.2 性能优化**
|
||||
- TTFB < 1.5s
|
||||
- 绉诲姩绔?LCP < 1s
|
||||
- 移动端 LCP < 1s
|
||||
- 意图搜索防抖
|
||||
|
||||
- [ ] **11.3 Bug 修复**
|
||||
|
||||
- [ ] **11.4 文档更新**
|
||||
- 鏇存柊妯″潡鐘舵€佹枃妗?
|
||||
- 鏇存柊绯荤粺褰撳墠鐘舵€?
|
||||
- 更新模块状态文档
|
||||
- 更新系统当前状态
|
||||
|
||||
**楠屾敹鏍囧噯**锛?
|
||||
- [ ] 鎵€鏈夊姛鑳芥<EFBFBD>甯?
|
||||
**验收标准**:
|
||||
- [ ] 所有功能正常
|
||||
- [ ] 性能达标
|
||||
- [ ] 文档完整
|
||||
|
||||
@@ -406,22 +406,22 @@ const ATTACHMENT_CONFIG = {
|
||||
```
|
||||
backend/src/modules/aia/
|
||||
├── controllers/
|
||||
鈹? 鈹溾攢鈹€ conversationController.ts # ~300琛?
|
||||
鈹? 鈹溾攢鈹€ agentController.ts # ~150琛?
|
||||
鈹? 鈹斺攢鈹€ projectController.ts # ~200琛?
|
||||
│ ├── conversationController.ts # ~300行
|
||||
│ ├── agentController.ts # ~150行
|
||||
│ └── projectController.ts # ~200行
|
||||
├── services/
|
||||
鈹? 鈹溾攢鈹€ conversationService.ts # ~500琛岋紙鏍稿績锛?
|
||||
鈹? 鈹溾攢鈹€ agentService.ts # ~200琛?
|
||||
鈹? 鈹溾攢鈹€ projectService.ts # ~150琛?
|
||||
鈹? 鈹溾攢鈹€ intentRouterService.ts # ~100琛岋紙鏂帮級
|
||||
鈹? 鈹斺攢鈹€ attachmentService.ts # ~200琛岋紙鏂帮級
|
||||
│ ├── conversationService.ts # ~500行(核心)
|
||||
│ ├── agentService.ts # ~200行
|
||||
│ ├── projectService.ts # ~150行
|
||||
│ ├── intentRouterService.ts # ~100行(新)
|
||||
│ └── attachmentService.ts # ~200行(新)
|
||||
├── routes/
|
||||
鈹? 鈹斺攢鈹€ index.ts # ~100琛?
|
||||
│ └── index.ts # ~100行
|
||||
├── types/
|
||||
鈹? 鈹斺攢鈹€ index.ts # ~100琛?
|
||||
鈹斺攢鈹€ index.ts # ~20琛?
|
||||
│ └── index.ts # ~100行
|
||||
└── index.ts # ~20行
|
||||
|
||||
棰勮<EFBFBD>鎬昏<EFBFBD>锛殈2000琛?
|
||||
预计总计:~2000行
|
||||
```
|
||||
|
||||
### 前端新增文件
|
||||
@@ -429,28 +429,28 @@ backend/src/modules/aia/
|
||||
```
|
||||
frontend-v2/src/modules/aia/
|
||||
├── pages/
|
||||
鈹? 鈹溾攢鈹€ Dashboard.tsx # ~400琛?
|
||||
鈹? 鈹斺攢鈹€ Workspace.tsx # ~500琛?
|
||||
│ ├── Dashboard.tsx # ~400行
|
||||
│ └── Workspace.tsx # ~500行
|
||||
├── components/
|
||||
鈹? 鈹溾攢鈹€ AgentPipeline.tsx # ~300琛?
|
||||
鈹? 鈹溾攢鈹€ AgentCard.tsx # ~100琛?
|
||||
鈹? 鈹溾攢鈹€ IntentSearch.tsx # ~150琛?
|
||||
鈹? 鈹溾攢鈹€ ConversationList.tsx # ~200琛?
|
||||
鈹? 鈹溾攢鈹€ ThinkingBlock.tsx # ~100琛?
|
||||
鈹? 鈹溾攢鈹€ AttachmentUpload.tsx # ~200琛?
|
||||
鈹? 鈹溾攢鈹€ AttachmentCard.tsx # ~80琛?
|
||||
鈹? 鈹斺攢鈹€ SlashCommands.tsx # ~150琛?
|
||||
│ ├── AgentPipeline.tsx # ~300行
|
||||
│ ├── AgentCard.tsx # ~100行
|
||||
│ ├── IntentSearch.tsx # ~150行
|
||||
│ ├── ConversationList.tsx # ~200行
|
||||
│ ├── ThinkingBlock.tsx # ~100行
|
||||
│ ├── AttachmentUpload.tsx # ~200行
|
||||
│ ├── AttachmentCard.tsx # ~80行
|
||||
│ └── SlashCommands.tsx # ~150行
|
||||
├── hooks/
|
||||
鈹? 鈹溾攢鈹€ useConversation.ts # ~150琛?
|
||||
鈹? 鈹溾攢鈹€ useAgents.ts # ~100琛?
|
||||
鈹? 鈹斺攢鈹€ useIntentRouter.ts # ~80琛?
|
||||
│ ├── useConversation.ts # ~150行
|
||||
│ ├── useAgents.ts # ~100行
|
||||
│ └── useIntentRouter.ts # ~80行
|
||||
├── api/
|
||||
鈹? 鈹斺攢鈹€ index.ts # ~200琛?
|
||||
│ └── index.ts # ~200行
|
||||
├── types/
|
||||
鈹? 鈹斺攢鈹€ index.ts # ~100琛?
|
||||
鈹斺攢鈹€ index.tsx # ~50琛?
|
||||
│ └── index.ts # ~100行
|
||||
└── index.tsx # ~50行
|
||||
|
||||
棰勮<EFBFBD>鎬昏<EFBFBD>锛殈2900琛?
|
||||
预计总计:~2900行
|
||||
```
|
||||
|
||||
---
|
||||
@@ -466,8 +466,8 @@ frontend-v2/src/modules/aia/
|
||||
| `cache` | `@/common/cache` | Redis/PG缓存 |
|
||||
| `jobQueue` | `@/common/jobs` | 异步任务 |
|
||||
| `promptService` | `@/common/prompts` | Prompt管理 |
|
||||
| `LLMFactory` | `@/common/llm` | LLM閫傞厤鍣?|
|
||||
| `prisma` | `@/config/database` | 鏁版嵁搴?|
|
||||
| `LLMFactory` | `@/common/llm` | LLM适配器 |
|
||||
| `prisma` | `@/config/database` | 数据库 |
|
||||
| `ExtractionClient` | `@/clients` | 文档提取 |
|
||||
| `TokenService` | `@/services` | Token计数 |
|
||||
|
||||
@@ -476,7 +476,7 @@ frontend-v2/src/modules/aia/
|
||||
| 依赖 | 来源 | 说明 |
|
||||
|------|------|------|
|
||||
| `ChatContainer` | `@/shared/components/Chat` | 通用对话组件 |
|
||||
| `Ant Design` | `antd` | UI缁勪欢搴?|
|
||||
| `Ant Design` | `antd` | UI组件库 |
|
||||
| `Ant Design X` | `@ant-design/x` | AI对话组件 |
|
||||
| `KaTeX` | `katex` | 公式渲染 |
|
||||
| `react-markdown` | `react-markdown` | Markdown渲染 |
|
||||
@@ -487,37 +487,37 @@ frontend-v2/src/modules/aia/
|
||||
|
||||
| 风险 | 概率 | 影响 | 缓解措施 |
|
||||
|------|------|------|---------|
|
||||
| 娴佸紡杈撳嚭鍏煎<EFBFBD>鎬?| 涓?| 楂?| 澶嶇敤宸查獙璇佺殑 SSE 浠g爜 |
|
||||
| 闄勪欢鎻愬彇瓒呮椂 | 涓?| 涓?| 浣跨敤 jobQueue 寮傛<EFBFBD>澶勭悊 |
|
||||
| 绉诲姩绔<EFBFBD>€傞厤闂<EFBFBD><EFBFBD> | 浣?| 涓?| 鎻愬墠瑙勫垝鏂<E59E9D>偣鍜屽竷灞€ |
|
||||
| Prompt绠$悊鏈嶅姟鏈<EFBFBD>氨缁?| 浣?| 涓?| 鍙<>复鏃跺洖閫€鍒版枃浠惰<E6B5A0>鍙?|
|
||||
| 流式输出兼容性 | 中 | 高 | 复用已验证的 SSE 代码 |
|
||||
| 附件提取超时 | 中 | 中 | 使用 jobQueue 异步处理 |
|
||||
| 移动端适配问题 | 低 | 中 | 提前规划断点和布局 |
|
||||
| Prompt管理服务未就绪 | 低 | 中 | 可临时回退到文件读取 |
|
||||
|
||||
---
|
||||
|
||||
## 鉁?楠屾敹鏍囧噯
|
||||
## ✅ 验收标准
|
||||
|
||||
### 功能验收
|
||||
|
||||
- [ ] 鏅鸿兘浣撳ぇ鍘呭畬鏁村睍绀?
|
||||
- [ ] 智能体大厅完整展示
|
||||
- [ ] 意图搜索正确路由
|
||||
- [ ] 多轮对话正常
|
||||
- [ ] 流式输出流畅
|
||||
- [ ] 娣卞害鎬濊€冩<EFBFBD>纭<EFBFBD>姌鍙?
|
||||
- [ ] 深度思考正确折叠
|
||||
- [ ] 附件上传完整
|
||||
- [ ] 鐭ヨ瘑搴撳紩鐢ㄦ<EFBFBD>纭?
|
||||
- [ ] 知识库引用正确
|
||||
- [ ] 快捷指令可用
|
||||
- [ ] 移动端适配正常
|
||||
|
||||
### 性能验收
|
||||
|
||||
- [ ] TTFB < 1.5s
|
||||
- [ ] 绉诲姩绔?LCP < 1s
|
||||
- [ ] 移动端 LCP < 1s
|
||||
- [ ] 意图搜索响应 < 500ms
|
||||
|
||||
### 质量验收
|
||||
|
||||
- [ ] 鏃?console.log锛堜娇鐢?logger锛?
|
||||
- [ ] 浠g爜绗﹀悎浜戝師鐢熻<EFBFBD>鑼?
|
||||
- [ ] 无 console.log(使用 logger)
|
||||
- [ ] 代码符合云原生规范
|
||||
- [ ] API 文档完整
|
||||
- [ ] 单元测试覆盖核心功能
|
||||
|
||||
@@ -527,14 +527,13 @@ frontend-v2/src/modules/aia/
|
||||
|
||||
| 日期 | 版本 | 内容 |
|
||||
|------|------|------|
|
||||
| 2026-01-11 | V1.0 | 鍒涘缓寮€鍙戣<EFBFBD>鍒?|
|
||||
| 2026-01-11 | V1.0 | 创建开发计划 |
|
||||
|
||||
---
|
||||
|
||||
**璁″垝鍒跺畾浜?*锛欰I Assistant
|
||||
**瀹℃牳浜?*锛氬緟瀹?
|
||||
**鎵瑰噯浜?*锛氬緟瀹?
|
||||
|
||||
**计划制定人**:AI Assistant
|
||||
**审核人**:待定
|
||||
**批准人**:待定
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# AIA V2.1 后端 API 设计
|
||||
|
||||
> **版本**:V2.1
|
||||
> **<EFBFBD>𥕦遣<EFBFBD>交<EFBFBD>**嚗?026-01-11
|
||||
> **<EFBFBD>箇<EFBFBD>頝臬<EFBFBD>**嚗䫤/api/v1/aia`
|
||||
> **创建日期**:2026-01-11
|
||||
> **基础路径**:`/api/v2/aia`
|
||||
|
||||
---
|
||||
|
||||
@@ -10,23 +10,23 @@
|
||||
|
||||
| 方法 | 路径 | 描述 | 认证 |
|
||||
|------|------|------|------|
|
||||
| GET | `/agents` | <EFBFBD>瑕<EFBFBD><EFBFBD>箄<EFBFBD>雿枏<EFBFBD>銵?| <20>?|
|
||||
| GET | `/agents/:id` | <EFBFBD>瑕<EFBFBD><EFBFBD>箄<EFBFBD>雿栞祕<EFBFBD>?| <20>?|
|
||||
| POST | `/intent/route` | <EFBFBD>誩㦛頝舐眏 | <EFBFBD>?|
|
||||
| GET | `/conversations` | <EFBFBD>瑕<EFBFBD>撖寡<EFBFBD><EFBFBD>𡑒” | <EFBFBD>?|
|
||||
| POST | `/conversations` | <EFBFBD>𥕦遣撖寡<EFBFBD> | <EFBFBD>?|
|
||||
| GET | `/conversations/:id` | <EFBFBD>瑕<EFBFBD>撖寡<EFBFBD>霂行<EFBFBD> | <EFBFBD>?|
|
||||
| DELETE | `/conversations/:id` | <EFBFBD>𣳇膄撖寡<EFBFBD> | <EFBFBD>?|
|
||||
| POST | `/conversations/:id/messages/stream` | <EFBFBD>煾<EFBFBD><EFBFBD><EFBFBD><EFBFBD>荔<EFBFBD>瘚<EFBFBD><EFBFBD>嚗?| <20>?|
|
||||
| POST | `/conversations/:id/attachments` | 銝𠹺<EFBFBD><EFBFBD><EFBFBD>辣 | <EFBFBD>?|
|
||||
| GET | `/projects` | <EFBFBD>瑕<EFBFBD>憿寧𤌍<EFBFBD>𡑒” | <EFBFBD>?|
|
||||
| GET | `/projects/:id` | <EFBFBD>瑕<EFBFBD>憿寧𤌍霂行<EFBFBD> | <EFBFBD>?|
|
||||
| GET | `/agents` | 获取智能体列表 | ✅ |
|
||||
| GET | `/agents/:id` | 获取智能体详情 | ✅ |
|
||||
| POST | `/intent/route` | 意图路由 | ✅ |
|
||||
| GET | `/conversations` | 获取对话列表 | ✅ |
|
||||
| POST | `/conversations` | 创建对话 | ✅ |
|
||||
| GET | `/conversations/:id` | 获取对话详情 | ✅ |
|
||||
| DELETE | `/conversations/:id` | 删除对话 | ✅ |
|
||||
| POST | `/conversations/:id/messages/stream` | 发送消息(流式) | ✅ |
|
||||
| POST | `/conversations/:id/attachments` | 上传附件 | ✅ |
|
||||
| GET | `/projects` | 获取项目列表 | ✅ |
|
||||
| GET | `/projects/:id` | 获取项目详情 | ✅ |
|
||||
|
||||
---
|
||||
|
||||
## 🔐 认证
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD>?API <20><>閬<EFBFBD>銁霂瑟<E99C82>憭港葉<E6B8AF>箏蒂 JWT Token嚗?
|
||||
所有 API 需要在请求头中携带 JWT Token:
|
||||
|
||||
```
|
||||
Authorization: Bearer <token>
|
||||
@@ -36,21 +36,21 @@ Authorization: Bearer <token>
|
||||
|
||||
## 📖 API 详细定义
|
||||
|
||||
### 1. <EFBFBD>箄<EFBFBD>雿梶㮾<EFBFBD>?
|
||||
### 1. 智能体相关
|
||||
|
||||
#### 1.1 <EFBFBD>瑕<EFBFBD><EFBFBD>箄<EFBFBD>雿枏<EFBFBD>銵?
|
||||
#### 1.1 获取智能体列表
|
||||
|
||||
```http
|
||||
GET /api/v1/aia/agents
|
||||
GET /api/v2/aia/agents
|
||||
```
|
||||
|
||||
**<EFBFBD>亥砭<EFBFBD><EFBFBD>㺭**嚗?
|
||||
**查询参数**:
|
||||
|
||||
| 参数 | 类型 | 必填 | 描述 |
|
||||
|------|------|------|------|
|
||||
| stage | string | <EFBFBD>?| 蝑偦<E89D91>厰𧫴畾蛛<E795BE>`design`, `data`, `analysis`, `write`, `publish` |
|
||||
| stage | string | 否 | 筛选阶段:`design`, `data`, `analysis`, `write`, `publish` |
|
||||
|
||||
**<EFBFBD>滚<EFBFBD>**嚗?
|
||||
**响应**:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -59,7 +59,7 @@ GET /api/v1/aia/agents
|
||||
"agents": [
|
||||
{
|
||||
"id": "research-design",
|
||||
"name": "蝘𤑳<EFBFBD>霈曇恣撠誩𨭌<EFBFBD>?,
|
||||
"name": "科研设计小助手",
|
||||
"description": "帮助您完成研究方案设计、文献检索、方法学指导",
|
||||
"icon": "🔬",
|
||||
"stage": "design",
|
||||
@@ -70,7 +70,7 @@ GET /api/v1/aia/agents
|
||||
{
|
||||
"id": "dc-tool",
|
||||
"name": "数据采集工具",
|
||||
"description": "頝唾蓮<EFBFBD>唳㺭<EFBFBD>桅<EFBFBD><EFBFBD><EFBFBD>芋<EFBFBD>?,
|
||||
"description": "跳转到数据采集模块",
|
||||
"icon": "📊",
|
||||
"stage": "data",
|
||||
"color": "#8B5CF6",
|
||||
@@ -82,20 +82,20 @@ GET /api/v1/aia/agents
|
||||
}
|
||||
```
|
||||
|
||||
#### 1.2 <EFBFBD>瑕<EFBFBD><EFBFBD>箄<EFBFBD>雿栞祕<EFBFBD>?
|
||||
#### 1.2 获取智能体详情
|
||||
|
||||
```http
|
||||
GET /api/v1/aia/agents/:id
|
||||
GET /api/v2/aia/agents/:id
|
||||
```
|
||||
|
||||
**<EFBFBD>滚<EFBFBD>**嚗?
|
||||
**响应**:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"data": {
|
||||
"id": "research-design",
|
||||
"name": "蝘𤑳<EFBFBD>霈曇恣撠誩𨭌<EFBFBD>?,
|
||||
"name": "科研设计小助手",
|
||||
"description": "帮助您完成研究方案设计、文献检索、方法学指导",
|
||||
"icon": "🔬",
|
||||
"stage": "design",
|
||||
@@ -104,7 +104,7 @@ GET /api/v1/aia/agents/:id
|
||||
"systemPrompt": "你是一个专业的医学科研设计专家...",
|
||||
"welcomeMessage": "您好!我是科研设计小助手,我可以帮您:\n- 设计研究方案\n- 检索相关文献\n- 指导研究方法",
|
||||
"suggestedQuestions": [
|
||||
"憒<EFBFBD><EFBFBD>霈曇恣銝<EFBFBD>銝析CT<EFBFBD>𠉛弦嚗?,
|
||||
"如何设计一个RCT研究?",
|
||||
"帮我检索近5年糖尿病研究文献",
|
||||
"什么情况下使用倾向性评分匹配?"
|
||||
]
|
||||
@@ -119,27 +119,27 @@ GET /api/v1/aia/agents/:id
|
||||
#### 2.1 智能意图识别
|
||||
|
||||
```http
|
||||
POST /api/v1/aia/intent/route
|
||||
POST /api/v2/aia/intent/route
|
||||
```
|
||||
|
||||
**霂瑟<EFBFBD>雿?*嚗?
|
||||
**请求体**:
|
||||
|
||||
```json
|
||||
{
|
||||
"query": "撣格<EFBFBD><EFBFBD><EFBFBD><EFBFBD>銝<EFBFBD>銝贝<EFBFBD>隞賣㺭<EFBFBD>?
|
||||
"query": "帮我分析一下这份数据"
|
||||
}
|
||||
```
|
||||
|
||||
**<EFBFBD>滚<EFBFBD>**嚗?
|
||||
**响应**:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"data": {
|
||||
"agentId": "data-analysis",
|
||||
"agentName": "蝏蠘恣<EFBFBD><EFBFBD><EFBFBD>撠誩𨭌<EFBFBD>?,
|
||||
"agentName": "统计分析小助手",
|
||||
"confidence": 0.92,
|
||||
"prefillPrompt": "霂瑕葬<EFBFBD>穃<EFBFBD><EFBFBD>鞱<EFBFBD>隞賣㺭<EFBFBD>殷<EFBFBD><EFBFBD><EFBFBD>𡠺<EFBFBD>讛膩<EFBFBD>抒<EFBFBD>霈∪<EFBFBD><EFBFBD>詨<EFBFBD><EFBFBD>批<EFBFBD><EFBFBD>?
|
||||
"prefillPrompt": "请帮我分析这份数据,包括描述性统计和相关性分析"
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -151,19 +151,19 @@ POST /api/v1/aia/intent/route
|
||||
#### 3.1 获取对话列表
|
||||
|
||||
```http
|
||||
GET /api/v1/aia/conversations
|
||||
GET /api/v2/aia/conversations
|
||||
```
|
||||
|
||||
**<EFBFBD>亥砭<EFBFBD><EFBFBD>㺭**嚗?
|
||||
**查询参数**:
|
||||
|
||||
| 参数 | 类型 | 必填 | 描述 |
|
||||
|------|------|------|------|
|
||||
| agentId | string | <EFBFBD>?| <20>㗇惣<E39787>賭<EFBFBD>蝑偦<E89D91>?|
|
||||
| projectId | string | <EFBFBD>?| <20>厰★<E58EB0>桃<EFBFBD><E6A183>㚁<EFBFBD>NULL 銵函內<E587BD>𡁶鍂撖寡<E69296>嚗?|
|
||||
| page | number | <EFBFBD>?| 憿萇<E686BF>嚗屸<E59A97>霈?1 |
|
||||
| pageSize | number | <EFBFBD>?| 瘥誯△<E8AAAF>圈<EFBFBD>嚗屸<E59A97>霈?20 |
|
||||
| agentId | string | 否 | 按智能体筛选 |
|
||||
| projectId | string | 否 | 按项目筛选(NULL 表示通用对话) |
|
||||
| page | number | 否 | 页码,默认 1 |
|
||||
| pageSize | number | 否 | 每页数量,默认 20 |
|
||||
|
||||
**<EFBFBD>滚<EFBFBD>**嚗?
|
||||
**响应**:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -174,10 +174,10 @@ GET /api/v1/aia/conversations
|
||||
"id": "conv-001",
|
||||
"title": "RCT研究设计咨询",
|
||||
"agentId": "research-design",
|
||||
"agentName": "蝘𤑳<EFBFBD>霈曇恣撠誩𨭌<EFBFBD>?,
|
||||
"agentName": "科研设计小助手",
|
||||
"projectId": null,
|
||||
"messageCount": 12,
|
||||
"lastMessage": "憟賜<EFBFBD>嚗峕<EFBFBD><EFBFBD>亙葬<EFBFBD>刻挽霈∠<EFBFBD>蝛嗆䲮獢?..",
|
||||
"lastMessage": "好的,我来帮您设计研究方案...",
|
||||
"createdAt": "2026-01-11T10:00:00Z",
|
||||
"updatedAt": "2026-01-11T12:30:00Z"
|
||||
}
|
||||
@@ -195,27 +195,27 @@ GET /api/v1/aia/conversations
|
||||
#### 3.2 创建对话
|
||||
|
||||
```http
|
||||
POST /api/v1/aia/conversations
|
||||
POST /api/v2/aia/conversations
|
||||
```
|
||||
|
||||
**霂瑟<EFBFBD>雿?*嚗?
|
||||
**请求体**:
|
||||
|
||||
```json
|
||||
{
|
||||
"agentId": "research-design",
|
||||
"projectId": null,
|
||||
"title": "<EFBFBD>啣笆霂?
|
||||
"title": "新对话"
|
||||
}
|
||||
```
|
||||
|
||||
**<EFBFBD>滚<EFBFBD>**嚗?
|
||||
**响应**:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"data": {
|
||||
"id": "conv-002",
|
||||
"title": "<EFBFBD>啣笆霂?,
|
||||
"title": "新对话",
|
||||
"agentId": "research-design",
|
||||
"projectId": null,
|
||||
"createdAt": "2026-01-11T14:00:00Z"
|
||||
@@ -223,19 +223,19 @@ POST /api/v1/aia/conversations
|
||||
}
|
||||
```
|
||||
|
||||
#### 3.3 <EFBFBD>瑕<EFBFBD>撖寡<EFBFBD>霂行<EFBFBD>嚗<EFBFBD>鉄<EFBFBD><EFBFBD>蟮瘨<EFBFBD><EFBFBD>嚗?
|
||||
#### 3.3 获取对话详情(含历史消息)
|
||||
|
||||
```http
|
||||
GET /api/v1/aia/conversations/:id
|
||||
GET /api/v2/aia/conversations/:id
|
||||
```
|
||||
|
||||
**<EFBFBD>亥砭<EFBFBD><EFBFBD>㺭**嚗?
|
||||
**查询参数**:
|
||||
|
||||
| 参数 | 类型 | 必填 | 描述 |
|
||||
|------|------|------|------|
|
||||
| limit | number | <EFBFBD>?| <20>瑕<EFBFBD><E79195><EFBFBD>餈𤨩<E9A488>⊥<EFBFBD><E28AA5>荔<EFBFBD>暺䁅恕 50 |
|
||||
| limit | number | 否 | 获取最近N条消息,默认 50 |
|
||||
|
||||
**<EFBFBD>滚<EFBFBD>**嚗?
|
||||
**响应**:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -244,7 +244,7 @@ GET /api/v1/aia/conversations/:id
|
||||
"id": "conv-001",
|
||||
"title": "RCT研究设计咨询",
|
||||
"agentId": "research-design",
|
||||
"agentName": "蝘𤑳<EFBFBD>霈曇恣撠誩𨭌<EFBFBD>?,
|
||||
"agentName": "科研设计小助手",
|
||||
"projectId": null,
|
||||
"createdAt": "2026-01-11T10:00:00Z",
|
||||
"updatedAt": "2026-01-11T12:30:00Z",
|
||||
@@ -260,7 +260,7 @@ GET /api/v1/aia/conversations/:id
|
||||
"id": "msg-002",
|
||||
"role": "assistant",
|
||||
"content": "好的,我来帮您设计一个糖尿病RCT研究方案...",
|
||||
"thinkingContent": "<EFBFBD>冽<EFBFBD><EFBFBD>唾挽霈﹕CT<EFBFBD>𠉛弦嚗屸<EFBFBD>閬<EFBFBD><EFBFBD><EFBFBD><EFBFBD>嚗?嚗厩<EFBFBD>蝛嗥𤌍<EFBFBD>?2嚗匧<EFBFBD><EFBFBD>埝<EFBFBD><EFBFBD>?3嚗㗇甅<EFBFBD>祇<EFBFBD> 4嚗厰<EFBFBD><EFBFBD>箏<EFBFBD><EFBFBD>寞<EFBFBD> 5嚗厩𤩅瘜?6嚗厩<EFBFBD>撅<EFBFBD><EFBFBD><EFBFBD><EFBFBD>...",
|
||||
"thinkingContent": "用户想设计RCT研究,需要考虑:1)研究目的 2)入排标准 3)样本量 4)随机化方法 5)盲法 6)结局指标...",
|
||||
"model": "deepseek-v3",
|
||||
"tokens": 1250,
|
||||
"createdAt": "2026-01-11T10:00:30Z"
|
||||
@@ -273,10 +273,10 @@ GET /api/v1/aia/conversations/:id
|
||||
#### 3.4 删除对话
|
||||
|
||||
```http
|
||||
DELETE /api/v1/aia/conversations/:id
|
||||
DELETE /api/v2/aia/conversations/:id
|
||||
```
|
||||
|
||||
**<EFBFBD>滚<EFBFBD>**嚗?
|
||||
**响应**:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -289,22 +289,22 @@ DELETE /api/v1/aia/conversations/:id
|
||||
|
||||
---
|
||||
|
||||
### 4. 瘨<EFBFBD><EFBFBD><EFBFBD>煾<EFBFBD><EFBFBD><EFBFBD>瘚<EFBFBD><EFBFBD>嚗?
|
||||
### 4. 消息发送(流式)
|
||||
|
||||
#### 4.1 发送消息并获取流式响应
|
||||
|
||||
```http
|
||||
POST /api/v1/aia/conversations/:id/messages/stream
|
||||
POST /api/v2/aia/conversations/:id/messages/stream
|
||||
```
|
||||
|
||||
**霂瑟<EFBFBD>憭?*嚗?
|
||||
**请求头**:
|
||||
|
||||
```
|
||||
Content-Type: application/json
|
||||
Accept: text/event-stream
|
||||
```
|
||||
|
||||
**霂瑟<EFBFBD>雿?*嚗?
|
||||
**请求体**:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -314,17 +314,17 @@ Accept: text/event-stream
|
||||
}
|
||||
```
|
||||
|
||||
**<EFBFBD>滚<EFBFBD>嚗𠄎SE <20>澆<EFBFBD>嚗?*嚗?
|
||||
**响应(SSE 格式)**:
|
||||
|
||||
```
|
||||
event: thinking_start
|
||||
data: {}
|
||||
|
||||
event: thinking_delta
|
||||
data: {"content": "<EFBFBD>冽<EFBFBD>銝𠹺<EFBFBD>鈭<EFBFBD>㺭<EFBFBD>格<EFBFBD>隞塚<EFBFBD><EFBFBD><EFBFBD>閬?}
|
||||
data: {"content": "用户上传了数据文件,需要"}
|
||||
|
||||
event: thinking_delta
|
||||
data: {"content": "餈𥡝<EFBFBD><EFBFBD>讛膩<EFBFBD>抒<EFBFBD>霈∪<EFBFBD><EFBFBD>?.."}
|
||||
data: {"content": "进行描述性统计分析..."}
|
||||
|
||||
event: thinking_end
|
||||
data: {"duration": 3200}
|
||||
@@ -333,7 +333,7 @@ event: message_start
|
||||
data: {"id": "msg-003"}
|
||||
|
||||
event: delta
|
||||
data: {"content": "<EFBFBD>寞旿<EFBFBD>其<EFBFBD>隡删<EFBFBD><EFBFBD>唳旿嚗?}
|
||||
data: {"content": "根据您上传的数据,"}
|
||||
|
||||
event: delta
|
||||
data: {"content": "我来为您进行分析..."}
|
||||
@@ -345,18 +345,18 @@ event: done
|
||||
data: {}
|
||||
```
|
||||
|
||||
**SSE 鈭衤辣蝐餃<EFBFBD>**嚗?
|
||||
**SSE 事件类型**:
|
||||
|
||||
| 事件 | 描述 | 数据格式 |
|
||||
|------|------|---------|
|
||||
| `thinking_start` | 撘<EFBFBD>憪𧢲楛摨行<EFBFBD>肽<EFBFBD>?| `{}` |
|
||||
| `thinking_delta` | <EFBFBD>肽<EFBFBD><EFBFBD><EFBFBD>摰寧<EFBFBD>畾?| `{"content": "..."}` |
|
||||
| `thinking_end` | <EFBFBD>肽<EFBFBD><EFBFBD><EFBFBD><EFBFBD>?| `{"duration": number}` |
|
||||
| `message_start` | 撘<EFBFBD>憪讠<EFBFBD><EFBFBD>𣂼<EFBFBD>憭?| `{"id": "..."}` |
|
||||
| `thinking_start` | 开始深度思考 | `{}` |
|
||||
| `thinking_delta` | 思考内容片段 | `{"content": "..."}` |
|
||||
| `thinking_end` | 思考结束 | `{"duration": number}` |
|
||||
| `message_start` | 开始生成回复 | `{"id": "..."}` |
|
||||
| `delta` | 回复内容片段 | `{"content": "..."}` |
|
||||
| `message_end` | 回复结束 | `{"id": "...", "tokens": number, "model": "..."}` |
|
||||
| `error` | 发生错误 | `{"code": "...", "message": "..."}` |
|
||||
| `done` | 瘚<EFBFBD><EFBFBD><EFBFBD>?| `{}` |
|
||||
| `done` | 流结束 | `{}` |
|
||||
|
||||
---
|
||||
|
||||
@@ -365,22 +365,22 @@ data: {}
|
||||
#### 5.1 上传附件
|
||||
|
||||
```http
|
||||
POST /api/v1/aia/conversations/:id/attachments
|
||||
POST /api/v2/aia/conversations/:id/attachments
|
||||
```
|
||||
|
||||
**霂瑟<EFBFBD>憭?*嚗?
|
||||
**请求头**:
|
||||
|
||||
```
|
||||
Content-Type: multipart/form-data
|
||||
```
|
||||
|
||||
**霂瑟<EFBFBD>雿橒<EFBFBD>FormData嚗?*嚗?
|
||||
**请求体(FormData)**:
|
||||
|
||||
| 字段 | 类型 | 必填 | 描述 |
|
||||
|------|------|------|------|
|
||||
| file | File | <EFBFBD>?| <20><>辣嚗㇊DF/Word/TXT/Excel嚗峕<EFBFBD>憭?0MB嚗?|
|
||||
| file | File | 是 | 文件(PDF/Word/TXT/Excel,最大20MB) |
|
||||
|
||||
**<EFBFBD>滚<EFBFBD>**嚗?
|
||||
**响应**:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -399,13 +399,13 @@ Content-Type: multipart/form-data
|
||||
}
|
||||
```
|
||||
|
||||
**<EFBFBD>躰秤<EFBFBD>?*嚗?
|
||||
**错误码**:
|
||||
|
||||
| <EFBFBD>躰秤<EFBFBD>?| <20>讛膩 |
|
||||
| 错误码 | 描述 |
|
||||
|--------|------|
|
||||
| `ATTACHMENT_TOO_LARGE` | 文件超过 20MB |
|
||||
| `ATTACHMENT_TYPE_NOT_SUPPORTED` | 不支持的文件类型 |
|
||||
| `ATTACHMENT_LIMIT_EXCEEDED` | <EFBFBD><EFBFBD>辣<EFBFBD>圈<EFBFBD>頞<EFBFBD><EFBFBD>銝𢠃<EFBFBD>嚗?銝迎<E98A9D> |
|
||||
| `ATTACHMENT_LIMIT_EXCEEDED` | 附件数量超过上限(5个) |
|
||||
| `TEXT_EXTRACTION_FAILED` | 文本提取失败 |
|
||||
|
||||
---
|
||||
@@ -415,10 +415,10 @@ Content-Type: multipart/form-data
|
||||
#### 6.1 获取项目列表
|
||||
|
||||
```http
|
||||
GET /api/v1/aia/projects
|
||||
GET /api/v2/aia/projects
|
||||
```
|
||||
|
||||
**<EFBFBD>滚<EFBFBD>**嚗?
|
||||
**响应**:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -427,8 +427,8 @@ GET /api/v1/aia/projects
|
||||
"projects": [
|
||||
{
|
||||
"id": "proj-001",
|
||||
"name": "蝟硋倏<EFBFBD><EFBFBD><EFBFBD>蝛園★<EFBFBD>?,
|
||||
"description": "2<EFBFBD>讠<EFBFBD>撠輻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>瘣餅䲮撘誩僕憸<EFBFBD><EFBFBD>蝛?,
|
||||
"name": "糖尿病研究项目",
|
||||
"description": "2型糖尿病患者生活方式干预研究",
|
||||
"conversationCount": 5,
|
||||
"createdAt": "2026-01-01T10:00:00Z",
|
||||
"updatedAt": "2026-01-11T12:00:00Z"
|
||||
@@ -449,20 +449,20 @@ GET /api/v1/aia/projects
|
||||
"code": -1,
|
||||
"error": {
|
||||
"code": "CONVERSATION_NOT_FOUND",
|
||||
"message": "撖寡<EFBFBD>銝滚<EFBFBD><EFBFBD>?
|
||||
"message": "对话不存在"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### <EFBFBD>𡁶鍂<EFBFBD>躰秤<EFBFBD>?
|
||||
### 通用错误码
|
||||
|
||||
| <EFBFBD>躰秤<EFBFBD>?| HTTP <EFBFBD>嗆<EFBFBD><EFBFBD><EFBFBD> | <20>讛膩 |
|
||||
| 错误码 | HTTP 状态码 | 描述 |
|
||||
|--------|------------|------|
|
||||
| `UNAUTHORIZED` | 401 | <EFBFBD>芣<EFBFBD><EFBFBD>?|
|
||||
| `FORBIDDEN` | 403 | <EFBFBD>䭾<EFBFBD><EFBFBD>?|
|
||||
| `NOT_FOUND` | 404 | 韏<EFBFBD><EFBFBD>銝滚<EFBFBD><EFBFBD>?|
|
||||
| `UNAUTHORIZED` | 401 | 未授权 |
|
||||
| `FORBIDDEN` | 403 | 无权限 |
|
||||
| `NOT_FOUND` | 404 | 资源不存在 |
|
||||
| `VALIDATION_ERROR` | 400 | 参数验证失败 |
|
||||
| `INTERNAL_ERROR` | 500 | <EFBFBD>滚𦛚<EFBFBD>典<EFBFBD><EFBFBD>券<EFBFBD>霂?|
|
||||
| `INTERNAL_ERROR` | 500 | 服务器内部错误 |
|
||||
| `LLM_ERROR` | 500 | LLM 调用失败 |
|
||||
| `RATE_LIMITED` | 429 | 请求过于频繁 |
|
||||
|
||||
@@ -475,13 +475,13 @@ GET /api/v1/aia/projects
|
||||
```typescript
|
||||
interface Attachment {
|
||||
id: string; // 附件ID
|
||||
filename: string; // <EFBFBD>笔<EFBFBD><EFBFBD><EFBFBD>辣<EFBFBD>?
|
||||
filename: string; // 原始文件名
|
||||
mimeType: string; // MIME 类型
|
||||
size: number; // 文件大小(字节)
|
||||
ossUrl: string; // OSS 存储地址
|
||||
textContent?: string; // 提取的文本内容(存储时截断)
|
||||
tokenCount: number; // <EFBFBD><EFBFBD>𧋦 Token <EFBFBD>?
|
||||
truncated: boolean; // <EFBFBD>臬炏鋡急⏛<EFBFBD>哨<EFBFBD>頞<EFBFBD><EFBFBD>30K tokens嚗?
|
||||
tokenCount: number; // 文本 Token 数
|
||||
truncated: boolean; // 是否被截断(超过30K tokens)
|
||||
createdAt: string; // 创建时间
|
||||
}
|
||||
```
|
||||
@@ -494,7 +494,7 @@ interface Message {
|
||||
conversationId: string;
|
||||
role: 'user' | 'assistant';
|
||||
content: string;
|
||||
thinkingContent?: string; // 瘛勗漲<EFBFBD>肽<EFBFBD><EFBFBD><EFBFBD>摰?
|
||||
thinkingContent?: string; // 深度思考内容
|
||||
attachments?: Attachment[];
|
||||
model?: string;
|
||||
tokens?: number;
|
||||
@@ -505,15 +505,15 @@ interface Message {
|
||||
|
||||
---
|
||||
|
||||
## <EFBFBD>妒 瘚贝<E7989A>蝷箔<E89DB7>嚗㇌EST Client嚗?
|
||||
## 🧪 测试示例(REST Client)
|
||||
|
||||
```http
|
||||
### <EFBFBD>瑕<EFBFBD><EFBFBD>箄<EFBFBD>雿枏<EFBFBD>銵?
|
||||
GET {{baseUrl}}/api/v1/aia/agents
|
||||
### 获取智能体列表
|
||||
GET {{baseUrl}}/api/v2/aia/agents
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 意图路由
|
||||
POST {{baseUrl}}/api/v1/aia/intent/route
|
||||
POST {{baseUrl}}/api/v2/aia/intent/route
|
||||
Authorization: Bearer {{token}}
|
||||
Content-Type: application/json
|
||||
|
||||
@@ -522,7 +522,7 @@ Content-Type: application/json
|
||||
}
|
||||
|
||||
### 创建对话
|
||||
POST {{baseUrl}}/api/v1/aia/conversations
|
||||
POST {{baseUrl}}/api/v2/aia/conversations
|
||||
Authorization: Bearer {{token}}
|
||||
Content-Type: application/json
|
||||
|
||||
@@ -531,8 +531,8 @@ Content-Type: application/json
|
||||
"title": "测试对话"
|
||||
}
|
||||
|
||||
### <EFBFBD>煾<EFBFBD><EFBFBD><EFBFBD><EFBFBD>荔<EFBFBD>瘚<EFBFBD><EFBFBD>嚗?
|
||||
POST {{baseUrl}}/api/v1/aia/conversations/{{conversationId}}/messages/stream
|
||||
### 发送消息(流式)
|
||||
POST {{baseUrl}}/api/v2/aia/conversations/{{conversationId}}/messages/stream
|
||||
Authorization: Bearer {{token}}
|
||||
Content-Type: application/json
|
||||
Accept: text/event-stream
|
||||
@@ -543,7 +543,7 @@ Accept: text/event-stream
|
||||
}
|
||||
|
||||
### 上传附件
|
||||
POST {{baseUrl}}/api/v1/aia/conversations/{{conversationId}}/attachments
|
||||
POST {{baseUrl}}/api/v2/aia/conversations/{{conversationId}}/attachments
|
||||
Authorization: Bearer {{token}}
|
||||
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
|
||||
|
||||
@@ -568,4 +568,3 @@ Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# AIA V2.1 前端组件设计
|
||||
|
||||
> **版本**:V2.1
|
||||
> **创建日期**�026-01-11
|
||||
> **创建日期**:2026-01-11
|
||||
> **技术栈**:React 19 + TypeScript 5 + Ant Design 6 + Ant Design X 2.1
|
||||
|
||||
---
|
||||
@@ -11,45 +11,45 @@
|
||||
```
|
||||
frontend-v2/src/modules/aia/
|
||||
├── pages/
|
||||
� ├── Dashboard.tsx # 智能体大厅(首页�
|
||||
â”? └── Workspace.tsx # 对è¯<EFBFBD>工作å<EFBFBD>?
|
||||
│ ├── Dashboard.tsx # 智能体大厅(首页)
|
||||
│ └── Workspace.tsx # 对话工作台
|
||||
├── components/
|
||||
� ├── AgentPipeline/
|
||||
â”? â”? ├── index.tsx # 5阶段æµ<EFBFBD>水线容å™?
|
||||
â”? â”? ├── StageColumn.tsx # å<EFBFBD>•阶段列
|
||||
â”? â”? └── AgentCard.tsx # 智能体å<EFBFBD>¡ç‰?
|
||||
� ├── IntentSearch/
|
||||
â”? â”? ├── index.tsx # æ„<EFBFBD>图æ<EFBFBD>œç´¢æ¡?
|
||||
� � └── SuggestionDropdown.tsx # 建议下拉�
|
||||
� ├── ConversationList/
|
||||
â”? â”? ├── index.tsx # 历å<EFBFBD>²ä¼šè¯<EFBFBD>列表
|
||||
â”? â”? └── ConversationItem.tsx # 会è¯<EFBFBD>é¡?
|
||||
� ├── MessageList/
|
||||
â”? â”? ├── index.tsx # 消æ<EFBFBD>¯åˆ—表
|
||||
â”? â”? ├── UserMessage.tsx # 用户消æ<EFBFBD>¯
|
||||
â”? â”? ├── AssistantMessage.tsx # AI回å¤<EFBFBD>
|
||||
â”? â”? └── ThinkingBlock.tsx # 深度æ€<EFBFBD>考折å<EFBFBD> å<EFBFBD>—
|
||||
� ├── Attachment/
|
||||
â”? â”? ├── AttachmentUpload.tsx # 附件上ä¼
|
||||
â”? â”? ├── AttachmentCard.tsx # 附件å<EFBFBD>¡ç‰‡
|
||||
� � └── AttachmentPreview.tsx # 附件预览
|
||||
� ├── SlashCommands/
|
||||
â”? â”? └── index.tsx # å¿«æ<EFBFBD>·æŒ‡ä»¤è<EFBFBD>œå<EFBFBD>•
|
||||
� └── ActionBar/
|
||||
â”? └── index.tsx # 结果æ“<EFBFBD>作æ ?
|
||||
│ ├── AgentPipeline/
|
||||
│ │ ├── index.tsx # 5阶段流水线容器
|
||||
│ │ ├── StageColumn.tsx # 单阶段列
|
||||
│ │ └── AgentCard.tsx # 智能体卡片
|
||||
│ ├── IntentSearch/
|
||||
│ │ ├── index.tsx # 意图搜索框
|
||||
│ │ └── SuggestionDropdown.tsx # 建议下拉框
|
||||
│ ├── ConversationList/
|
||||
│ │ ├── index.tsx # 历史会话列表
|
||||
│ │ └── ConversationItem.tsx # 会话项
|
||||
│ ├── MessageList/
|
||||
│ │ ├── index.tsx # 消息列表
|
||||
│ │ ├── UserMessage.tsx # 用户消息
|
||||
│ │ ├── AssistantMessage.tsx # AI回复
|
||||
│ │ └── ThinkingBlock.tsx # 深度思考折叠块
|
||||
│ ├── Attachment/
|
||||
│ │ ├── AttachmentUpload.tsx # 附件上传
|
||||
│ │ ├── AttachmentCard.tsx # 附件卡片
|
||||
│ │ └── AttachmentPreview.tsx # 附件预览
|
||||
│ ├── SlashCommands/
|
||||
│ │ └── index.tsx # 快捷指令菜单
|
||||
│ └── ActionBar/
|
||||
│ └── index.tsx # 结果操作栏
|
||||
├── hooks/
|
||||
â”? ├── useConversation.ts # 对è¯<EFBFBD>管ç<EFBFBD>†
|
||||
â”? ├── useAgents.ts # 智能体数æ<EFBFBD>?
|
||||
â”? ├── useIntentRouter.ts # æ„<EFBFBD>图路由
|
||||
â”? ├── useStreamMessage.ts # æµ<EFBFBD>å¼<EFBFBD>消æ<EFBFBD>¯
|
||||
â”? └── useAttachment.ts # 附件上ä¼
|
||||
│ ├── useConversation.ts # 对话管理
|
||||
│ ├── useAgents.ts # 智能体数据
|
||||
│ ├── useIntentRouter.ts # 意图路由
|
||||
│ ├── useStreamMessage.ts # 流式消息
|
||||
│ └── useAttachment.ts # 附件上传
|
||||
├── api/
|
||||
â”? └── index.ts # API å°<EFBFBD>装
|
||||
│ └── index.ts # API 封装
|
||||
├── types/
|
||||
� └── index.ts # TypeScript 类型
|
||||
│ └── index.ts # TypeScript 类型
|
||||
├── styles/
|
||||
â”? ├── dashboard.module.css # Dashboard æ ·å¼<EFBFBD>
|
||||
â”? └── workspace.module.css # Workspace æ ·å¼<EFBFBD>
|
||||
│ ├── dashboard.module.css # Dashboard 样式
|
||||
│ └── workspace.module.css # Workspace 样式
|
||||
└── index.tsx # 模块入口 + 路由
|
||||
```
|
||||
|
||||
@@ -68,7 +68,7 @@ frontend-v2/src/modules/aia/
|
||||
--stage-write: #F59E0B; /* 橙色 - 论文撰写 */
|
||||
--stage-publish: #EF4444; /* 红色 - 成果发布 */
|
||||
|
||||
/* 功能�*/
|
||||
/* 功能色 */
|
||||
--ai-assistant: #6366F1; /* AI助手主色 */
|
||||
--thinking-bg: #F3F4F6; /* 思考块背景 */
|
||||
--thinking-border: #E5E7EB; /* 思考块边框 */
|
||||
@@ -108,7 +108,7 @@ frontend-v2/src/modules/aia/
|
||||
|
||||
## 📄 页面设计
|
||||
|
||||
### 1. Dashboard(智能体大厅�
|
||||
### 1. Dashboard(智能体大厅)
|
||||
|
||||
```tsx
|
||||
// pages/Dashboard.tsx
|
||||
@@ -119,7 +119,7 @@ import { AgentPipeline } from '../components/AgentPipeline';
|
||||
export const Dashboard: React.FC = () => {
|
||||
return (
|
||||
<div className={styles.dashboard}>
|
||||
{/* 顶部æ„<EFBFBD>图æ<EFBFBD>œç´¢æ¡?*/}
|
||||
{/* 顶部意图搜索框 */}
|
||||
<header className={styles.header}>
|
||||
<h1>AI 智能助手</h1>
|
||||
<p>有什么可以帮助您的?</p>
|
||||
@@ -135,14 +135,14 @@ export const Dashboard: React.FC = () => {
|
||||
};
|
||||
```
|
||||
|
||||
**布局特点**�
|
||||
**布局特点**:
|
||||
- 顶部居中大搜索框
|
||||
- 5阶段æµ<EFBFBD>水线横å<EFBFBD>‘平铺(桌é<EFBFBD>¢ï¼? 纵å<C2B5>‘滚动(移动)
|
||||
- Gemini é£Žæ ¼å¤§ç•™ç™?
|
||||
- 5阶段流水线横向平铺(桌面)/ 纵向滚动(移动)
|
||||
- Gemini 风格大留白
|
||||
|
||||
---
|
||||
|
||||
### 2. Workspace(对è¯<EFBFBD>工作å<EFBFBD>°ï¼?
|
||||
### 2. Workspace(对话工作台)
|
||||
|
||||
```tsx
|
||||
// pages/Workspace.tsx
|
||||
@@ -201,7 +201,7 @@ export const Workspace: React.FC = () => {
|
||||
|
||||
## 🧩 组件详细设计
|
||||
|
||||
### 1. AgentPipelineï¼?阶段æµ<C3A6>水线)
|
||||
### 1. AgentPipeline(5阶段流水线)
|
||||
|
||||
```tsx
|
||||
// components/AgentPipeline/index.tsx
|
||||
@@ -238,7 +238,7 @@ export const AgentPipeline: React.FC<AgentPipelineProps> = ({ onAgentClick }) =>
|
||||
};
|
||||
```
|
||||
|
||||
**æ ·å¼<EFBFBD>特点**ï¼?
|
||||
**样式特点**:
|
||||
```css
|
||||
.pipeline {
|
||||
display: flex;
|
||||
@@ -258,7 +258,7 @@ export const AgentPipeline: React.FC<AgentPipelineProps> = ({ onAgentClick }) =>
|
||||
|
||||
---
|
||||
|
||||
### 2. IntentSearch(æ„<EFBFBD>图æ<EFBFBD>œç´¢æ¡†ï¼?
|
||||
### 2. IntentSearch(意图搜索框)
|
||||
|
||||
```tsx
|
||||
// components/IntentSearch/index.tsx
|
||||
@@ -307,14 +307,14 @@ export const IntentSearch: React.FC = () => {
|
||||
|
||||
---
|
||||
|
||||
### 3. ThinkingBlock(深度æ€<EFBFBD>考折å<EFBFBD> å<EFBFBD>—ï¼?
|
||||
### 3. ThinkingBlock(深度思考折叠块)
|
||||
|
||||
```tsx
|
||||
// components/MessageList/ThinkingBlock.tsx
|
||||
|
||||
interface ThinkingBlockProps {
|
||||
content: string;
|
||||
duration?: number; // æ€<EFBFBD>考耗时(秒ï¼?
|
||||
duration?: number; // 思考耗时(秒)
|
||||
isStreaming?: boolean; // 是否正在生成
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ export const ThinkingBlock: React.FC<ThinkingBlockProps> = ({
|
||||
|
||||
useEffect(() => {
|
||||
if (!isStreaming && expanded) {
|
||||
// 完æˆ<EFBFBD>å<EFBFBD>?1.5s 自动收起
|
||||
// 完成后 1.5s 自动收起
|
||||
const timer = setTimeout(() => setExpanded(false), 1500);
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
@@ -344,7 +344,7 @@ export const ThinkingBlock: React.FC<ThinkingBlockProps> = ({
|
||||
{isStreaming ? <LoadingOutlined spin /> : <BulbOutlined />}
|
||||
</span>
|
||||
<span className={styles.title}>
|
||||
{isStreaming ? 'æ£åœ¨æ·±åº¦æ€<EFBFBD>è€?..' : `已深度æ€<EFBFBD>è€?(耗时 ${duration?.toFixed(1)}s)`}
|
||||
{isStreaming ? '正在深度思考...' : `已深度思考 (耗时 ${duration?.toFixed(1)}s)`}
|
||||
</span>
|
||||
<span className={styles.expandIcon}>
|
||||
{expanded ? <UpOutlined /> : <DownOutlined />}
|
||||
@@ -363,7 +363,7 @@ export const ThinkingBlock: React.FC<ThinkingBlockProps> = ({
|
||||
};
|
||||
```
|
||||
|
||||
**æ ·å¼<EFBFBD>**ï¼?
|
||||
**样式**:
|
||||
```css
|
||||
.thinkingBlock {
|
||||
background: var(--thinking-bg);
|
||||
@@ -412,18 +412,18 @@ export const AttachmentUpload: React.FC<AttachmentUploadProps> = ({
|
||||
|
||||
const handleUpload = async (file: File) => {
|
||||
if (attachments.length >= maxCount) {
|
||||
message.error(`最多上�${maxCount} 个附件`);
|
||||
message.error(`最多上传 ${maxCount} 个附件`);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 文件类型校验
|
||||
const allowedTypes = ['application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'text/plain', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];
|
||||
if (!allowedTypes.includes(file.type)) {
|
||||
message.error('仅支æŒ?PDFã€<C3A3>Wordã€<C3A3>TXTã€<C3A3>Excel 文件');
|
||||
message.error('仅支持 PDF、Word、TXT、Excel 文件');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 文件大å°<EFBFBD>æ ¡éªŒï¼?0MBï¼?
|
||||
// 文件大小校验(20MB)
|
||||
if (file.size > 20 * 1024 * 1024) {
|
||||
message.error('文件大小不能超过 20MB');
|
||||
return false;
|
||||
@@ -448,7 +448,7 @@ export const AttachmentUpload: React.FC<AttachmentUploadProps> = ({
|
||||
</Button>
|
||||
</Upload>
|
||||
|
||||
{/* å·²ä¸Šä¼ é™„ä»¶åˆ—è¡?*/}
|
||||
{/* 已上传附件列表 */}
|
||||
<div className={styles.attachmentList}>
|
||||
{attachments.map(att => (
|
||||
<AttachmentCard
|
||||
@@ -483,10 +483,10 @@ interface SlashCommandsProps {
|
||||
}
|
||||
|
||||
const commands: SlashCommand[] = [
|
||||
{ key: 'polish', icon: '�, label: '润色', description: '优化文本表达' },
|
||||
{ key: 'polish', icon: '✨', label: '润色', description: '优化文本表达' },
|
||||
{ key: 'expand', icon: '📝', label: '扩写', description: '扩展内容细节' },
|
||||
{ key: 'translate', icon: '🌐', label: '翻译', description: '中英互译' },
|
||||
{ key: 'export', icon: '📄', label: '导出Word', description: '导出�Word 文档' },
|
||||
{ key: 'export', icon: '📄', label: '导出Word', description: '导出为 Word 文档' },
|
||||
];
|
||||
|
||||
export const SlashCommands: React.FC<SlashCommandsProps> = ({
|
||||
@@ -544,7 +544,7 @@ export const SlashCommands: React.FC<SlashCommandsProps> = ({
|
||||
|
||||
---
|
||||
|
||||
### 6. ActionBar(结果æ“<EFBFBD>作æ <EFBFBD>ï¼?
|
||||
### 6. ActionBar(结果操作栏)
|
||||
|
||||
```tsx
|
||||
// components/ActionBar/index.tsx
|
||||
@@ -623,7 +623,7 @@ export function useConversation(conversationId?: string): UseConversationReturn
|
||||
}
|
||||
}, [conversationId]);
|
||||
|
||||
// å<EFBFBD>‘é€<EFBFBD>消æ<EFBFBD>¯ï¼ˆæµ<EFBFBD>å¼<EFBFBD>ï¼?
|
||||
// 发送消息(流式)
|
||||
const sendMessage = async (content: string, attachmentIds?: string[]) => {
|
||||
setIsLoading(true);
|
||||
|
||||
@@ -637,7 +637,7 @@ export function useConversation(conversationId?: string): UseConversationReturn
|
||||
};
|
||||
setMessages(prev => [...prev, userMessage]);
|
||||
|
||||
// åˆ<EFBFBD>å§‹åŒ?AI 消æ<CB86>¯
|
||||
// 初始化 AI 消息
|
||||
const aiMessage: Message = {
|
||||
id: `temp-ai-${Date.now()}`,
|
||||
role: 'assistant',
|
||||
@@ -769,7 +769,7 @@ export function useStreamMessage() {
|
||||
|
||||
---
|
||||
|
||||
## 📱 å“<C3A5>应å¼<C3A5>设è®?
|
||||
## 📱 响应式设计
|
||||
|
||||
### 断点策略
|
||||
|
||||
@@ -783,19 +783,19 @@ const breakpoints = {
|
||||
};
|
||||
```
|
||||
|
||||
### Dashboard å“<EFBFBD>应å¼?
|
||||
### Dashboard 响应式
|
||||
|
||||
| 断点 | 布局 |
|
||||
|------|------|
|
||||
| `< 768px` | 流水线纵向滚动,卡片单列 |
|
||||
| `â‰?768px` | æµ<EFBFBD>水线横å<EFBFBD>?5 åˆ?|
|
||||
| `≥ 768px` | 流水线横向 5 列 |
|
||||
|
||||
### Workspace å“<EFBFBD>应å¼?
|
||||
### Workspace 响应式
|
||||
|
||||
| 断点 | 布局 |
|
||||
|------|------|
|
||||
| `< 768px` | 侧边栏隐藏(抽屉滑出),输入框键盘适配 |
|
||||
| `â‰?768px` | ä¾§è¾¹æ <EFBFBD>固定显ç¤?240px |
|
||||
| `≥ 768px` | 侧边栏固定显示 240px |
|
||||
|
||||
---
|
||||
|
||||
@@ -883,4 +883,3 @@ export interface SlashCommand {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user