From 33901631a91db364c070bdaa2abaa6687c65c922 Mon Sep 17 00:00:00 2001 From: ThreeFish Date: Sat, 5 Dec 2026 22:15:06 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat(ModelBind):=20anthropic=20=E5=AE=9A?= =?UTF-8?q?=E4=BB=B7=E8=A1=8C=E9=85=8D=E4=BB=B7=E5=8D=B3=E8=BF=9B=20Model?= =?UTF-8?q?=20Bind=20=E4=B8=8B=E6=8B=89=EF=BC=8CModels=20=E9=A1=B5?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=20Label=20=E5=88=97=EF=BC=8C=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E6=8C=89=20vendor=20=E5=88=86=E7=BB=84=E6=8E=92?= =?UTF-8?q?=E5=BA=8F;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 派生条件改为「vendor 在激活链 且 model 以该 vendor 原生前缀族开头」:anthropic 的 claude-haiku-5-5 等新型号不再需要改内置目录或 bindable_models;copilot / antigravity / gemini 等无前缀族 vendor 行不派生,identity 规则合成范围不变; - ModelPricingEntry 增 label(默认空):Models 页 Label 列 + 行展开可编辑(已保存行仅 vendor / model 锁定);下拉 label 优先级 bindable_models > pricing label(offline_key 归一互配)> 内置 label > model 名; - 下拉按归属 vendor 在激活链(订阅状态顺序)中的位次分组、组内版本降序,中继条目与无归属 custom 条目排最后; - Model Mapping 子页签每条 target 增「Concurrency」列(仅注册表点名 concurrency 的 vendor),读写 vendors..concurrency.models[target],留空沿用默认,与 Overview Model Calling 内联编辑同源; - 测试:派生 / label 优先级 / 分组排序用例,Config 页 Label 列与 Concurrency 列 Node harness 用例;文档同步; 🤖 Generated with [Claude Code](https://claude.com/claude-code), [CodeX](https://openai.com), [Gemini Code Assistant](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang --- docs/arch/config-reference.md | 9 +- docs/arch/session-model-bind.md | 10 +- src/coding/proxy/config/routing.py | 2 + src/coding/proxy/config/ui_registry.py | 8 +- .../proxy/server/static/config/config.js | 63 +++++++++- src/coding/proxy/vendors/model_catalog.py | 49 +++++--- tests/test_dashboard_config_tab.py | 52 ++++++++ tests/test_model_catalog.py | 112 +++++++++++++++--- 8 files changed, 259 insertions(+), 46 deletions(-) diff --git a/docs/arch/config-reference.md b/docs/arch/config-reference.md index e8af39e..cb385f1 100644 --- a/docs/arch/config-reference.md +++ b/docs/arch/config-reference.md @@ -202,6 +202,8 @@ - 槽位满时新请求按 FIFO 顺序排队,直到任一在途请求释放槽位才被唤醒。 - 429 重试期间持续占用槽位(重试视为同一请求的延续)。 - 顶层 `concurrency` 字段缺省为 `None` → 转发至 `ZhipuConfig` 时回退默认值 `default=3`;如需完全关闭限流,可在 `ZhipuConfig` 构造层显式置 `null`(一般无需操作)。 +- `models` 中显式配置的模型在启动时预建槽位:不必等首个请求就出现在 Overview 的 Model Calling 实时状态里(`limit=N, in_use=0`);未显式配置的模型仍在首个请求到达时惰性创建。 +- 编辑入口两处、同一份数据:Config → Vendors › `` › Model Mapping 子页签每条规则的 target 带「Concurrency」列(留空 = 沿用 `default`,单元格显示「默认 N」),与 Overview Model Calling 的内联编辑读写同一 `models` map。无并发配置的 vendor(anthropic 等 monitor 模式)没有这一列,并发不受限。 --- @@ -252,13 +254,14 @@ | --------------------------- | ----- | -------------------------------------------------- | | `vendor` | str | 供应商名称 | | `model` | str | 实际模型名 | +| `label` | str | 展示名(默认空):Model Bind 下拉以此显示,空则回落内置目录 label 或 model 名 | | `online` | bool | 下线开关(默认 `true`):`false` 后该模型不进 Model Bind 下拉、不可新绑定;已绑会话保留并继续由归属 vendor 优先承接,成本照常计价 | | `input_cost_per_mtok` | float | 输入 Token 单价($/百万 token,支持 `$`/`¥` 前缀) | | `output_cost_per_mtok` | float | 输出 Token 单价 | | `cache_write_cost_per_mtok` | float | 缓存创建 Token 单价 | | `cache_read_cost_per_mtok` | float | 缓存读取 Token 单价 | -写入边界:pricing 行**不可删除**——任何 (vendor, model) 行消失(删除、改名、「恢复默认」丢行)的保存一律拒绝(错误只带条数不回显值);退役模型请置 `online: false`。`config import` 整体替换不在其限。已保存行的 vendor/model 在 Config 页只读。native 系 vendor(zhipu/minimax/kimi/doubao/xiaomi/alibaba)的 pricing 行同时是 Model Bind 目录的派生来源:配价即入下拉,无需等发版补内置目录(见 [session-model-bind.md](session-model-bind.md))。 +写入边界:pricing 行**不可删除**——任何 (vendor, model) 行消失(删除、改名、「恢复默认」丢行)的保存一律拒绝(错误只带条数不回显值);退役模型请置 `online: false`。`config import` 整体替换不在其限。已保存行的 vendor/model 在 Config 页只读。vendor 在激活链且 model 以其原生前缀族开头的 pricing 行(anthropic 的 `claude-*` 与 native 系 vendor)同时是 Model Bind 目录的派生来源:配价即入下拉,无需等发版补内置目录(见 [session-model-bind.md](session-model-bind.md))。 --- @@ -383,7 +386,7 @@ env var(运行时) > 存储的显式字段(Dashboard / CLI 配置) > Pyd | --- | --- | --- | --- | | `policies` | `list[SessionPolicy]` | `[]` | 配置态 Session 路由策略,按序求值首次命中生效(存量键:`name`/`match.session_keys`/`tiers`,注释见 `config.default.yaml`) | | `policies.*.model` | `str \| null` | `null` | 会话级模型覆盖:非空时该 Session 的后续请求体 `model` 统一改写为此值(逐请求生效,在途请求不受影响) | -| `bindable_models` | `list[BindableModel]` | claude 三档 | 可绑定模型显式定制层:下拉选项为其与「内置 vendor 目录 ∪ pricing 行(native vendor)」(按激活 vendor 过滤)的合成结果;空清单 = 整体关闭模型绑定(含内置目录与 pricing 派生条目) | +| `bindable_models` | `list[BindableModel]` | claude 三档 | 可绑定模型显式定制层:下拉选项为其与「内置 vendor 目录 ∪ pricing 行」(按激活 vendor 过滤)的合成结果;空清单 = 不做定制(内置目录与 pricing 派生条目照常生效),关闭某模型的绑定用条目 `exclude: true` 或不激活对应 vendor | | `bindable_models.*.label` | `str` | — | UI 显示名,清单内唯一,非空 | | `bindable_models.*.model` | `str` | — | 覆盖目标模型名,清单内唯一,非空 | | `bindable_models.*.tiers` | `list[str]` | `[]` | 绑定后优先承接的 vendor(链头),其后按订阅状态顺序回退;同名覆盖内置条目时留空继承内置归属值,纯自定义条目留空 = 链头沿用当前 tier 顺序 | @@ -392,7 +395,7 @@ env var(运行时) > 存储的显式字段(Dashboard / CLI 配置) > Pyd ### 11.2 目录合成与 identity 规则 -下拉选项在 app 构建时合成(内置目录 ∪ pricing 行 ∪ 本清单,按 `model` 去重、config 覆盖 label/tiers、`exclude` 剔除);pricing 派生条目仅取 native 系 vendor 且在激活链(label = model 名,tiers 归属该 vendor),`online: false` 的模型带 `offline` 标记——不进下拉与 PUT 校验,executor 链头解析与热切换迁移仍可见(已绑会话保留)。合成目录中 native 系 vendor 的模型自动获得 identity `model_mapping` 规则(pattern = target,custom 条目按归属 tiers 或原生前缀族归属),无需手工配置,防 `ModelMapper` default 静默改写。绑定语义为「归属 vendor 优先 + 同档回退」:归属 vendor 置于链头,其故障(429 / 529 / 额度用光 / 熔断)时按订阅状态顺序回退到其他 vendor 的同档模型(档位由 `model_mapping` 反查,查不到则等同 Default);详见 [session-model-bind.md](session-model-bind.md)。 +下拉选项在 app 构建时合成(内置目录 ∪ pricing 行 ∪ 本清单,按 `model` 去重、config 覆盖 label/tiers、`exclude` 剔除);pricing 派生条目取 vendor 在激活链且 model 以该 vendor 原生前缀族开头的行(tiers 归属该 vendor;anthropic 的 `claude-*` 配价即入下拉,copilot / antigravity 等无前缀族的 vendor 行不派生),label 优先级为 `bindable_models` 显式 label > pricing 行 `label` > 内置 label > model 名;下拉按归属 vendor 在激活链(订阅状态顺序)中的位次分组、组内版本降序;`online: false` 的模型带 `offline` 标记——不进下拉与 PUT 校验,executor 链头解析与热切换迁移仍可见(已绑会话保留)。合成目录中 native 系 vendor 的模型自动获得 identity `model_mapping` 规则(pattern = target,custom 条目按归属 tiers 或原生前缀族归属),无需手工配置,防 `ModelMapper` default 静默改写。绑定语义为「归属 vendor 优先 + 同档回退」:归属 vendor 置于链头,其故障(429 / 529 / 额度用光 / 熔断)时按订阅状态顺序回退到其他 vendor 的同档模型(档位由 `model_mapping` 反查,查不到则等同 Default);详见 [session-model-bind.md](session-model-bind.md)。 ## 12. antigravity_gateway — Antigravity 客户端透传配置 diff --git a/docs/arch/session-model-bind.md b/docs/arch/session-model-bind.md index ac3ec8b..362a9c9 100644 --- a/docs/arch/session-model-bind.md +++ b/docs/arch/session-model-bind.md @@ -38,11 +38,11 @@ ## 3. 可绑定目录与配置([config-reference.md](config-reference.md) 为参数权威) -下拉选项 = **内置 vendor 目录 ∪ pricing 行(仅 native vendor)∪ `bindable_models` 显式条目**(三者均按激活 vendor 过滤),合成于 app 构建时([model_catalog.py](../../src/coding/proxy/vendors/model_catalog.py)): +下拉选项 = **内置 vendor 目录 ∪ pricing 行 ∪ `bindable_models` 显式条目**(三者均按激活 vendor 过滤),合成于 app 构建时([model_catalog.py](../../src/coding/proxy/vendors/model_catalog.py)): ```yaml session_policies: - # 可绑定模型显式定制层;空清单 = 整体关闭模型绑定(含内置目录) + # 可绑定模型显式定制层;空清单 = 不做定制(内置目录与 pricing 派生条目照常生效) bindable_models: - label: "Opus 4.6" # UI 显示名(唯一) model: "claude-opus-4-6" # 覆盖目标模型名(唯一) @@ -51,13 +51,15 @@ session_policies: ``` - 合成规则:按 `model` 去重;config 同名条目覆盖 `label`/`tiers`(`tiers` 留空继承内置归属值),`exclude: true` 剔除内置同名条目;纯自定义条目原样保留(`vendor: custom`,tiers 留空 = 沿用全局链路顺序)。 -- **pricing 派生条目**:native 系 vendor(zhipu/minimax/kimi/doubao/xiaomi/alibaba)的已配价模型即时进目录(label = model 名,tiers 归属该 vendor),填补内置目录的发版滞后;与内置/config 同名时让位。 +- **pricing 派生条目**:vendor 在激活链且 model 以该 vendor 原生前缀族开头的已配价行即时进目录(tiers 归属该 vendor),填补内置目录的发版滞后:anthropic 的 `claude-*`(如 haiku-5-5、fable-5-2)与 native 系 vendor(zhipu/minimax/kimi/doubao/xiaomi/alibaba)的模型在 Models 页配价即入下拉;copilot / antigravity / gemini 等无前缀族的 vendor 行记的是上游回报名,不派生。与内置/config 同名时让位。 +- **label 优先级**:`bindable_models` 显式 label > pricing 行 `label`(Models 页 Label 列,按 `offline_key` 归一后与目录条目互配,日期快照别名行的 label 同样生效)> 内置目录 label > model 名。 +- **排序**:按归属 vendor 在激活链(`tiers`,即订阅状态页的 vendor 顺序)中的位次分组,组内按模型名解析的版本号降序(越新越靠前),同版本保持内置 → pricing → config 的合成顺序;归属 vendor 不在链上的中继条目与无归属的 custom 条目排最后。 - **下线(`pricing.*.online: false`)**:模型带 `offline` 标记——不进下拉,`PUT /api/session-vendor` 拒绝新绑(400,文案指明 offline);executor 链头解析与热切换迁移消费含下线的全量清单(`get_known_models()`),已绑会话保留并继续由归属 vendor 优先承接(Sessions 页显示 `(off-list)`);成本照常计价,identity 规则保留。 - **pricing 行不可删除**:Config 页与 `PUT /api/config`、CLI `config set` / `config reset` 对任何会使 (vendor, model) 行消失的保存一律拒绝(错误只带条数不回显值;`config import` 整体替换除外)。Config 页已保存行以「下线/上线」替代删除,vendor/model 只读,「恢复默认价格」保留自定义行。 - **identity 映射规则自动合成**:合成目录中 native 系 vendor(zhipu/minimax/kimi/doubao/xiaomi/alibaba)的模型在 app 构建时自动获得 `pattern=target=model` 规则(custom 条目按归属 tiers 或原生前缀族归属),无需手工配置,杜绝 ModelMapper default 回退静默改写;已被用户显式映射规则(exact/通配/正则)覆盖的模型跳过合成,用户规则优先。 - 未知名(不在任何原生前缀族,如自定义微调模型名)绑定到 native 系 vendor 需配套显式 `model_mapping` 规则,否则门控不放行(native 系对未知名的 default 回退是静默改写而非透传,不放行是刻意防错);anthropic 真透传 vendor 对未知名仍放行。 - 合成目录外的模型无法通过 API 绑定(PUT 校验返回 400)。 -- 内置目录是发版节奏的静态快照:native vendor 的新模型配价(pricing 行)即入下拉,或经自定义条目即时自救(自动获得 identity 规则)。 +- 内置目录是发版节奏的静态快照:新模型在 Models 页配价(pricing 行)即入下拉,或在 `bindable_models` 加自定义条目即时自救。 ## 4. API 与 CLI diff --git a/src/coding/proxy/config/routing.py b/src/coding/proxy/config/routing.py index fdeb0e5..9cebe83 100644 --- a/src/coding/proxy/config/routing.py +++ b/src/coding/proxy/config/routing.py @@ -122,6 +122,8 @@ class ModelPricingEntry(BaseModel): vendor: str # 供应商名称(对应 usage 表"供应商"列) model: str # 实际模型名(对应 usage 表"实际模型"列) + # 展示名:Model Bind 下拉以此显示(空 = 回落内置目录 label / model 名) + label: str = "" # 下线开关:False = 不进 Model Bind 下拉、不可再绑定;已绑会话保留并继续 # 按归属 vendor 优先路由,成本照常计价(pricing 行不可删除,退役走下线) online: bool = True diff --git a/src/coding/proxy/config/ui_registry.py b/src/coding/proxy/config/ui_registry.py index 579a6dc..de989b2 100644 --- a/src/coding/proxy/config/ui_registry.py +++ b/src/coding/proxy/config/ui_registry.py @@ -377,7 +377,7 @@ def _vendor_qg(prefix: str, group: str, window_desc: str) -> list[FieldSpec]: "vendors.*.concurrency", "Concurrency", "optional_group", - "每模型并发限制;未设置时使用内置默认(每模型 3 个)", + "每模型并发限制;未设置时使用内置默认(每模型 3 个);也可在 Vendors › Model Mapping 子页签按 target 逐条设置", vendors=["zhipu"], group="Concurrency", ), @@ -447,6 +447,12 @@ def _vendor_qg(prefix: str, group: str, window_desc: str) -> list[FieldSpec]: ), _f("pricing.*.vendor", "Vendor", "text", "供应商名,对应用量表的供应商列"), _f("pricing.*.model", "Model", "text", "实际服务模型名"), + _f( + "pricing.*.label", + "Label", + "text", + "展示名,Model Bind 下拉以此显示;留空回落内置目录的 label 或 model 名", + ), _f( "pricing.*.input_cost_per_mtok", "Input", diff --git a/src/coding/proxy/server/static/config/config.js b/src/coding/proxy/server/static/config/config.js index c0a429b..277df50 100644 --- a/src/coding/proxy/server/static/config/config.js +++ b/src/coding/proxy/server/static/config/config.js @@ -1279,7 +1279,45 @@ function mappingDirtyFor(t) { if (activeOps(S.ops).some(function (k) { return k.indexOf('model_mapping.') === 0; })) return true; var shown = function (l) { return (l || []).filter(function (m) { return mappingShownIn(m, t); }); }; - return !deepEqual(shown(S.work.model_mapping), shown(S.base.model_mapping)); + return !deepEqual(shown(S.work.model_mapping), shown(S.base.model_mapping)) || concurrencyDirtyFor(t); + } + // Model Mapping 子页签的「并发度」列写的是 vendors..concurrency.models,一并算进该子页签的 dirty + function concurrencyDirtyFor(t) { + if (activeOps(S.ops).some(function (k) { return k.indexOf('vendors.' + t + '.concurrency.') === 0; })) return true; + return !deepEqual(perModelLimits(S.work.vendors, t), perModelLimits(S.base.vendors, t)); + } + // 该 vendor 是否支持每模型并发度(注册表 vendors.*.concurrency 点名的 vendor) + function hasConcurrency(t) { + var sp = specFor('vendors.' + t + '.concurrency'); + return !!(sp && (!sp.vendors || sp.vendors.indexOf(t) >= 0)); + } + function perModelLimits(list, t) { + var v = findVendor(list, t), c = v && v.concurrency; + return c && isObj(c.models) ? c.models : {}; + } + function defaultConcurrency(t) { + var v = findVendor(S.work.vendors, t), d = v && v.concurrency && v.concurrency.default; + if (d === undefined) d = dflt('vendors.*.concurrency.default'); + return d === undefined || d === null ? 3 : d; + } + // 并发度字段:读写 vendors..concurrency.models[target];清空即删键(回落 vendor 默认) + function concurrencyField(vendor, target) { + var sp = clone(specFor('vendors.' + vendor + '.concurrency.models')) || {}; + Object.assign(sp, { + path: 'vendors.' + vendor + '.concurrency.models.' + target, label: 'Concurrency', widget: 'number', min: 1, max: 20, + description: '该 target 模型的并发上限(映射后模型名);留空沿用 ' + prettyName(vendor) + ' 的默认并行度 ' + defaultConcurrency(vendor) + '。与 Overview 的 Model Calling 内联编辑同一份数据', + }); + return { spec: sp, bind: { + path: sp.path, + get: function () { var v = perModelLimits(S.work.vendors, vendor)[target]; return v === undefined ? null : v; }, + set: function (v) { + var w = findVendor(S.work.vendors, vendor), b = findVendor(S.base.vendors, vendor); + if (!w) return; + var parts = ['concurrency', 'models', target]; + if (v === null || v === undefined || v === '') delIn(w, parts, b); else setIn(w, parts, v); + changed(); + }, + } }; } function errorAt(prefix) { return S.errors.some(function (e) { var p = locToPath(e.loc); return p === prefix || p.indexOf(prefix + '.') === 0; }); @@ -1493,6 +1531,18 @@ fields: function (i) { return itemFields(['model_mapping'], i, ['pattern', 'target', 'is_regex', 'vendors']); }, blank: function () { return { pattern: '', target: '', is_regex: false, vendors: vendor ? [vendor] : [] }; }, }; + // 支持每模型并发度的 vendor:每条规则的 target 多一列「并发度」(留空 = 沿用 vendor 默认) + if (vendor && hasConcurrency(vendor)) { + o.cols.push({ label: 'Concurrency', w: '--col-bool', text: function (r) { + var v = perModelLimits(S.work.vendors, vendor)[r.target]; + return v === undefined ? '默认 ' + defaultConcurrency(vendor) : String(v); + } }); + var baseFields = o.fields; + o.fields = function (i) { + var target = (S.work.model_mapping[i] || {}).target; + return baseFields(i).concat(target ? [concurrencyField(vendor, target)] : []); + }; + } if (vendor) { o.filter = function (r) { return mappingShownIn(r, vendor); }; o.before = [h('p', { class: 'cfg-note', text: '只列作用域为 All 或点名 ' + prettyName(vendor) + ' 的规则(与全局 Model Mapping 同一份数据,原位编辑);新规则默认作用域为 ' + prettyName(vendor) + '。' })]; @@ -1529,7 +1579,7 @@ onclick: function () { goPill('pricing', v); }, }); }))); - var before = [h('p', { class: 'cfg-note', text: '每个 vendor 一个子页签,表内只列 ' + modelTabLabel(cur) + ' 的定价。单价单位为每百万 token;修改后历史用量成本按新价格重算。行序即表内顺序,可拖拽或用 ↑ / ↓ 调整。定价行不可删除:退役模型请下线(不进 Model Bind 下拉,已绑会话保留,成本照常计价);下线按模型名匹配 Model Bind 目录,忽略日期快照后缀与 . / - 写法差异,同名模型任一行下线即下线。' })]; + var before = [h('p', { class: 'cfg-note', text: '每个 vendor 一个子页签,表内只列 ' + modelTabLabel(cur) + ' 的定价。单价单位为每百万 token;修改后历史用量成本按新价格重算。行序即表内顺序,可拖拽或用 ↑ / ↓ 调整。Label 是 Model Bind 下拉的展示名,留空回落内置 label 或 model 名;本 vendor 原生模型配价后即进 Model Bind 下拉。定价行不可删除:退役模型请下线(不进 Model Bind 下拉,已绑会话保留,成本照常计价);下线按模型名匹配 Model Bind 目录,忽略日期快照后缀与 . / - 写法差异,同名模型任一行下线即下线。' })]; if (fresh.length && !S.readonly) { before.push(banner('info', '包内默认定价中有 ' + fresh.length + ' 行不在已保存的定价表中(定价表已覆盖默认值,不会自动合入;合并后各归其 vendor 子页签)', [btn('合并', function () { S.work.pricing = (S.work.pricing || []).concat(clone(fresh)); changed(); rerender(); }, 'cfg-btn-sm')])); @@ -1577,6 +1627,7 @@ cols: [ { label: 'Vendor', w: '--col-vendor', text: function (r) { return prettyName(r.vendor); } }, { label: 'Model', w: '--col-model', mono: true, text: function (r) { return r.model; } }, + { label: 'Label', w: '--col-name', text: function (r) { return r.label || '–'; } }, { label: 'Currency', w: '--col-currency', text: entryCurrency }, { label: 'Status', w: '--col-bool', text: function (r) { return r.online === false ? 'Offline' : 'Online'; } }, { label: 'Input', w: '--col-price', mono: true, text: price(PRICE_FIELDS[0]) }, @@ -1597,10 +1648,12 @@ changed(); }, }; - var baseFields = itemFields(['pricing'], i, ['vendor', 'model']); + var baseFields = itemFields(['pricing'], i, ['vendor', 'model', 'label']); + // 已保存行的 vendor / model 锁定(identity 键,pricing 行不可删除);label 可改 + var keys = ['vendor', 'model', 'label']; if (savedRow(i)) { baseFields = baseFields.map(function (f, k) { - return { spec: f.spec, bind: f.bind, row: function (b) { return field(spec('pricing.*.' + ['vendor', 'model'][k]), b, true); } }; + return keys[k] === 'label' ? f : { spec: f.spec, bind: f.bind, row: function (b) { return field(spec('pricing.*.' + keys[k]), b, true); } }; }); } return baseFields.concat([{ spec: curSpec, bind: cur }], PRICE_FIELDS.map(function (f) { @@ -1614,7 +1667,7 @@ }; })); }, - blank: function () { return { vendor: cur || '', model: '', input_cost_per_mtok: '$0.0', output_cost_per_mtok: '$0.0', cache_write_cost_per_mtok: '$0.0', cache_read_cost_per_mtok: '$0.0' }; }, + blank: function () { return { vendor: cur || '', model: '', label: '', input_cost_per_mtok: '$0.0', output_cost_per_mtok: '$0.0', cache_write_cost_per_mtok: '$0.0', cache_read_cost_per_mtok: '$0.0' }; }, })); }; diff --git a/src/coding/proxy/vendors/model_catalog.py b/src/coding/proxy/vendors/model_catalog.py index 75bfc8d..3acb154 100644 --- a/src/coding/proxy/vendors/model_catalog.py +++ b/src/coding/proxy/vendors/model_catalog.py @@ -33,7 +33,8 @@ logger = logging.getLogger(__name__) -# 走共享 ModelMapper 的 native 系 vendor(identity 规则只对这类 vendor 合成) +# 走共享 ModelMapper 的 native 系 vendor(identity 规则只对这类 vendor 合成; +# pricing 行派生进目录的范围另按 NATIVE_MODEL_PREFIXES 判定) _NATIVE_MAPPER_VENDORS = frozenset( {"zhipu", "minimax", "kimi", "doubao", "xiaomi", "alibaba"} ) @@ -170,12 +171,18 @@ def compose_bindable_catalog( - config 清单为空 = 不做定制,目录仍为「内置目录(按激活 vendor 过滤) ∪ pricing 派生条目」;关闭绑定请用条目的 ``exclude=True`` 逐个剔除, 或不激活对应 vendor(不再有「空清单即禁用」的陷阱语义) - - 排序:按模型名解析的版本号降序(越新越靠前),同版本保持内置目录 - / pricing / config 的合成顺序;解析不出版本号的排最后 - - pricing 行仅取 native vendor(``_NATIVE_MAPPER_VENDORS``)且在激活链: - 配价即入目录(派生条目 label = model 名,tiers 归属该 vendor,自动获得 - identity 映射规则),填补内置目录滞后于上游新型号的缺口;按 (vendor, + - 排序:先按归属 vendor 在激活链(``active_vendor_names``,即订阅状态的 + vendor 顺序)中的位次分组,组内按模型名解析的版本号降序(越新越靠前), + 同版本保持合成顺序;归属 vendor 不在链上(中继条目)与无归属的 + custom 条目排最后,解析不出版本号的在组内排最后 + - pricing 行取 vendor 在激活链且 model 以该 vendor 原生前缀族 + (``NATIVE_MODEL_PREFIXES``)开头的行:配价即入目录(派生条目 + tiers 归属该 vendor),填补内置目录滞后于上游新型号的缺口;copilot / + antigravity 等无前缀族的 vendor 行记的是上游回报名,不派生。按 (vendor, model) 精确去重,与内置/config 同名时让位 + - label 优先级:config 显式 label > pricing 行 ``label``(按 :func:`offline_key` + 归一后与目录条目互配,日期快照别名行的 label 同样生效)> 内置目录 + label > model 名;pricing label 留空即回落 - 下线以 model 为粒度:同名模型任一 pricing 行 ``online: false`` 即视为 下线(模型名按 :func:`offline_key` 归一后比对,pricing 行的日期快照后缀 ``-20251001`` 与 ``.``/``-`` 写法差异不影响匹配),条目带 ``offline: true`` @@ -196,12 +203,16 @@ def compose_bindable_catalog( # (vendor, model) 精确匹配、保持配置顺序 priced_online: dict[str, bool] = {} priced_rows: list[tuple[str, str]] = [] + priced_labels: dict[str, str] = {} seen_rows: set[tuple[str, str]] = set() for row in priced or (): vendor, model = str(row.vendor), str(row.model) online = bool(getattr(row, "online", True)) key = offline_key(model) priced_online[key] = priced_online.get(key, True) and online + label = str(getattr(row, "label", "") or "").strip() + if label: + priced_labels.setdefault(key, label) if (vendor, model) not in seen_rows: seen_rows.add((vendor, model)) priced_rows.append((vendor, model)) @@ -234,7 +245,8 @@ def _claim_label(label: str, model: str, owner: str) -> str: if e.model in merged: continue merged[e.model] = { - "label": _claim_label(e.label, e.model, e.vendor), + "label": priced_labels.get(offline_key(e.model)) + or _claim_label(e.label, e.model, e.vendor), "model": e.model, "tiers": list(e.tiers), "vendor": e.vendor, @@ -242,12 +254,16 @@ def _claim_label(label: str, model: str, owner: str) -> str: order.append(e.model) for vendor, model in priced_rows: - if vendor not in _NATIVE_MAPPER_VENDORS or vendor not in active_set: + prefixes = NATIVE_MODEL_PREFIXES.get(vendor) + if vendor not in active_set or not prefixes: + continue + if not model.startswith(prefixes): continue if model in merged: continue merged[model] = { - "label": _claim_label(model, model, vendor), + "label": priced_labels.get(offline_key(model)) + or _claim_label(model, model, vendor), "model": model, "tiers": [vendor], "vendor": vendor, @@ -284,13 +300,18 @@ def _claim_label(label: str, model: str, owner: str) -> str: if not priced_online.get(offline_key(str(entry["model"])), True): entry["offline"] = True - # 稳定排序:版本号新的靠前,解析不出版本号的保持原相对顺序排最后 - def _key(e: dict[str, Any]) -> tuple[int, tuple[int, int]]: + # 稳定排序:按归属 vendor 在激活链中的位次分组,组内版本号新的靠前, + # 解析不出版本号的保持原相对顺序排组内最后 + rank = {v: i for i, v in enumerate(active)} + + def _key(e: dict[str, Any]) -> tuple[int, int, int, int]: + owners = [str(t) for t in e.get("tiers", []) if t] + group = rank.get(owners[0] if owners else "", len(active)) v = model_version(str(e["model"])) - # tuple 比较不支持 None,用「有无版本」作首位;reverse 后无版本者排最后 - return (1 if v else 0, v or (0, 0)) + # 无版本者排组内最后:版本位取 0,再以「有无版本」区分 + return (group, 0 if v else 1, -(v[0] if v else 0), -(v[1] if v else 0)) - catalog.sort(key=_key, reverse=True) + catalog.sort(key=_key) return catalog diff --git a/tests/test_dashboard_config_tab.py b/tests/test_dashboard_config_tab.py index 0b42ecd..b8fc517 100644 --- a/tests/test_dashboard_config_tab.py +++ b/tests/test_dashboard_config_tab.py @@ -937,6 +937,48 @@ class Node { added.closest('.cfg-detail-row').querySelector('.cfg-row').getAttribute('data-path') === 'model_mapping.3.pattern', 'focus must land in the newly added row, not an already expanded one'); + // 10c) Model Mapping 子页签的「并发度」列:只有注册表点名 concurrency 的 vendor 才有;读写 vendors..concurrency.models[target],清空删键回落默认 + view = mkView([], pricing.slice()); + view.values.model_mapping = [ + { pattern: 'P1', target: 'glm-5.3', is_regex: false, vendors: ['zhipu'] }, + { pattern: 'P2', target: 'glm-5.4', is_regex: false, vendors: [] }, + ]; + view.values.vendors = [{ vendor: 'zhipu', enabled: true, concurrency: { default: 2, models: { 'glm-5.4': 7 } } }, { vendor: 'anthropic', enabled: true }]; + view.defaults.vendors = [{ vendor: 'zhipu', enabled: true, concurrency: { default: 2, models: { 'glm-5.4': 7 } } }, { vendor: 'anthropic', enabled: true }]; + view.registry.fields = registry.concat([ + { path: 'tiers', label: 'Tiers', widget: 'list', description: '链路', enum: ['zhipu', 'anthropic'] }, + { path: 'vendors.*.concurrency', label: 'Concurrency', widget: 'optional_group', vendors: ['zhipu'], group: 'Concurrency', description: '并发' }, + { path: 'vendors.*.concurrency.default', label: 'Default Limit', widget: 'number', vendors: ['zhipu'], group: 'Concurrency', description: '默认', min: 1, max: 20 }, + { path: 'vendors.*.concurrency.models', label: 'Per-Model', widget: 'map', vendors: ['zhipu'], group: 'Concurrency', description: '按模型' }, + ]); + await CT.refresh(true); + pill('vendors'); sub('zhipu'); sec('model_mapping'); + let ths2 = Array.from(root.querySelectorAll('th')).map(t => t.textContent); + assert.ok(ths2.includes('Concurrency'), 'zhipu Model Mapping has a Concurrency column: ' + ths2.join('|')); + assert.ok(rows()[0].textContent.includes('默认 2'), 'unset target shows the vendor default'); + assert.ok(rows()[1].textContent.includes('7'), 'configured target shows its limit'); + assert.ok(!root.querySelector('.cfg-subpills .range-btn[data-vendor="zhipu"]').classList.contains('cfg-has-dot')); + rows()[0].click(); + const concInp = root.querySelector('[data-path="vendors.zhipu.concurrency.models.glm-5.3"] input'); + assert.ok(concInp && !concInp.disabled && concInp.getAttribute('type') === 'number', 'expanded row offers an editable Concurrency field'); + concInp.value = '4'; concInp.dispatch('input'); + assert.ok(rows()[0].textContent.includes('4') && !rows()[0].textContent.includes('默认 2'), 'cell reflects the edit'); + rows()[0].click(); // 收起行触发整体重绘,页签圆点随之刷新 + assert.ok(root.querySelector('.cfg-subpills .range-btn[data-vendor="zhipu"]').classList.contains('cfg-has-dot'), 'vendor sub-pill turns dirty'); + assert.ok(root.querySelector('.cfg-subpills-3 .range-btn[data-sec="model_mapping"]').classList.contains('cfg-has-dot'), 'Model Mapping sub-tab carries a dirty dot'); + rows()[0].click(); // 重新展开(DOM 已重建,重新取输入框) + assert.ok(rows()[0].textContent.includes('4'), 're-expanded row still shows the edit'); + const concInp2 = root.querySelector('[data-path="vendors.zhipu.concurrency.models.glm-5.3"] input'); + concInp2.value = ''; concInp2.dispatch('input'); + assert.ok(rows()[0].textContent.includes('默认 2'), 'clearing falls back to the default'); + rows()[0].click(); + assert.ok(!root.querySelector('.cfg-subpills .range-btn[data-vendor="zhipu"]').classList.contains('cfg-has-dot'), 'no residual key: not dirty after clearing'); + assert.ok(!root.querySelector('.cfg-subpills-3 .range-btn[data-sec="model_mapping"]').classList.contains('cfg-has-dot'), 'Model Mapping dot cleared too'); + sub('anthropic'); + if (root.querySelector('.cfg-subpills-3 .range-btn[data-sec="model_mapping"]')) sec('model_mapping'); + ths2 = Array.from(root.querySelectorAll('th')).map(t => t.textContent); + assert.ok(!ths2.includes('Concurrency'), 'anthropic has no per-model concurrency: no column'); + // 11) 409 + 定向重载失败:不保留「已重新加载」承诺;重试仅重载冲突 section view = mkView([], pricing.slice()); view.values.failover = { status_codes: [429] }; @@ -973,6 +1015,16 @@ class Node { const vInp = root.querySelector('.cfg-row[data-path="pricing.0.vendor"] input'); assert.ok(vInp && vInp.disabled, 'saved row vendor is readonly'); assert.ok(root.querySelector('.cfg-row[data-path="pricing.0.model"] input').disabled, 'saved row model is readonly'); + // Label 列:空 label 显示占位,已保存行的 label 输入框可编辑(vendor / model 才锁定) + const ths = root.querySelectorAll('.cfg-body[data-path="pricing"] th').map(t => t.textContent); + assert.ok(ths.indexOf('Label') === ths.indexOf('Model') + 1, 'Label column sits right after Model: ' + ths.join('|')); + assert.ok(rows()[0].textContent.includes('–'), 'empty label renders a dash placeholder'); + const labelInp = root.querySelector('.cfg-row[data-path="pricing.0.label"] input'); + assert.ok(labelInp && !labelInp.disabled, 'saved row label is editable'); + labelInp.value = 'X Model'; labelInp.dispatch('input'); + assert.ok(rows()[0].textContent.includes('X Model'), 'label cell reflects the edit'); + labelInp.value = ''; labelInp.dispatch('input'); + assert.ok(rows()[0].textContent.includes('–'), 'clearing the label restores the dash'); const priceInp = root.querySelector('.cfg-row[data-path="pricing.0.input_cost_per_mtok"] input'); priceInp.value = '9.0'; priceInp.dispatch('input'); root.querySelectorAll('.cfg-section-head .cfg-btn').find(b => b.textContent === '添加').click(); diff --git a/tests/test_model_catalog.py b/tests/test_model_catalog.py index 1918b44..88082b7 100644 --- a/tests/test_model_catalog.py +++ b/tests/test_model_catalog.py @@ -150,20 +150,32 @@ def test_native_vendor_priced_model_derives_entry(self): ) assert "offline" not in derived - def test_non_native_vendor_pricing_not_derived(self): + def test_anthropic_priced_claude_derives_entry(self): + """anthropic 行配价即入目录:haiku-5-5 等新型号无需改内置目录或 bindable_models.""" + cat = compose_bindable_catalog( + ["zhipu", "anthropic"], [], [_price("anthropic", "claude-haiku-5-5")] + ) + derived = next(e for e in cat if e["model"] == "claude-haiku-5-5") + assert (derived["label"], derived["vendor"], derived["tiers"]) == ( + "claude-haiku-5-5", + "anthropic", + ["anthropic"], + ) + + def test_non_native_prefix_pricing_not_derived(self): + """非本 vendor 原生前缀族、无前缀族 vendor 与未激活 vendor 的行不派生.""" cat = compose_bindable_catalog( ["zhipu", "anthropic"], [_cfg("A", "glm-5.3")], [ - _price("anthropic", "claude-x-9"), + _price("anthropic", "glm-x-9"), _price("gemini", "gemini-x-9"), - _price("copilot", "copilot-x"), + _price("copilot", "claude-haiku-4.5"), + _price("kimi", "kimi-k3"), ], ) models = {e["model"] for e in cat} - assert "claude-x-9" not in models - assert "gemini-x-9" not in models - assert "copilot-x" not in models + assert not {"glm-x-9", "gemini-x-9", "claude-haiku-4.5", "kimi-k3"} & models def test_inactive_vendor_pricing_not_derived(self): cat = compose_bindable_catalog( @@ -171,6 +183,52 @@ def test_inactive_vendor_pricing_not_derived(self): ) assert all(e["model"] != "kimi-k3" for e in cat) + def test_pricing_label_used_on_derived_entry(self): + row = ModelPricingEntry( + vendor="anthropic", model="claude-haiku-5-5", label="Haiku 5.5" + ) + cat = compose_bindable_catalog(["anthropic"], [], [row]) + derived = next(e for e in cat if e["model"] == "claude-haiku-5-5") + assert derived["label"] == "Haiku 5.5" + + def test_pricing_label_overrides_builtin_label(self): + """pricing label 覆盖内置 label;日期快照别名行的 label 经 offline_key 归一后同样生效.""" + cat = compose_bindable_catalog( + ["anthropic"], + [], + [ + ModelPricingEntry( + vendor="anthropic", + model="claude-haiku-4-5-20251001", + label="Haiku 4.5", + ) + ], + ) + builtin = next(e for e in cat if e["model"] == "claude-haiku-4-5") + assert builtin["label"] == "Haiku 4.5" + + def test_pricing_label_priority_below_config(self): + cat = compose_bindable_catalog( + ["anthropic"], + [_cfg("我的 Haiku", "claude-haiku-5-5")], + [ + ModelPricingEntry( + vendor="anthropic", model="claude-haiku-5-5", label="Haiku 5.5" + ) + ], + ) + derived = next(e for e in cat if e["model"] == "claude-haiku-5-5") + assert derived["label"] == "我的 Haiku" + + def test_empty_pricing_label_falls_back(self): + cat = compose_bindable_catalog( + ["anthropic"], + [], + [ModelPricingEntry(vendor="anthropic", model="claude-opus-5-5", label="")], + ) + builtin = next(e for e in cat if e["model"] == "claude-opus-5-5") + assert builtin["label"] == "Opus 5.5" + def test_priced_builtin_model_deduped_builtin_label_wins(self): cat = compose_bindable_catalog( ["zhipu"], [_cfg("A", "claude-opus-4.6")], [_price("zhipu", "glm-5.3")] @@ -247,21 +305,37 @@ def test_empty_config_still_derives_from_pricing(self): cat = compose_bindable_catalog(["zhipu"], [], [_price("zhipu", "glm-5.5")]) assert any(e["model"] == "glm-5.5" and e["vendor"] == "zhipu" for e in cat) - def test_catalog_sorted_newest_version_first(self): - """下拉顺序 = 模型版本降序(越新越靠前),跨 vendor 全局排序.""" + def test_catalog_grouped_by_active_vendor_then_version(self): + """下拉顺序 = 按激活链 vendor 位次分组(订阅状态顺序),组内版本降序.""" cat = compose_bindable_catalog( - ["zhipu", "anthropic", "minimax"], - [], - [_price("zhipu", "glm-5.5"), _price("minimax", "minimax-m2.7")], + ["anthropic", "zhipu", "minimax"], + [_cfg("自定义", "my-model", ["zhipu"]), _cfg("无归属", "orphan")], + [_price("anthropic", "claude-haiku-5-5")], ) - versions = [model_version(e["model"]) for e in cat] - known = [v for v in versions if v] - assert known == sorted(known, reverse=True) - # 版本号 (5,5) 的三者并列最新,排头;glm-4.7 之类老版本必在其后 - assert model_version(cat[0]["model"]) == (5, 5) - assert [e["model"] for e in cat].index("glm-4.7") > [ - e["model"] for e in cat - ].index("glm-5.4") + models = [e["model"] for e in cat] + # anthropic 组:同版本 (5,5) 内置条目先于 pricing 派生条目 + assert models[:3] == [ + "claude-sonnet-5-5", + "claude-opus-5-5", + "claude-haiku-5-5", + ] + assert models.index("claude-haiku-4-5") < models.index("glm-5.4") + assert models.index("glm-4.7") < models.index("minimax-m2.7") + # 无归属 custom 排最后;归属 vendor 在链上的 custom 按归属分组 + assert models[-1] == "orphan" + assert models.index("my-model") < models.index("minimax-m2.7") + + def test_catalog_group_order_follows_active_vendor_order(self): + cat = compose_bindable_catalog(["zhipu", "anthropic"], []) + assert cat[0]["vendor"] == "zhipu" + assert {e["vendor"] for e in cat if e["model"].startswith("glm-")} == {"zhipu"} + + def test_relay_entry_ranks_after_active_chain(self): + """anthropic 出链、copilot 中继承接的 claude-* 条目排在链上 vendor 组之后.""" + cat = compose_bindable_catalog(["zhipu", "copilot"], []) + models = [e["model"] for e in cat] + assert models[-1].startswith("claude-") + assert all(m.startswith("glm-") for m in models[:10]) def test_offline_derived_model_keeps_identity_rule(self): """下线模型保留 identity 规则:已绑会话继续 exact 命中原名,不被回退改写.""" From 040c4b0fe86fac7d31b4eb422427dc31c9d94e55 Mon Sep 17 00:00:00 2001 From: ThreeFish Date: Sat, 5 Dec 2026 22:15:09 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat(Zhipu):=20=E6=98=BE=E5=BC=8F=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=B8=8A=E9=99=90=E7=9A=84=E6=A8=A1=E5=9E=8B=E9=A2=84?= =?UTF-8?q?=E5=BB=BA=E5=B9=B6=E5=8F=91=E6=A7=BD=E4=BD=8D=EF=BC=8C=E6=97=A0?= =?UTF-8?q?=E6=B5=81=E9=87=8F=E5=8D=B3=E5=87=BA=E7=8E=B0=E5=9C=A8=20Model?= =?UTF-8?q?=20Calling=20=E5=AE=9E=E6=97=B6=E7=8A=B6=E6=80=81;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code), [CodeX](https://openai.com), [Gemini Code Assistant](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang --- src/coding/proxy/vendors/concurrency.py | 4 ++++ tests/test_zhipu_concurrency.py | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/coding/proxy/vendors/concurrency.py b/src/coding/proxy/vendors/concurrency.py index a5e5763..bd164e6 100644 --- a/src/coding/proxy/vendors/concurrency.py +++ b/src/coding/proxy/vendors/concurrency.py @@ -157,6 +157,10 @@ class ModelConcurrencyController: def __init__(self, config: ZhipuConcurrencyConfig | None) -> None: self._config = config self._slots: dict[str, _ConcurrencySlot] = {} + # 显式配置了上限的模型预建槽位:不必等首个请求就出现在 Model Calling 实时状态里 + if config is not None: + for model in config.models: + self._get_or_create_slot(model) @property def mode(self) -> Literal["monitor", "limited"]: diff --git a/tests/test_zhipu_concurrency.py b/tests/test_zhipu_concurrency.py index d7be1ca..30e2cb5 100644 --- a/tests/test_zhipu_concurrency.py +++ b/tests/test_zhipu_concurrency.py @@ -175,6 +175,26 @@ def test_mode_is_limited(self) -> None: ctrl = ModelConcurrencyController(ZhipuConcurrencyConfig(default=2)) assert ctrl.mode == "limited" + def test_configured_models_pre_warm_slots(self) -> None: + """显式配置上限的模型预建槽位:无流量也出现在 diagnostics(Model Calling 实时状态).""" + ctrl = ModelConcurrencyController( + ZhipuConcurrencyConfig(default=2, models={"glm-5.3": 5}) + ) + diag = ctrl.get_diagnostics() + assert diag == { + "glm-5.3": { + "mode": "limited", + "in_use": 0, + "pending": 0, + "peak_pending_recent": 0, + "limit": 5, + "available": 5, + } + } + + def test_monitor_mode_pre_warms_nothing(self) -> None: + assert ModelConcurrencyController(None).get_diagnostics() == {} + @pytest.mark.asyncio async def test_lazy_slot_creation(self) -> None: ctrl = ModelConcurrencyController(ZhipuConcurrencyConfig(default=2)) From 58b9f2a2c6ce4b281734b75a0bf5ecb9d75e6451 Mon Sep 17 00:00:00 2001 From: ThreeFish Date: Sat, 5 Dec 2026 22:15:10 +0800 Subject: [PATCH 3/3] =?UTF-8?q?build(version):=20=E5=8F=91=E5=B8=83=20v0.6?= =?UTF-8?q?.20=20=E2=80=94=20anthropic=20=E5=AE=9A=E4=BB=B7=E8=A1=8C?= =?UTF-8?q?=E8=BF=9B=20Model=20Bind=20=E4=B8=8B=E6=8B=89=E3=80=81Models=20?= =?UTF-8?q?=E9=A1=B5=20Label=20=E5=88=97=E3=80=81=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=8C=89=20vendor=20=E5=88=86=E7=BB=84=E3=80=81Model=20Mapping?= =?UTF-8?q?=20=E5=AD=90=E9=A1=B5=E7=AD=BE=E6=8C=89=20target=20=E8=AE=BE?= =?UTF-8?q?=E5=B9=B6=E5=8F=91=E5=BA=A6;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code), [CodeX](https://openai.com), [Gemini Code Assistant](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang --- CHANGELOG.md | 11 +++++++++++ pyproject.toml | 2 +- uv.lock | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d2fc42..30587ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ 本文件基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/) 规范维护,版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。 +## [v0.6.20](https://github.com/ThreeFish-AI/coding-proxy/releases/tag/v0.6.20) - 2026-12-05 + +> 本版主轴:Models 页配价即进 Model Bind 下拉(anthropic 新型号不再需要改内置目录或 `bindable_models`),Models 页新增 Label 列美化下拉展示名,下拉按 vendor 分组排序;Model Mapping 子页签按 target 设置每模型并发度。 + +- fix(model-bind): **anthropic 的 pricing 行配价即进 Model Bind 下拉**:此前派生条目只取 native 系 vendor(zhipu/minimax/kimi/doubao/xiaomi/alibaba),anthropic 的 `claude-haiku-5-5` 等新型号既不在内置目录 `_ANTHROPIC`、也不派生,Models 页看得到、Session 页 Model Bind 下拉选不到;现派生条件改为「vendor 在激活链 且 model 以该 vendor 原生前缀族开头」,copilot / antigravity / gemini 等无前缀族 vendor 的行(上游回报名)仍不派生,identity 规则合成范围不变(anthropic 仍恒等透传); +- feat(models): **Models 页新增 Label 列**:`ModelPricingEntry` 增 `label`(默认空),表格在 Model 右侧显示 Label、行展开可编辑(已保存行仅 vendor / model 锁定,label 可改);Model Bind 下拉的 label 优先级为 `bindable_models` 显式 label > pricing 行 label(按 `offline_key` 归一互配,日期快照别名行的 label 同样生效)> 内置目录 label > model 名; +- feat(model-bind): **下拉按 vendor 分组排序**:先按归属 vendor 在激活链(`tiers`,即订阅状态页顺序)中的位次分组,组内按模型版本号降序,同版本保持内置 → pricing → config 的合成顺序;归属 vendor 不在链上的中继条目与无归属 custom 条目排最后(此前为跨 vendor 全局按版本排序); +- feat(config): **Model Mapping 子页签按 target 设置每模型并发度**:支持并发配置的 vendor(zhipu)每条规则的 target 多一列「Concurrency」(留空 = 沿用 `default`,单元格显示「默认 N」),行展开可填 1–20;读写 `vendors..concurrency.models[target]`,与 Overview Model Calling 的内联编辑同一份数据,编辑计入该 vendor 子页签与 Model Mapping 三级页签的 dirty;anthropic 等 monitor 模式 vendor 无此列、并发不受限;全局 Model Mapping 页不加列(规则作用域为 All 时无法确定写哪一个 vendor); +- feat(zhipu): **显式配置上限的模型预建并发槽位**:不必等首个请求就出现在 Model Calling 实时状态里(`limit=N, in_use=0`);未显式配置的模型仍惰性创建,monitor 模式不变; +- docs: [session-model-bind.md](docs/arch/session-model-bind.md)、[config-reference.md](docs/arch/config-reference.md) 同步派生范围、label 优先级、分组排序与并发度编辑入口; + ## [v0.6.19](https://github.com/ThreeFish-AI/coding-proxy/releases/tag/v0.6.19) - 2026-12-05 > 本版主轴:一次性收口 13 个存量 Issue——配置迁移(I-001)遗留的 6 个 follow-up(#282 ~ #287)、Antigravity 会话标题系列 4 个(#326 ~ #329)、发布手册过时(#311)与订阅状态真机回访(#300);Dashboard 表格列宽随容器按比例伸缩(#354)。 diff --git a/pyproject.toml b/pyproject.toml index dc9c8d4..1584622 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "coding-proxy" -version = "0.6.19" +version = "0.6.20" description = "A High-Availability, Transparent, and Smart Multi-Vendor Proxy for Claude Code. Support Claude Plans, GitHub Copilot, Google Antigravity, ZAI/GLM, MiniMax, Qwen, Xiaomi, Kimi, Doubao..." readme = "README.md" requires-python = ">=3.12" diff --git a/uv.lock b/uv.lock index b497534..385f019 100644 --- a/uv.lock +++ b/uv.lock @@ -159,7 +159,7 @@ wheels = [ [[package]] name = "coding-proxy" -version = "0.6.19" +version = "0.6.20" source = { editable = "." } dependencies = [ { name = "aiosqlite" },