Commit Graph

66 Commits

Author SHA1 Message Date
855d142fec chore: add remaining test docs, scripts and temp files
- Add Git commit preparation checklist
- Add Phase testing guides and issue tracking
- Add utility scripts (env setup, test data initialization)
- Add temp migration SQL files (for reference)
- Update startup scripts and README
- Remove obsolete scripts
2025-11-16 15:44:55 +08:00
1992232fda docs: add testing guides and phase summaries
- Add AI quick start guide (START-HERE-FOR-AI.md)
- Add Phase 1-3 testing guides and summaries
- Add feature testing documentation (review, citation)
- Add environment check scripts
- Add one-click startup script
- Add test user initialization scripts
- Add testing records and issue tracking
2025-11-16 15:44:28 +08:00
e52020409c docs: complete documentation system (250+ files)
- System architecture and design documentation
- Business module docs (ASL/AIA/PKB/RVW/DC/SSA/ST)
- ASL module complete design (quality assurance, tech selection)
- Platform layer and common capabilities docs
- Development standards and API specifications
- Deployment and operations guides
- Project management and milestone tracking
- Architecture implementation reports
- Documentation templates and guides
2025-11-16 15:43:55 +08:00
0fe6821a89 feat(frontend): add batch processing and review features
- Add batch processing API and mode
- Add deep read mode for full-text analysis
- Add document selector and switcher components
- Add review page with editorial and methodology assessment
- Add capacity indicator and usage info modal
- Add custom hooks for batch tasks and chat modes
- Update layouts and routing
- Add TypeScript types for chat features
2025-11-16 15:43:39 +08:00
11325f88a7 feat(frontend): add frontend-v2 modular architecture (Task 17)
- React 19 + TypeScript + Vite
- Module registration mechanism with dynamic loading
- Permission management system (basic/advanced/premium)
- Route guards for access control
- Error boundaries for module isolation
- 6 business module placeholders (AIA/ASL/PKB/DC/SSA/ST)
- Top navigation layout
- Tailwind CSS 3 + Ant Design 5
2025-11-16 15:43:17 +08:00
5579ffa78e feat(backend): add batch processing and review tasks modules
- Add Prisma migrations for batch processing tables
- Add Prisma migrations for review tasks tables
- Add seed data for testing
- Add prompt templates for review (editorial, methodology)
- Add CloseAI configuration guide
- Add database validation scripts
2025-11-16 15:43:04 +08:00
0c5310fb77 refactor(backend): incremental architecture evolution (Task 19)
- Add common/ layer for shared capabilities (LLM, RAG, document, middleware)
- Add legacy/ layer for existing business code
- Move files to new structure (controllers, routes, services)
- Update index.ts for new route registration
- System remains fully functional
2025-11-16 15:42:44 +08:00
8a17dc80ae chore: add encoding config to prevent Chinese garbled text (.editorconfig, .gitattributes) 2025-11-16 15:42:18 +08:00
AI Clinical Dev Team
39eb62ee79 feat: add extraction_service (PDF/Docx/Txt) and update .gitignore to exclude venv 2025-11-16 15:32:44 +08:00
AI Clinical Dev Team
2a4f59b08b docs: update design docs for general chat 2025-10-12 10:08:27 +08:00
AI Clinical Dev Team
4ea14dc66d docs: milestone1 completion summary 2025-10-12 10:03:32 +08:00
AI Clinical Dev Team
35bb9d1a16 docs: update progress for Day23-25 2025-10-12 10:01:10 +08:00
AI Clinical Dev Team
f09c79d7d0 feat: add migration scripts 2025-10-12 09:51:11 +08:00
AI Clinical Dev Team
348af7fee9 feat: add general chat feature (without project/agent concept) 2025-10-12 09:48:49 +08:00
AI Clinical Dev Team
07704817ba debug: add detailed logging for userPromptContent 2025-10-11 21:42:38 +08:00
AI Clinical Dev Team
77249ad6f5 debug: add detailed logging for knowledge base context injection 2025-10-11 21:37:54 +08:00
AI Clinical Dev Team
b31ff29038 fix: remove score_threshold params causing Dify API error 2025-10-11 21:27:31 +08:00
AI Clinical Dev Team
99e1a01d70 debug: add detailed logging for knowledge base search 2025-10-11 21:20:13 +08:00
AI Clinical Dev Team
be56c3d35d fix: dropdown click issue 2025-10-11 18:05:28 +08:00
AI Clinical Dev Team
5e06a68189 fix: AgentChatPage conversation data extraction issue 2025-10-11 17:56:19 +08:00
AI Clinical Dev Team
35b0c396c3 fix: AgentChatPage dependencies and Spin component warning 2025-10-11 17:30:57 +08:00
AI Clinical Dev Team
74d7e5eff1 docs: add Day 23-24 work summary 2025-10-11 17:11:06 +08:00
AI Clinical Dev Team
60014b57b5 feat: complete Day 21-24 knowledge base features
- Day 21-22: fix CORS and file upload issues
- Day 23-24: implement @knowledge base search and conversation integration
- Backend: integrate Dify RAG into conversation system
- Frontend: load knowledge base list and @ reference feature
2025-10-11 17:08:12 +08:00
AI Clinical Dev Team
239c7ea85e feat: Day 21-22 - knowledge base frontend completed, fix CORS and file upload issues
- Complete knowledge base list and detail pages
- Complete document upload component
- Fix CORS config (add PUT/DELETE method support)
- Fix file upload issues (disabled state and beforeUpload return value)
- Add detailed debug logs (cleaned up)
- Create Day 21-22 completion summary document
2025-10-11 15:40:12 +08:00
AI Clinical Dev Team
1613e4e517 docs: Day 21 completed summary 2025-10-11 13:00:36 +08:00
AI Clinical Dev Team
186ae55302 feat(frontend): Day 21 knowledge base management frontend completed 2025-10-11 12:48:26 +08:00
AI Clinical Dev Team
5bacdc1768 docs: Day 20 completed summary and milestone update 2025-10-11 11:35:12 +08:00
AI Clinical Dev Team
b26700a7d5 feat(backend): implement knowledge base management backend API 2025-10-11 11:32:47 +08:00
AI Clinical Dev Team
8a4c703128 feat: complete Dify client implementation (Day 19)
## Dify 瀹㈡埛绔皝瑁呭畬鎴?鉁?
### 瀹屾垚鐨勫伐浣?
1. 绫诲瀷瀹氫箟 (backend/src/clients/types.ts)
   - Dataset, Document, Retrieval 鐩稿叧绫诲瀷
   - 瀹屾暣鐨?TypeScript 绫诲瀷瀹氫箟
   - 鑷畾涔?DifyError 閿欒绫?
