platforms不配置不应该报错
This commit is contained in:
+1
-1
@@ -33,7 +33,7 @@ app/
|
||||
```bash
|
||||
cd app
|
||||
npm install
|
||||
cp config.example.yml config.yml # 补 platforms(必填);本地跑把 workspace_root / data_root 改回 ./data/...
|
||||
cp config.example.yml config.yml # platforms 可先留空(启动后在设置页添加);本地跑再把 workspace_root / data_root 改回 ./data/...
|
||||
npm start # http://localhost:8090
|
||||
```
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# config.example.yml — 配置模板:与 server/config.js 的 DEFAULTS 一一对应。
|
||||
# 复制为 config.yml 后补齐 platforms(至少一个平台,否则启动报错),其余可按需覆盖。
|
||||
# 复制为 config.yml 即可启动;platforms 为空则无模型可用,可在前端设置页添加后重启。
|
||||
|
||||
# 模型平台池:每平台 {name, url, type?, models:[{id, ...}], keys:[{api_key, concurrency?}]}。
|
||||
platforms: []
|
||||
|
||||
@@ -216,12 +216,11 @@ function parseAndValidate(rawText, configPath) {
|
||||
raw = Object.assign({}, raw, { platforms: migrateLegacyModels(raw.models) });
|
||||
log.info('config', '检测到旧配置 models[] 扁平格式,已自动迁移为 platforms 层级;建议改写 config.yml 为 platforms 格式');
|
||||
}
|
||||
if (!Array.isArray(raw.platforms) || !raw.platforms.length) {
|
||||
throw new Error('配置缺少 platforms:至少需要一个平台 {name, url, keys:[{api_key}], models:[{id}]}')
|
||||
}
|
||||
// platforms 允许为空:可先起服务,再在前端设置页添加平台后重启(无模型时无会话可调度)。
|
||||
const rawPlatforms = Array.isArray(raw.platforms) ? raw.platforms : [];
|
||||
// 用 deepMerge 后的 cfg.model_profiles(含内置 mini/zero),故 config.yml 不配也有默认组合。
|
||||
cfg.model_profiles = normalizeModelProfiles(cfg.model_profiles);
|
||||
cfg.platforms = normalizePlatforms(raw.platforms, new Set(Object.keys(cfg.model_profiles)));
|
||||
cfg.platforms = normalizePlatforms(rawPlatforms, new Set(Object.keys(cfg.model_profiles)));
|
||||
cfg.models = [];
|
||||
cfg.platforms.forEach((p, pi) => p.keys.forEach((k, ki) => p.models.forEach((m, mi) => {
|
||||
cfg.models.push({
|
||||
@@ -237,7 +236,7 @@ function parseAndValidate(rawText, configPath) {
|
||||
});
|
||||
})));
|
||||
if (!cfg.models.length) {
|
||||
throw new Error('platforms 下没有任何可用模型:keys[].models 至少需要一个 {id}')
|
||||
log.warn('config', '配置中没有可用模型(platforms 为空或其下模型全被禁用):可在设置页添加平台后重启。');
|
||||
}
|
||||
|
||||
cfg.workspace_root = path.resolve(cfg.workspace_root);
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ vi config.yml
|
||||
`/workspace/tasks`、`/workspace/data`)。`config.yml` 里至少要配:
|
||||
|
||||
```yaml
|
||||
platforms: ... # 模型池:每个平台 url + keys.api_key + models.id(必填,不能留空)
|
||||
platforms: ... # 模型池:每个平台 url + keys.api_key + models.id;可留空,启动后到设置页添加
|
||||
auth: # 建议启用,否则谁都能访问
|
||||
secret: "换一个随机串"
|
||||
users:
|
||||
|
||||
Reference in New Issue
Block a user