Files
AIclinicalresearch/docs/02-通用能力层/01-LLM大模型网关
HaHafeng 8eef9e0544 feat(asl): Complete Week 4 - Results display and Excel export with hybrid solution
Features:
- Backend statistics API (cloud-native Prisma aggregation)
- Results page with hybrid solution (AI consensus + human final decision)
- Excel export (frontend generation, zero disk write, cloud-native)
- PRISMA-style exclusion reason analysis with bar chart
- Batch selection and export (3 export methods)
- Fixed logic contradiction (inclusion does not show exclusion reason)
- Optimized table width (870px, no horizontal scroll)

Components:
- Backend: screeningController.ts - add getProjectStatistics API
- Frontend: ScreeningResults.tsx - complete results page (hybrid solution)
- Frontend: excelExport.ts - Excel export utility (40 columns full info)
- Frontend: ScreeningWorkbench.tsx - add navigation button
- Utils: get-test-projects.mjs - quick test tool

Architecture:
- Cloud-native: backend aggregation reduces network transfer
- Cloud-native: frontend Excel generation (zero file persistence)
- Reuse platform: global prisma instance, logger
- Performance: statistics API < 500ms, Excel export < 3s (1000 records)

Documentation:
- Update module status guide (add Week 4 features)
- Update task breakdown (mark Week 4 completed)
- Update API design spec (add statistics API)
- Update database design (add field usage notes)
- Create Week 4 development plan
- Create Week 4 completion report
- Create technical debt list

Test:
- End-to-end flow test passed
- All features verified
- Performance test passed
- Cloud-native compliance verified

Ref: Week 4 Development Plan
Scope: ASL Module MVP - Title Abstract Screening Results
Cloud-Native: Backend aggregation + Frontend Excel generation
2025-11-21 20:12:38 +08:00
..

LLM大模型网关

能力定位: 通用能力层核心能力
复用率: 71% (5个模块依赖)
优先级: P0最高
状态: 待实现


📋 能力概述

LLM大模型网关是平台AI能力的核心中枢负责

  • 统一管理所有LLM调用
  • 根据用户版本动态切换模型
  • 成本控制与限流
  • Token计数与计费

🎯 核心价值

1. 商业模式技术基础

专业版 → DeepSeek-V3便宜¥1/百万tokens
高级版 → DeepSeek + Qwen3
旗舰版 → DeepSeek + Qwen3 + Qwen-Long + Claude

2. 成本控制

  • 统一监控所有LLM API调用
  • 超出配额自动限流
  • 按版本计费

3. 统一接口

  • 屏蔽不同LLM API的差异
  • 统一的调用接口

📊 依赖模块

5个模块依赖71%复用率):

  1. AIA - AI智能问答
  2. ASL - AI智能文献双模型判断
  3. PKB - 个人知识库RAG问答
  4. DC - 数据清洗NER提取
  5. RVW - 稿件审查AI评估

💡 核心功能

1. 模型选择

selectModel(userId: string, preferredModel?: string): string
// 根据用户版本和配额选择合适的模型

2. 统一调用

chat(params: {
  userId: string;
  modelType?: ModelType;
  messages: Message[];
  stream?: boolean;
}): Promise<ChatResponse>

3. 配额管理

checkQuota(userId: string): Promise<QuotaInfo>
// 检查用户剩余配额

4. Token计数

countTokens(text: string): number
// 使用tiktoken计算Token数

📂 文档结构

01-LLM大模型网关/
  ├── [AI对接] LLM网关快速上下文.md      # ✅ 已完成
  ├── 03-CloseAI集成指南.md              # ✅ 已完成 ⭐
  ├── 00-需求分析/
  │   └── README.md
  ├── 01-设计文档/
  │   ├── 01-详细设计.md                  # ⏳ Week 5创建
  │   ├── 02-数据库设计.md                # ⏳ Week 5创建
  │   ├── 03-API设计.md                   # ⏳ Week 5创建
  │   └── README.md
  └── README.md                           # ✅ 当前文档

快速入门文档

文档 说明 状态
[AI对接] LLM网关快速上下文.md 快速了解LLM网关设计 已完成
03-CloseAI集成指南.md CloseAIGPT-5+Claude-4.5)集成文档 已完成

⚠️ 开发计划调整

原计划Week 2完成LLM网关

调整: LLM网关完整实现推迟到Week 5

理由:

  1. 现有LLM调用已经workDeepSeek、Qwen
  2. CloseAI集成配置已完成可直接使用
  3. ASL开发不阻塞先用简单调用
  4. Week 5有多个模块实践后再抽取统一网关更合理

当前可用Week 3 ASL开发

  • DeepSeek API直连
  • GPT-5-Pro APICloseAI代理
  • Claude-4.5 APICloseAI代理
  • Qwen APIDashScope
  • 4个模型的基础调用代码示例

Week 5完善LLM网关统一

  • 统一调用接口
  • 版本分级(专业版/高级版/旗舰版)
  • 配额管理和限流
  • Token计数和计费
  • 使用记录和监控

🔗 相关文档


最后更新: 2025-11-06
维护人: 技术架构师