fix: 平台 type 放开校验;模型唯一键改为 平台名/模型id

- type 仅决定余额适配器,未知值合法(查不了余额而已),不再报非法
- 打平视图 cfg.models:id = 内部唯一键「平台名/模型id」(池/会话/用量/前端按它认模型,调用处字段名不变),
  mid = 发给上游的原始模型名(callModel body.model 用它)
- 同平台内模型 id 必须唯一;不同平台允许同 id(旧版直接报错的问题)
- 旧 models[] 迁移时平台名自动去重,避免唯一键碰撞
- 前端:卡片/编辑器展示 mid(原始名),编辑弹窗新增时按 平台+id 查重
- concurrency 仍仅解析记录,调度保持每模型 1 会话
This commit is contained in:
2026-09-02 23:09:04 +08:00
parent 7e046e5bbe
commit e3bfe0a1d5
9 changed files with 302 additions and 99 deletions
+3 -2
View File
@@ -108,11 +108,12 @@ async function callModel(cfg, modelId, messages, tools, options) {
if (opts.signal.aborted) controller.abort();
else opts.signal.addEventListener('abort', () => controller.abort());
}
// modelId = 内部唯一键「平台名/模型id」;发给上游的模型名用 mid(原始 id)。
const modelCfg = (cfg.models || []).find(m => m.id === modelId);
if (!modelCfg || !modelCfg.url) throw new Error('模型未在配置中定义或缺少独立 url: ' + modelId);
if (!modelCfg || !modelCfg.url) throw new Error('模型未在配置中定义或缺少 url: ' + modelId);
const body = {
model: modelId,
model: modelCfg.mid || modelCfg.id,
messages,
stream: true,
stream_options: { include_usage: true },