(config: ModelConfig)
| 23 | * 创建模型实例 |
| 24 | */ |
| 25 | export function createModel(config: ModelConfig) { |
| 26 | if (!config.baseURL) throw new Error('缺少 API Base URL 配置'); |
| 27 | if (!config.apiKey) throw new Error('缺少 API Key 配置'); |
| 28 | if (!config.model) throw new Error('缺少模型名称配置'); |
| 29 | |
| 30 | return createOpenAI({ |
| 31 | apiKey: config.apiKey, |
| 32 | baseURL: config.baseURL, |
| 33 | })(config.model); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * 从环境变量读取模型配置 |
no outgoing calls
no test coverage detected