Files
AIclinicalresearch/docs/02-通用能力层/01-LLM大模型网关/README.md
HaHafeng 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

150 lines
3.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
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.
# 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. 模型选择
```typescript
selectModel(userId: string, preferredModel?: string): string
// 根据用户版本和配额选择合适的模型
```
### 2. 统一调用
```typescript
chat(params: {
userId: string;
modelType?: ModelType;
messages: Message[];
stream?: boolean;
}): Promise<ChatResponse>
```
### 3. 配额管理
```typescript
checkQuota(userId: string): Promise<QuotaInfo>
// 检查用户剩余配额
```
### 4. Token计数
```typescript
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计数和计费
- 使用记录和监控
---
## 🔗 相关文档
- [通用能力层总览](../README.md)
- [系统架构分层设计](../../00-系统总体设计/01-系统架构分层设计.md)
---
**最后更新:** 2025-11-06
**维护人:** 技术架构师