mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-09-01 17:10:24 +08:00
feat: support comma-separated AI_MODEL for quick multi-model setup (#870)
Users expected setting AI_MODEL to a comma-separated list to expose multiple models in the picker, but the value was used verbatim as a single model id, leaving the picker with only the "Server Default" fallback. Add a third-priority fallback in loadEnvServerModelsConfig: when AI_MODELS_CONFIG and ai-models.json are both absent, AI_MODEL contains a comma, and AI_PROVIDER is set to a known provider, synthesize an equivalent ServerModelsConfig with the provider's models trimmed, deduplicated, and the first marked as default. Also makes getAIModel and getValidationModel pick the first comma-split value when falling back to AI_MODEL, so requests started before the client picker hydrates still resolve to a real model id. Docs (en/cn/ja) and env.example updated; tests cover the new fallback plus the no-comma / no-AI_PROVIDER negative cases.
This commit is contained in:
@@ -336,6 +336,17 @@ AI_MODELS_CONFIG='{"providers":[{"name":"OpenAI","provider":"openai","models":["
|
||||
|
||||
在项目根目录创建 `ai-models.json` 文件(或通过 `AI_MODELS_CONFIG_PATH` 指定路径)。
|
||||
|
||||
**方式三:`AI_MODEL` 用逗号分隔**(单 provider 的快速配置)
|
||||
|
||||
如果只需要暴露同一 provider 下的多个模型,可以直接在 `AI_MODEL` 里用逗号分隔。第一个模型会作为默认值。
|
||||
|
||||
```bash
|
||||
AI_PROVIDER=doubao
|
||||
AI_MODEL=doubao-seed-1-8-251215,doubao-seed-1-6-flash,doubao-seed-1-6-pro
|
||||
```
|
||||
|
||||
这是等价 `ai-models.json` 的简写形式。如果需要配置多个 provider,或自定义 `apiKeyEnv` / `baseUrlEnv`,请使用方式一或方式二。
|
||||
|
||||
### 配置示例
|
||||
|
||||
```json
|
||||
|
||||
Reference in New Issue
Block a user