Files
AIclinicalresearch/START-HERE-FOR-NEW-AI.md
HaHafeng 88cc049fb3 feat(asl): Complete Day 5 - Fulltext Screening Backend API Development
- Implement 5 core API endpoints (create task, get progress, get results, update decision, export Excel)
- Add FulltextScreeningController with Zod validation (652 lines)
- Implement ExcelExporter service with 4-sheet report generation (352 lines)
- Register routes under /api/v1/asl/fulltext-screening
- Create 31 REST Client test cases
- Add automated integration test script
- Fix PDF extraction fallback mechanism in LLM12FieldsService
- Update API design documentation to v3.0
- Update development plan to v1.2
- Create Day 5 development record
- Clean up temporary test files
2025-11-23 10:52:07 +08:00

247 lines
7.3 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 🚀 新AI启动指令2分钟快速上手
> **日期:** 2025-11-18
> **状态:** 平台基础设施已完成立即开始ASL模块开发
> **阅读时间:** 2分钟
---
## 📋 项目现状(一句话)
**医学科研AI平台基础设施已完成8个核心模块+5个LLM模型现在开发ASL文献筛选模块的第一个功能标题摘要初筛。所有依赖就绪可立即开始**
---
## ✅ 已完成的工作(你的优势)
| 完成时间 | 工作内容 | 状态 |
|---------|---------|------|
| 2025-11-17 | **平台基础设施**8个模块 | ✅ 100% |
| | - 存储服务(本地/OSS切换 | ✅ |
| | - 日志系统结构化JSON | ✅ |
| | - 缓存服务Memory/Redis | ✅ |
| | - 异步任务队列 | ✅ |
| | - 健康检查+监控 | ✅ |
| | - 数据库连接池+环境配置 | ✅ |
| 2025-11-18 | **CloseAI集成**GPT-4o+Claude | ✅ 100% |
| | - GPT-4o: 1.5秒响应 ⭐ | ✅ |
| | - Claude-4.5: 2.8秒响应 | ✅ |
| | - 双模型筛选: 4.8秒 | ✅ |
| Week 1-2 | 前后端架构+文档 | ✅ 100% |
---
## 🎯 你的任务ASL模块开发
### 第一步定义数据库Schema2小时
**文件位置:** `backend/prisma/schema.prisma`
**需要添加4个模型**
1. `AslScreeningProject` - 筛选项目
2. `AslLiterature` - 文献信息
3. `AslScreeningResult` - 筛选结果
4. `AslScreeningTask` - 筛选任务
**⚠️ 关键要求:**
- 每个模型必须添加 `@@schema("asl_schema")`
- 参考 `docs/03-业务模块/ASL-AI智能文献/04-开发计划/02-标题摘要初筛开发计划.md` Week 1 Day 1第299-402行有完整代码
**执行命令:**
```bash
cd backend
npx prisma migrate dev --name add_asl_screening_tables
npx prisma generate
```
---
## 📚 必读文档3个核心文档
### 1⃣ 系统全貌20分钟⭐⭐⭐
**`docs/00-系统总体设计/00-系统当前状态与开发指南.md`**
**为什么必读:**
- 包含平台基础设施使用方法storage/logger/cache/jobQueue
- 包含5个LLM模型的调用方式
- 包含云原生开发规范(必须遵守)
- 包含禁止的操作清单
**重点章节:**
- Part 1.3:后端架构 - 平台基础设施(必读)
- Part 2.3:云原生开发规范(必须遵守)
- Part 3重要原则与禁忌必须遵守
---
### 2⃣ ASL开发计划20分钟⭐⭐⭐
**`docs/03-业务模块/ASL-AI智能文献/04-开发计划/02-标题摘要初筛开发计划.md`**
**为什么必读:**
- Week 1 Day 1 包含完整的Prisma Schema代码可直接复制
- 每一天的开发任务详细说明
- 包含LLM筛选服务代码示例
**重点章节:**
- Week 1 Day 1数据库Schema设计第299-402行
- Week 2 Day 1LLM筛选核心实现第403-530行
- 云原生开发注意事项第77-162行
---
### 3⃣ 任务分解清单15分钟⭐⭐
**`docs/03-业务模块/ASL-AI智能文献/04-开发计划/03-任务分解.md`**
**为什么必读:**
- 80+个详细任务每个有ID、耗时、验收标准
- 按天组织,清晰明确
- 包含云原生开发要求
**重点章节:**
- T1.1.1 - T1.1.5数据库Schema设计任务
- 云原生开发要求第61-143行
---
## ⭐ 核心代码示例(直接使用)
### 1. 使用平台基础设施
```typescript
// ✅ 必须使用平台服务
import { storage, logger, cache, jobQueue } from '@/common'
import { prisma } from '@/config/database'
// 文件上传
await storage.upload('literature/123.pdf', buffer)
// 日志记录
logger.info('Screening started', { projectId, count })
// 缓存LLM响应
await cache.set('llm:key', response, 3600)
// 异步任务
const job = await jobQueue.push('asl:screening', data)
// 数据库操作
await prisma.aslProject.create({ data: {...} })
```
### 2. 调用LLM双模型筛选
```typescript
import { LLMFactory } from '@/common/llm/adapters'
// 并行调用两个模型4.8秒完成)
const [deepseekResult, gpt4oResult] = await Promise.all([
LLMFactory.getAdapter('deepseek-v3').chat(messages),
LLMFactory.getAdapter('gpt-5').chat(messages) // 实际使用 gpt-4o
])
// 判断一致性
if (deepseekResult.decision === gpt4oResult.decision) {
// 共识度高,直接采纳
} else {
// 不一致,标记为需要人工复核
}
```
### 3. Excel内存解析云原生
```typescript
import xlsx from 'xlsx'
// ✅ 正确:内存解析
const workbook = xlsx.read(buffer, { type: 'buffer' })
// ❌ 错误:不要保存到磁盘
// fs.writeFileSync('./temp.xlsx', buffer) // 禁止!
```
---
## ⚠️ 必须遵守的规范
### 禁止的操作(会被拒绝)
1.`fs.writeFileSync()` - 使用 `storage.upload()`
2.`new PrismaClient()` - 使用全局 `prisma`
3. ❌ 同步处理LLM批量任务 - 使用 `jobQueue`
4. ❌ Excel保存到磁盘 - 内存解析
5. ❌ 重复实现存储/日志/缓存 - 使用平台服务
6. ❌ 频繁Git提交 - 一天工作结束后统一提交
7. ❌ 提交未测试的代码 - 必须测试通过
### 必须遵守的原则
1. ✅ 使用平台基础设施storage/logger/cache/jobQueue
2. ✅ Schema隔离所有表必须 `@@schema("asl_schema")`
3. ✅ Excel内存解析不落盘
4. ✅ 异步处理LLM任务避免超时
5. ✅ 使用全局Prisma实例
---
## 🚀 立即开始的3个步骤
```bash
# Step 1: 阅读核心文档35分钟
1. docs/00-系统总体设计/00-系统当前状态与开发指南.md20分钟
2. docs/03-业务模块/ASL-AI智能文献/04-开发计划/02-标题摘要初筛开发计划.md15分钟
# Step 2: 定义数据库Schema2小时
1. 打开 backend/prisma/schema.prisma
2. 复制开发计划文档中的Prisma代码Week 1 Day 1
3. 运行迁移npx prisma migrate dev --name add_asl_screening_tables
# Step 3: 创建后端目录结构10分钟
mkdir -p backend/src/modules/asl/{routes,controllers,services,schemas,types,utils}
```
---
## 📞 遇到问题?
| 问题类型 | 查看文档 |
|---------|---------|
| 不了解架构 | `00-系统当前状态与开发指南.md` |
| 不知道怎么用平台服务 | `00-系统当前状态与开发指南.md` Part 1.3 |
| 不知道怎么调用LLM | `02-通用能力层/01-LLM大模型网关/03-CloseAI集成指南.md` |
| 不知道做什么任务 | `03-业务模块/ASL-AI智能文献/04-开发计划/03-任务分解.md` |
| 不知道怎么写代码 | `03-业务模块/ASL-AI智能文献/04-开发计划/02-标题摘要初筛开发计划.md` |
---
## 🎉 准备好了吗?
**检查清单:**
- [ ] 已阅读本文档2分钟
- [ ] 已阅读 `00-系统当前状态与开发指南.md` Part 1.3 和 Part 2.310分钟
- [ ] 已查看 `02-标题摘要初筛开发计划.md` Week 1 Day 15分钟
- [ ] 理解了平台基础设施的使用方式storage/logger/cache/jobQueue
- [ ] 理解了5个LLM模型的调用方式
- [ ] 知道了第一个任务定义数据库Schema
**开始开发吧!** 🚀
---
**详细上下文:** 如需更多信息,查看 `docs/03-业务模块/ASL-AI智能文献/[AI对接] ASL模块快速上下文.md`
**系统全貌:** `docs/00-系统总体设计/00-系统当前状态与开发指南.md`
**最后更新:** 2025-11-18
**更新内容:** 添加平台基础设施和CloseAI集成信息