2. DifyClient 鏍稿績绫?(backend/src/clients/DifyClient.ts)
   - 鐭ヨ瘑搴撶鐞? createDataset, getDatasets, getDataset, deleteDataset
   - 鏂囨。绠$悊: uploadDocumentDirectly, getDocuments, getDocument, deleteDocument
   - 鐭ヨ瘑搴撴绱? retrieveKnowledge (鏀寔璇箟鎼滅储銆乼op_k銆佺浉浼煎害闃堝€?
   - 杈呭姪鏂规硶: waitForDocumentProcessing, uploadAndProcessDocument

3. 娴嬭瘯鑴氭湰 (backend/src/scripts/test-dify-client.ts)
   - 8椤瑰畬鏁存祴璇曞叏閮ㄩ€氳繃
   - 娴嬭瘯鑰楁椂绾?5绉?   - 楠岃瘉鎵€鏈堿PI鍔熻兘姝e父

### 娴嬭瘯缁撴灉

鉁?娴嬭瘯1: 鍒涘缓鐭ヨ瘑搴?鉁?娴嬭瘯2: 鑾峰彇鐭ヨ瘑搴撳垪琛?(鎵惧埌3涓?
鉁?娴嬭瘯3: 鑾峰彇鐭ヨ瘑搴撹鎯?鉁?娴嬭瘯4: 涓婁紶鏂囨。 (247 tokens)
鉁?娴嬭瘯5: 鑾峰彇鏂囨。鍒楄〃
鉁?娴嬭瘯6: 鐭ヨ瘑搴撴绱?(鐩镐技搴?.4420)
鉁?娴嬭瘯7: 鍒犻櫎鏂囨。
鉁?娴嬭瘯8: 鍒犻櫎鐭ヨ瘑搴?
### 鎶€鏈寒鐐?
- 瀹屽杽鐨勯敊璇鐞嗘満鍒?(axios 鎷︽埅鍣?
- 鏅鸿兘杞绛夊緟鏂囨。澶勭悊瀹屾垚
- FormData 鏂囦欢涓婁紶鏀寔
- 鍗曚緥妯″紡瀵煎嚭
- 鏀寔鑷畾涔夐厤缃?
### 渚濊禆鏇存柊

- form-data: ^4.0.0
- @types/form-data: ^2.5.0

### 閰嶇疆鏇存柊

- DIFY_API_KEY 鏇存柊涓烘湇鍔PI瀵嗛挜
- DIFY_API_URL=http://localhost/v1

### 鏂囨。鏇存柊

- 鏂板: docs/05-姣忔棩杩涘害/Day19-Dify瀹㈡埛绔皝瑁呭畬鎴?md
- 鏇存柊: docs/04-寮€鍙戣鍒?寮€鍙戦噷绋嬬.md (Day 19 鏍囪涓哄畬鎴?

### 涓嬩竴姝?
Day 20-22: 鐭ヨ瘑搴撶鐞嗗姛鑳?- 鏁版嵁搴撹〃璁捐 (KnowledgeBase, Document)
- 鍚庣 CRUD API
- 鍓嶇鐭ヨ瘑搴撶鐞嗛〉闈?- 鏂囨。涓婁紶缁勪欢

---
Progress: 閲岀▼纰?1 (MVP) 90% -> 鐭ヨ瘑搴撶鐞嗗紑鍙戜腑
2025-10-11 10:25:30 +08:00
AI Clinical Dev Team
9acbb0ae2b feat: complete Dify platform deployment (Day 18)
## Dify 閮ㄧ讲瀹屾垚 鉁?
### 瀹屾垚鐨勫伐浣?1. Docker 闀滃儚鍔犻€熷櫒閰嶇疆
   - 閰嶇疆 5 涓浗鍐呴暅鍍忔簮
   - 澶у箙鎻愬崌涓嬭浇閫熷害鍜屾垚鍔熺巼

2. Dify 闀滃儚鎷夊彇 (鍏?11 涓湇鍔?
   - langgenius/dify-api:1.9.1
   - langgenius/dify-web:1.9.1
   - postgres, redis, weaviate, nginx 绛?   - 鎬诲ぇ灏忕害 2GB锛岃€楁椂绾?15 鍒嗛挓

3. Dify 鏈嶅姟鍚姩
   - 鉁?nginx (80/443)
   - 鉁?api, worker, worker_beat
   - 鉁?web (3000)
   - 鉁?db (PostgreSQL), redis
   - 鉁?weaviate (鍚戦噺鏁版嵁搴?
   - 鉁?sandbox, plugin_daemon, ssrf_proxy

4. Dify 鍒濆鍖栭厤缃?   - 鍒涘缓绠$悊鍛樿处鍙?   - 鍒涘缓搴旂敤: AI Clinical Research
   - 鑾峰彇 API Key: app-VZRn0vMXdmltEJkvatHVGv5j

5. 鍚庣鐜閰嶇疆
   - DIFY_API_URL=http://localhost/v1
   - DIFY_API_KEY 宸查厤缃?
### 鏂囨。鏇存柊
- 鏂板: docs/05-姣忔棩杩涘害/Day18-Dify閮ㄧ讲瀹屾垚.md
- 鏇存柊: docs/04-寮€鍙戣鍒?寮€鍙戦噷绋嬬.md (Day 18 鏍囪涓哄畬鎴?

### 涓嬩竴姝?Day 19-24: 鐭ヨ瘑搴撶郴缁熷紑鍙?- Dify 瀹㈡埛绔皝瑁?- 鐭ヨ瘑搴撶鐞?CRUD
- 鏂囨。涓婁紶涓庡鐞?- @鐭ヨ瘑搴撻泦鎴?- RAG 闂瓟楠岃瘉

---
Progress: 閲岀▼纰?1 (MVP) 85% -> 鐭ヨ瘑搴撶郴缁熷紑鍙戜腑
2025-10-11 08:58:41 +08:00
AI Clinical Dev Team
0f0940534f fix: resolve black code block background and Ant Design warnings
Issue 1: Black background appearing in chat (CRITICAL)
- Cause: Using vscDarkPlus (dark theme) for code syntax highlighting
- Solution: Changed to oneLight (light theme) + custom styling
- Result: Code blocks now have light gray background matching UI

Issue 2: Ant Design deprecation warnings
- Removed deprecated 'popupClassName' from Select
- Removed deprecated 'overlayStyle' from Tooltip
- These warnings don't affect functionality but cleaned up console

Changes:
- MessageList.tsx: vscDarkPlus 鈫?oneLight + custom styles
- ModelSelector.tsx: Removed deprecated props

Test: Ask AI to write code, should see light-themed code blocks
2025-10-10 22:24:09 +08:00
AI Clinical Dev Team
8b07a3f822 fix: increase conversation history from 10 to 100 messages
Previous limit was too conservative:
- Old: 10 messages (5 conversation turns) 鉂?Too limited
- New: 100 messages (50 conversation turns) 鉁?Reasonable

Context capacity comparison:
- DeepSeek-V3: 64K tokens 鈮?100-200 turns
- Qwen3-72B: 128K tokens 鈮?200-400 turns
- Previous 10 messages was only using ~1% of capacity

Real usage scenarios:
- Quick consultation: 5-10 turns
- In-depth discussion: 20-50 turns 鉁?Common
- Complete research design: 50-100 turns

The new 100-message limit covers 99% of real use cases while
staying well within model token limits.
2025-10-10 22:16:30 +08:00
AI Clinical Dev Team
529cfe20da fix: prevent project background from being sent on every message
Critical bug fix: Project background was being sent with EVERY message,
causing AI to respond to background instead of follow-up questions.

Problem:
- First message: User asks A, AI answers A 鉁?- Second message: User asks B, but prompt includes background again
- AI responds to background content, ignores question B 鉂?
Solution:
- Only send full prompt template (with project background) on FIRST message
- For follow-up messages, send ONLY user input (+ knowledge base if exists)
- Maintain conversation history properly

Updated: conversationService.assembleContext()
- Check if historyMessages.length === 0 (first message)
- First message: use renderUserPrompt() with all variables
- Follow-up: send userInput directly (optionally with knowledge base)

This ensures multi-turn conversations work correctly.
2025-10-10 22:07:53 +08:00
AI Clinical Dev Team
2d51933aee feat: maximize chat window size
Major layout optimizations to increase chat area:

1. MainLayout improvements:
   - Remove Content padding/margin (was 24px + 24px = 48px wasted)
   - Reduce Sider width from 280px to 240px
   - Set Content overflow:hidden and flex layout

2. AgentChatPage improvements:
   - Replace large Card header with compact toolbar (saved ~40px)
   - Remove Card wrapper (saved border/padding)
   - Direct div layout for chat area

3. Other pages:
   - Added padding:24px to HomePage/KnowledgePage/HistoryPage
   - Maintain consistent spacing for non-chat pages

Result: Chat window now occupies ~85% of screen height instead of ~33%

Verified working: AI responses, scrolling, and UI display
2025-10-10 22:01:09 +08:00
AI Clinical Dev Team
fdebb44859 fix: resolve conversation API issues
1. Fixed double data unwrapping in AgentChatPage
2. Fixed API URL in sendMessageStream (use relative path /api/v1)

Verified working: AI can now respond to messages
2025-10-10 21:52:10 +08:00
AI Clinical Dev Team
6e8b43f6df fix: use correct mock user ID in conversation controller
Changed userId from '1' to 'user-mock-001' in all conversation controller methods to match the actual mock user created in database.

This fixes the 400 error when creating conversations.
2025-10-10 21:39:40 +08:00
AI Clinical Dev Team
b9cb173eb6 fix: resolve double data unwrapping issue in API calls
Issue: projectApi and agentApi were unwrapping response.data twice:
1. request interceptor returns response.data
2. API functions returned response.data again (undefined)

This caused all API calls to fail silently with 'response.success' being undefined.

Fixed:
- projectApi: Removed redundant .data access
- agentApi: Removed redundant .data access

All API functions now correctly return the backend response:
{ success: true, data: [...] }

This fixes:
- '鑾峰彇椤圭洰鍒楄〃澶辫触' error on page load
- '鍒涘缓椤圭洰澶辫触' error when creating projects
- Any other API call failures
2025-10-10 21:33:38 +08:00
AI Clinical Dev Team
bfba0ef8b8 docs: add frontend data fetching troubleshooting guide 2025-10-10 21:28:49 +08:00
AI Clinical Dev Team
16b975c340 fix: add service management scripts for port conflicts
New tools:
- 鍋滄鎵€鏈夋湇鍔?bat - Stop all services
- 鏌ョ湅绔彛鍗犵敤.bat - Check port usage
- 閲嶅惎鏈嶅姟.bat - Restart services
- 蹇€熶慨澶?绔彛鍗犵敤.md - Troubleshooting guide

These scripts help resolve:
- EADDRINUSE error (port 3001 already in use)
- ENOBUFS error (network connection issues)
- Timeout errors (backend not responding)
2025-10-10 21:23:51 +08:00
AI Clinical Dev Team
cc3323b795 docs: add quick start guide (START-BEGIN.md) 2025-10-10 21:15:45 +08:00
AI Clinical Dev Team
96d9783242 fix: create mock user to resolve FK constraint issue
Issues fixed:
1. Frontend port is 3000 (not 5173)
2. Projects API returns 500 due to missing user
3. Foreign key constraint violation on projects_user_id_fkey

Solutions:
- Created create-mock-user.ts script
- Added user-mock-001 to database
- Created startup guide (娴嬭瘯鍜屽惎鍔?md)
- Created one-click launcher (涓€閿惎鍔?bat)
- Created diagnostic tool (璇婃柇闂.bat)

New files:
- backend/src/scripts/create-mock-user.ts
- 娴嬭瘯鍜屽惎鍔?md
- 涓€閿惎鍔?bat
- 璇婃柇闂.bat
2025-10-10 21:15:04 +08:00
AI Clinical Dev Team
e11bb3fb5e docs: Day 14-17 completion summary and milestone 1 completed 2025-10-10 20:54:38 +08:00
AI Clinical Dev Team
84bf1c86ab feat: Day 14-17 - Frontend Chat Interface completed
Frontend:
- Create MessageList component with streaming animation
- Create MessageInput component with @knowledge base support
- Create ModelSelector component (DeepSeek/Qwen/Gemini)
- Implement conversationApi with SSE streaming
- Update AgentChatPage integrate all components
- Add Markdown rendering (react-markdown + remark-gfm)
- Add code highlighting (react-syntax-highlighter)
- Add vite-env.d.ts for environment variables

Features:
- Real-time streaming output with cursor animation
- Markdown and code block rendering
- Model switching (DeepSeek-V3, Qwen3-72B, Gemini Pro)
- @Knowledge base selector (UI ready)
- Auto-scroll to bottom
- Shift+Enter for new line, Enter to send
- Beautiful message bubble design

Build: Frontend build successfully (7.94s, 1.9MB)

New Files:
- components/chat/MessageList.tsx (170 lines)
- components/chat/MessageList.css (150 lines)
- components/chat/MessageInput.tsx (145 lines)
- components/chat/MessageInput.css (60 lines)
- components/chat/ModelSelector.tsx (110 lines)
- components/chat/ModelSelector.css (35 lines)
- api/conversationApi.ts (170 lines)
- src/vite-env.d.ts (9 lines)

Total: ~850 lines of new code
2025-10-10 20:52:30 +08:00
AI Clinical Dev Team
8bd2b4fc54 fix: rename QWEN_API_KEY to DASHSCOPE_API_KEY for accuracy 2025-10-10 20:44:04 +08:00
AI Clinical Dev Team
8afff23995 docs: Day 12-13 completion summary and milestone update 2025-10-10 20:33:18 +08:00
AI Clinical Dev Team
702e42febb docs: Day 10-11 completion summary and milestone update
- Create Day10-11-Agent Configuration System completion document
- Update development milestone, mark Day 10-11 as completed
- Update overall progress: Milestone 1 reached 80%
- Document detailed agent config features and API endpoints
2025-10-10 20:17:44 +08:00
AI Clinical Dev Team
864a0b1906 feat: Day 10-11 - Agent Configuration System completed
Backend:
- Create agents.yaml config file with 12 agents definition
- Create Prompt templates for topic-evaluation agent
- Implement agentService.ts for loading and managing agent configs
- Create agentController.ts with CRUD operations
- Create agent routes (GET /agents, /agents/:id, etc.)
- Register agent routes in main server

Frontend:
- Create agentApi.ts service module
- Update AgentChatPage to dynamically load agent config from API
- Add loading state and error handling
- Display agent details (description, category, model)

Build: Both frontend and backend build successfully
2025-10-10 20:13:08 +08:00
AI Clinical Dev Team
59522eaab7 docs: Day 8-9 completion summary and milestone update 2025-10-10 19:41:16 +08:00
AI Clinical Dev Team
b72167f73e feat: Day 8-9 - Project Management API completed
Backend:
- Create project routes (GET, POST, PUT, DELETE)
- Implement projectController with CRUD operations
- Create projectService for database operations
- Add validation middleware for request validation
- Update Prisma schema (add background, researchType, deletedAt fields)
- Implement soft delete for projects

Frontend:
- Create projectApi service module
- Update useProjectStore with fetchProjects and loading state
- Connect ProjectSelector to real API with loading indicator
- Connect CreateProjectDialog to real API with error handling
- Connect EditProjectDialog to real API with loading state
- Add comprehensive error handling and user feedback

Build: Both frontend and backend build successfully
2025-10-10 19:38:49 +08:00
AI Clinical Dev Team
e9e19064e2 docs: update Day 7 summary and milestone progress 2025-10-10 17:57:10 +08:00