From b81bbe0c8c951c7f2bdec5fd2363781ff33cb26c Mon Sep 17 00:00:00 2001 From: fylorn <249551762+fylorn@users.noreply.github.com> Date: Thu, 12 Nov 2026 21:25:23 +0800 Subject: [PATCH] chore(release): publish Lite 2026.11.13 --- package.json | 2 +- release-notes/2026.11.13.md | 5 ++ src-tauri/Cargo.lock | 30 ++++---- src-tauri/Cargo.toml | 16 ++-- src-tauri/tauri.conf.json | 2 +- src-tauri/tests/control_plane.rs | 105 ++++++++++++++++++++++++++ src/generated/tw-api.ts | 58 ++++++++++++-- src/i18n/core.zh.json | 5 +- src/upstreams/ModelSpecDialog.i18n.ts | 56 +++++++++++--- src/upstreams/ModelSpecDialog.tsx | 103 +++++++++++++++++++------ src/upstreams/ModelsPanel.i18n.ts | 2 + src/upstreams/ModelsPanel.tsx | 1 + src/upstreams/ShareDialog.i18n.ts | 2 + src/upstreams/modelSpec.test.ts | 72 ++++++++++++++---- src/upstreams/modelSpec.ts | 95 ++++++++++++----------- src/upstreams/share.test.ts | 9 +++ src/upstreams/share.ts | 4 +- 17 files changed, 446 insertions(+), 121 deletions(-) create mode 100644 release-notes/2026.11.13.md diff --git a/package.json b/package.json index 969b5194..06ac84c5 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "thinkwatch-lite", "private": true, "description": "Desktop app for a local AI API gateway on macOS, Windows and Linux", - "version": "2026.11.12", + "version": "2026.11.13", "type": "module", "packageManager": "pnpm@11.13.0", "scripts": { diff --git a/release-notes/2026.11.13.md b/release-notes/2026.11.13.md new file mode 100644 index 00000000..eceaa54e --- /dev/null +++ b/release-notes/2026.11.13.md @@ -0,0 +1,5 @@ +Model capabilities are discovered automatically, with manual overrides available in the existing Model specs dialog. When an upstream or relay omits capability metadata, choose supported reasoning effort levels and an optional default yourself, explicitly mark effort as not adjustable, or restore automatic discovery at any time. Providers without model listings can still use manually entered model IDs. + +The dialog shows upstream declarations, the saved effective profile, its source, and any levels unavailable through the current protocol. Aliases offer only levels supported by every routing candidate. Sharing links now disclose when they omit manual effort profiles and recommend a config package instead. + +This release bundles Core 0.95.0. After updating, restart Codex to reload its model catalog. diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 41d04aa1..0d0b598c 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -4950,7 +4950,7 @@ dependencies = [ [[package]] name = "thinkwatch-lite" -version = "2026.11.12" +version = "2026.11.13" dependencies = [ "anyhow", "base64 0.22.1", @@ -5459,8 +5459,8 @@ dependencies = [ [[package]] name = "tw-api" -version = "0.94.0" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.94.0#cdc8e206bebb6406c34a3ea602f55fa18373f8eb" +version = "0.95.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.95.0#a7f5713c017eee5bfdde9eb9c66ac9ffcbd8bc8e" dependencies = [ "serde", "serde_json", @@ -5471,8 +5471,8 @@ dependencies = [ [[package]] name = "tw-dialect" -version = "0.94.0" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.94.0#cdc8e206bebb6406c34a3ea602f55fa18373f8eb" +version = "0.95.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.95.0#a7f5713c017eee5bfdde9eb9c66ac9ffcbd8bc8e" dependencies = [ "memchr", "serde", @@ -5481,8 +5481,8 @@ dependencies = [ [[package]] name = "tw-guard" -version = "0.94.0" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.94.0#cdc8e206bebb6406c34a3ea602f55fa18373f8eb" +version = "0.95.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.95.0#a7f5713c017eee5bfdde9eb9c66ac9ffcbd8bc8e" dependencies = [ "aho-corasick", "base64 0.22.1", @@ -5503,8 +5503,8 @@ dependencies = [ [[package]] name = "tw-link" -version = "0.94.0" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.94.0#cdc8e206bebb6406c34a3ea602f55fa18373f8eb" +version = "0.95.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.95.0#a7f5713c017eee5bfdde9eb9c66ac9ffcbd8bc8e" dependencies = [ "serde", "serde_json", @@ -5530,8 +5530,8 @@ dependencies = [ [[package]] name = "tw-types" -version = "0.94.0" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.94.0#cdc8e206bebb6406c34a3ea602f55fa18373f8eb" +version = "0.95.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.95.0#a7f5713c017eee5bfdde9eb9c66ac9ffcbd8bc8e" dependencies = [ "serde", "ts-rs", @@ -5539,8 +5539,8 @@ dependencies = [ [[package]] name = "tw-watch" -version = "0.94.0" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.94.0#cdc8e206bebb6406c34a3ea602f55fa18373f8eb" +version = "0.95.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.95.0#a7f5713c017eee5bfdde9eb9c66ac9ffcbd8bc8e" dependencies = [ "libc", "notify", @@ -5550,8 +5550,8 @@ dependencies = [ [[package]] name = "tw-yaml" -version = "0.94.0" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.94.0#cdc8e206bebb6406c34a3ea602f55fa18373f8eb" +version = "0.95.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.95.0#a7f5713c017eee5bfdde9eb9c66ac9ffcbd8bc8e" dependencies = [ "saphyr-parser", "thiserror 2.0.21", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 692a0cf0..f5b6e181 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thinkwatch-lite" -version = "2026.11.12" +version = "2026.11.13" edition = "2024" # **这个数决定依赖能升到哪一版。**edition 2024 的解析器只挑声明的 Rust # 版本编得动的依赖:写 1.85 的时候,`cargo update` 一直停在旧的 time 和 @@ -21,17 +21,17 @@ edition = "2024" rust-version = "1.90" license = "MIT" -# core 的几个 crate。**钉在 tag 上,不是分支,而且全部钉同一个 tag。**跟着 `main` +# core 的几个 crate 全部钉在同一个发布 tag 上。跟着 `main` # 走意味着同一份源码今天和明天编出来的东西不一样;而更要紧的是,打进 `.app` 的那个 # twcore 二进制必须和这里编译进去的协议镜像来自同一个 core 版本 —— 打包脚本正是 # 从 tw-api 锁到的 tag 去取二进制的(见 scripts/fetch-core.sh)。 [workspace.dependencies] -tw-api = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.94.0" } -tw-types = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.94.0" } -tw-yaml = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.94.0" } -tw-guard = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.94.0" } -tw-watch = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.94.0" } -tw-link = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.94.0" } +tw-api = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.95.0" } +tw-types = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.95.0" } +tw-yaml = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.95.0" } +tw-guard = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.95.0" } +tw-watch = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.95.0" } +tw-link = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.95.0" } [lib] name = "thinkwatch_lite_lib" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index a28ed933..dd472204 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "ThinkWatch Lite", - "version": "2026.11.12", + "version": "2026.11.13", "identifier": "app.thinkwatch.lite", "build": { "beforeDevCommand": "pnpm dev", diff --git a/src-tauri/tests/control_plane.rs b/src-tauri/tests/control_plane.rs index 9fc384f1..e035ef3f 100644 --- a/src-tauri/tests/control_plane.rs +++ b/src-tauri/tests/control_plane.rs @@ -814,3 +814,108 @@ async fn a_tool_call_plugin_is_turned_on_only_through_the_confirmed_save() { .await .unwrap(); } + +/// The desktop transport preserves effort edits and returns the Core's effective profile. +#[tokio::test] +async fn manual_effort_profiles_round_trip_through_the_desktop_control_client() { + use tw_api::{ModelSpecSave, ReasoningEffort, ReasoningEffortChange, ReasoningLevel::*, ep}; + let core = Core::start(); + core.wait_ready().await; + let c = core.ok(); + let provider = "manual-effort"; + let model = "private-model"; + c.call::( + &[], + &serde_json::from_value(serde_json::json!({ + "provider":{"name":provider,"base_url":"http://127.0.0.1:1/v1","protocol":"openai-chat"} + })) + .unwrap(), + ) + .await + .unwrap(); + c.call::( + &[], + &tw_api::ManualModelsSave { + provider: provider.into(), + models: vec![model.into()], + base_version: None, + }, + ) + .await + .unwrap(); + let profile = ReasoningEffort { + supported_levels: vec![Medium, High, Ultra], + default_level: Some(Ultra), + }; + c.call::( + &[], + &ModelSpecSave { + provider: provider.into(), + model: model.into(), + reasoning_effort: ReasoningEffortChange::Set { + value: profile.clone(), + }, + ..Default::default() + }, + ) + .await + .unwrap(); + let rows = c + .call::(&[provider], &()) + .await + .unwrap(); + let row = rows.models.iter().find(|r| r.id == model).unwrap(); + assert_eq!(row.manual_reasoning_effort.as_ref(), Some(&profile)); + assert_eq!(row.reasoning, Some(true)); + assert_eq!(row.manual_reasoning, None); + assert_eq!( + row.reasoning_effort, + Some(ReasoningEffort { + supported_levels: vec![Medium, High], + default_level: Some(Medium) + }) + ); + assert_eq!(row.reasoning_effort_filtered_levels, [Ultra]); + c.call::( + &[], + &ModelSpecSave { + provider: provider.into(), + model: model.into(), + context_window: Some(64000), + ..Default::default() + }, + ) + .await + .unwrap(); + let rows = c + .call::(&[provider], &()) + .await + .unwrap(); + let row = rows.models.iter().find(|r| r.id == model).unwrap(); + assert_eq!( + row.manual_reasoning_effort.as_ref(), + Some(&profile), + "omitted effort edits keep the original profile" + ); + c.call::( + &[], + &ModelSpecSave { + provider: provider.into(), + model: model.into(), + reasoning_effort: ReasoningEffortChange::Auto, + ..Default::default() + }, + ) + .await + .unwrap(); + let rows = c + .call::(&[provider], &()) + .await + .unwrap(); + let row = rows.models.iter().find(|r| r.id == model).unwrap(); + assert!(row.manual_reasoning_effort.is_none()); + assert!( + row.reasoning_effort.is_none(), + "missing upstream metadata remains unknown after reset" + ); +} diff --git a/src/generated/tw-api.ts b/src/generated/tw-api.ts index 7e67630e..29d07cf4 100644 --- a/src/generated/tw-api.ts +++ b/src/generated/tw-api.ts @@ -1,6 +1,6 @@ // Generated by tw-api (`tw_api::ts::export_all`). Do not edit by hand. -export const CONTROL_API_VERSION = 59; +export const CONTROL_API_VERSION = 60; /** * 手动中止(`POST /request/{id}/abort`、`POST /sessions/{id}/abort`)叫停了哪几个请求。 @@ -3099,7 +3099,7 @@ export type ModelRow = { id: string, */ enabled: boolean, /** - * 上下文窗口:这一家手写的(`model_specs`),没写时来自价目表 + * 上下文窗口:手动覆盖优先,然后上游报告,最后价目表 */ context_window?: number | null, /** @@ -3107,7 +3107,7 @@ context_window?: number | null, */ context_window_source?: SpecSource | null, /** - * 一次最多输出多少 token:这一家手写的,没写时来自价目表 + * 一次最多输出多少 token:手动覆盖优先,然后上游报告,最后价目表 */ max_output_tokens?: number | null, /** @@ -3115,7 +3115,7 @@ max_output_tokens?: number | null, */ max_output_tokens_source?: SpecSource | null, /** - * 会不会推理:这一家手写的,没写时来自价目表。不知道时没有 + * 会不会推理:手动覆盖优先,然后上游报告,最后价目表。不知道时没有 */ reasoning?: boolean | null, /** @@ -3123,7 +3123,27 @@ reasoning?: boolean | null, */ reasoning_source?: SpecSource | null, /** - * 收不收图:这一家手写的,没写时来自价目表。不知道时没有 + * 推理开关的手动原值;非空手动档位推导出的 true 不会写进这里。 + */ +manual_reasoning?: boolean | null, +/** + * 实际可用的档位(已应用推理开关和协议转换限制)。没有表示未知。 + */ +reasoning_effort?: ReasoningEffort | null, reasoning_effort_source?: SpecSource | null, +/** + * 上游实际报告的档位;手动覆盖时仍保留,供界面解释和恢复自动。 + */ +reported_reasoning_effort?: ReasoningEffort | null, +/** + * 配置原值,包含省略的默认值。不能从生效值反推它。 + */ +manual_reasoning_effort?: ReasoningEffort | null, +/** + * 当前协议转换不能表示、因而没有向客户端提供的档位。 + */ +reasoning_effort_filtered_levels?: Array, +/** + * 收不收图:手动覆盖优先,然后上游报告,最后价目表。不知道时没有 */ image_input?: boolean | null, /** @@ -3161,7 +3181,8 @@ export type ModelSource = "discovered" | "manual" | "none"; /** * 设一家上游的一个模型的规格(`PUT /provider-model-spec`):价目表不认识这个模型、 - * 或者写错了时手写。**四项都空就是删掉这一项**,回到价目表。 + * 或者写错了时手写。旧的四项按请求替换;推理档位必须显式 auto 才清除。 + * 所有规格(含保留的高级字段)都空时删除模型项。 */ export type ModelSpecSave = { provider: string, /** @@ -3180,6 +3201,10 @@ max_output_tokens?: number | null, * 会不会推理。空 = 用价目表的 */ reasoning?: boolean | null, +/** + * 省略或 keep 保留原值,auto 移除覆盖,set 整组替换。 + */ +reasoning_effort?: ReasoningEffortChange, /** * 收不收图。空 = 用价目表的 */ @@ -4341,6 +4366,25 @@ export type RatioView = { */ median: number, samples: number, }; +/** + * 一整组推理档位。空列表明确表示不可调;没有这项才是自动或未知。 + */ +export type ReasoningEffort = { supported_levels: Array, +/** + * 省略时在最终可用档位里优先 medium,否则取最低档。 + */ +default_level?: ReasoningLevel | null, }; + +/** + * 编辑推理档位:旧客户端省略时保留,恢复自动必须显式提交 auto。 + */ +export type ReasoningEffortChange = { "mode": "keep" } | { "mode": "auto" } | { "mode": "set", value: ReasoningEffort, }; + +/** + * 客户端可选择的推理强度,按从低到高排列。是否能转发还取决于协议。 + */ +export type ReasoningLevel = "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra"; + /** * 一个例外值。**只存哈希和打码后的样子,不存原值**:例外表随配置导出、同步、备份。 * @@ -5672,7 +5716,7 @@ reason: ServeSkip, }; /** * 上下文窗口、输出上限这样的模型规格从哪儿来。 */ -export type SpecSource = "price_table" | "manual"; +export type SpecSource = "price_table" | "manual" | "upstream"; /** * L3 测速要花多少。 diff --git a/src/i18n/core.zh.json b/src/i18n/core.zh.json index f51f0059..2299c881 100644 --- a/src/i18n/core.zh.json +++ b/src/i18n/core.zh.json @@ -735,9 +735,12 @@ "config.manual_model_wildcard": "上游「{upstream}」手动添加的模型「{model}」含有 * 或 ?。手动添加的模型须为确切的模型 ID;只使用上游的部分模型,请设置启用范围(models_only)。", "config.manual_model_duplicate": "模型「{model}」在上游「{upstream}」手动添加的模型中重复。", "config.manual_model_too_long": "上游「{upstream}」手动添加的模型中有一项超过 {max} 个字符。", + "config.model_spec_effort_duplicate": "上游「{upstream}」模型「{model}」的推理档位「{level}」重复。", + "config.model_spec_effort_default": "上游「{upstream}」模型「{model}」的默认推理档位必须属于 supported_levels。", + "config.model_spec_effort_disabled": "上游「{upstream}」模型「{model}」已禁用推理,不能同时指定非空推理档位。", "config.model_spec_blank_model": "上游「{upstream}」的模型规格(model_specs)中有一项的模型 ID 为空。", "config.model_spec_wildcard": "上游「{upstream}」的模型规格「{model}」含有 * 或 ?。模型规格只能对应一个确切的模型 ID。", - "config.model_spec_nothing_set": "上游「{upstream}」的模型规格「{model}」中 context_window、max_output_tokens、reasoning、image_input 均未设置。请至少设置一项,或删除该规格。", + "config.model_spec_nothing_set": "上游「{upstream}」的模型规格「{model}」中没有设置任何规格。请至少设置一项,或删除该规格。", "config.model_spec_zero": "上游「{upstream}」的模型规格「{model}」中 {field} 为 0,须为大于 0 的 token 数。要使用价目表中的值,请删除该项。", "config.reserved_name": "{what:kind}名称「{name}」以 __ 开头,该前缀保留给内置项,请使用其他名称。", "config.rule_name_empty": "有一条自定义{what:rule_line}规则没有名称。", diff --git a/src/upstreams/ModelSpecDialog.i18n.ts b/src/upstreams/ModelSpecDialog.i18n.ts index 66999fa9..8c9a0043 100644 --- a/src/upstreams/ModelSpecDialog.i18n.ts +++ b/src/upstreams/ModelSpecDialog.i18n.ts @@ -3,34 +3,70 @@ import { messages } from "@/i18n"; export const modelSpecDialogText = messages( { title: "模型规格", - desc: "价目表中没有此模型或数值有误时填写。留空或选「价目表」的一项使用价目表。", + desc: "默认自动获取模型能力;上游缺少信息或结果有误时,可按需填写覆盖值。留空或选「自动」恢复自动获取。", contextWindow: "上下文窗口", maxOutput: "输出上限", reasoning: "推理", imageInput: "图片输入", - table: "价目表", + table: "自动", + priceTable: "价目表", yes: "支持", no: "不支持", fromTable: (n: string) => `价目表:${n}`, - useTable: "使用价目表", - notInTable: "价目表中没有", + useTable: "使用自动获取的值", + fromUpstream: (n: string) => `上游:${n}`, + notInTable: "暂无已知值", bad: "须为正整数,最大 4294967295。", - removing: "保存后删除手动设置,各项都使用价目表。", + removing: "保存后移除手动设置,恢复自动获取。", + effort: "推理强度", + effortHelp: "自动使用上游声明的档位。支持推理不一定支持调节强度;手动档位应与上游实际支持的能力一致。", + effortDisabled: "已选择不支持推理,保存后不提供推理档位。", + noAdjustable: "不可调", + manual: "手动", + upstream: "上游", + unknown: "未知", + supportedLevels: "支持的档位", + chooseLevel: "至少选择一个档位;没有可调档位请选「不可调」。", + defaultLevel: "默认档位", + defaultHelp: "自动:在最终可用档位里优先 medium,否则最低档。", + reported: "上游报告", + savedEffective: "该上游当前生效档位", + aliasEffortHelp: "别名使用所有候选模型共有的档位;任一候选能力未知时不提供档位。Codex 也会优先使用与客户端版本对应的上游目录。", + filtered: (levels: string) => `当前协议转换不支持 ${levels},这些档位未向客户端提供。`, + resetEffort: "恢复自动档位", }, { title: "Model specs", - desc: "For a model the price table lacks or gets wrong. A blank field, or one set to Price table, uses the price table.", + desc: "Model capabilities are discovered automatically. Override missing or incorrect information here; leave a field blank or select Automatic to restore discovery.", contextWindow: "Context window", maxOutput: "Max output", reasoning: "Reasoning", imageInput: "Image input", - table: "Price table", + table: "Automatic", + priceTable: "Price table", yes: "Yes", no: "No", fromTable: (n: string) => `Price table: ${n}`, - useTable: "Use the price table", - notInTable: "Not in the price table", + useTable: "Use automatic values", + fromUpstream: (n: string) => `Upstream: ${n}`, + notInTable: "No known value", bad: "A whole number above 0, at most 4294967295.", - removing: "Saving removes the manual values; all specs use the price table.", + removing: "Saving removes manual overrides and restores automatic values.", + effort: "Reasoning effort", + effortHelp: "Use the levels declared by the upstream automatically. Reasoning support does not always include adjustable effort; manual levels should match the upstream's actual capabilities.", + effortDisabled: "Reasoning is disabled. Saving removes reasoning choices from the catalog.", + noAdjustable: "Not adjustable", + manual: "Manual", + upstream: "Upstream", + unknown: "Unknown", + supportedLevels: "Supported levels", + chooseLevel: "Select at least one level, or choose Not adjustable.", + defaultLevel: "Default level", + defaultHelp: "Automatic prefers medium in the final available set, otherwise its lowest level.", + reported: "Reported by upstream", + savedEffective: "Saved levels for this upstream", + aliasEffortHelp: "Aliases offer only levels shared by every candidate; an unknown candidate leaves no confirmed choices. Codex also prefers the upstream catalog for its client version.", + filtered: (levels: string) => `The current protocol conversion cannot represent ${levels}; these choices are not offered to clients.`, + resetEffort: "Restore automatic effort", }, ); diff --git a/src/upstreams/ModelSpecDialog.tsx b/src/upstreams/ModelSpecDialog.tsx index 8b452d9a..5af3ef1c 100644 --- a/src/upstreams/ModelSpecDialog.tsx +++ b/src/upstreams/ModelSpecDialog.tsx @@ -10,30 +10,20 @@ import { DialogTitle, } from "@/ui/dialog"; import { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText } from "@/ui/input-group"; +import { Checkbox } from "@/ui/checkbox"; +import { NativeSelect, NativeSelectOption } from "@/ui/native-select"; import { Segmented } from "@/ui/segmented"; import { useText } from "@/i18n"; import { commonText } from "@/i18n/common.i18n"; -import type { ModelRow, SpecSource } from "@/types"; +import type { ModelRow, SpecSource, ReasoningEffort, ReasoningLevel } from "@/types"; import { api } from "./api"; import { modelsKey } from "./data"; import { errorText } from "./labels"; -import { isEmptySpec, manualOf, sameSpec, specOf, tokensOf, type SpecFlag } from "./modelSpec"; +import { effortOf, isEmptySpec, manualOf, sameSpec, specOf, tokensOf, toggleEffortLevel, REASONING_LEVELS, type EffortForm, type EffortMode, type SpecFlag } from "./modelSpec"; import { modelSpecDialogText } from "./ModelSpecDialog.i18n"; import { DialogError, FormItem } from "./parts"; -/** - * 手写一家上游的一个模型的上下文窗口、输出上限、推理、图片输入(`PUT /provider-model-spec`)。 - * - * 价目表不认识的中转站模型说不出上下文窗口,价目表写错的也有:这里写的只管这一家的 - * 这一个模型,写了就优先于价目表。**四项都不写就是删掉手写的**,回到价目表。 - * - * 格子里是手写的那个数;没手写的空着,占位写价目表给的数(没有就说价目表中没有)—— - * 留空是什么意思,看占位就知道。推理、图片输入是三段:价目表 / 支持 / 不支持,价目表怎么说 - * 写在下面一行。 - * - * 挂载方:上游表「模型」一格的弹窗(「规格…」)、编辑上游对话框的「模型」一节(上下文窗口 - * 那一格、行菜单的「规格…」)。对话框挂在弹窗外面:弹窗一收起,里面的东西就卸掉了。 - */ +/** Per-provider model overrides; automatic values are shown separately and never saved as overrides. */ export function ModelSpecDialog({ open, onOpenChange, @@ -55,7 +45,7 @@ export function ModelSpecDialog({ return ( {/* 点到对话框外面不关:填了一半的数不该因为一次误点丢掉。Esc、×、取消照常 */} - e.preventDefault()}> + e.preventDefault()}> {/* 内容只在开着时挂上:每次打开都从这一行此刻的值填起 */} {row && ( (null); @@ -99,11 +90,11 @@ function Body({ */ const [base] = useState(configVersion); - const spec = specOf({ context, output, reasoning, imageInput }); - /** 打开时的四项。打开时的值是 core 给的,一定写得对 */ + const spec = specOf({ context, output, reasoning, imageInput, effort }); + /** Compare with the manual values from when the dialog opened. */ const before = specOf(manual)!; const changed = spec !== undefined && !sameSpec(spec, before); - /** 原来手写过、现在四项都不写了:保存就是删掉,回到价目表 */ + /** All editable overrides are cleared; preserve advanced settings owned by Core. */ const removing = spec !== undefined && isEmptySpec(spec) && !isEmptySpec(before); async function save() { @@ -169,7 +160,10 @@ function Body({ { + setReasoning(next); + if (next === "no") setEffort(effortOf(null)); + }} table={row.reasoning} source={row.reasoning_source} /> @@ -182,6 +176,8 @@ function Body({ /> + + @@ -204,8 +200,9 @@ function Body({ function placeholderOf( value: number | null | undefined, source: SpecSource | null | undefined, - t: { fromTable: (n: string) => string; useTable: string; notInTable: string }, + t: { fromTable: (n: string) => string; fromUpstream: (n: string) => string; useTable: string; notInTable: string }, ): string { + if (source === "upstream" && value != null) return t.fromUpstream(value.toLocaleString()); if (source === "price_table" && value != null) return t.fromTable(value.toLocaleString()); if (source === "manual") return t.useTable; return t.notInTable; @@ -231,7 +228,8 @@ function FlagField({ }) { const t = useText(modelSpecDialogText); const desc = - source === "price_table" && table != null + source === "upstream" && table != null ? t.fromUpstream(table ? t.yes : t.no) + : source === "price_table" && table != null ? t.fromTable(table ? t.yes : t.no) : source === "manual" ? undefined @@ -292,3 +290,64 @@ function TokensField({ ); } + +function EffortField({ row, value, onChange, disabled }: { + row: ModelRow; value: EffortForm; onChange: (v: EffortForm) => void; disabled: boolean; +}) { + const t = useText(modelSpecDialogText); + const describe = (profile: ReasoningEffort | null | undefined) => { + if (profile == null) return t.unknown; + if (profile.supported_levels.length === 0) return t.noAdjustable; + return profile.supported_levels.join(" / ") + (profile.default_level ? ` · ${t.defaultLevel}: ${profile.default_level}` : ""); + }; + const source = row.reasoning_effort_source === "manual" ? t.manual + : row.reasoning_effort_source === "upstream" ? t.upstream + : row.reasoning_effort_source === "price_table" ? t.priceTable : t.unknown; + function mode(next: EffortMode) { + const levels = value.levels.length ? value.levels : [...(row.reported_reasoning_effort?.supported_levels ?? [])]; + onChange({ ...value, mode: next, levels }); + } + return ( +
+ + + label={t.effort} value={value.mode} disabled={disabled} onChange={mode} + options={[ + { id: "auto", label: t.table }, + { id: "none", label: t.noAdjustable }, + { id: "manual", label: t.manual }, + ]} + /> + + {!disabled && value.mode === "manual" && ( + <> +
+ {t.supportedLevels} +
+ {REASONING_LEVELS.map((level) => ( + + ))} +
+ {value.levels.length === 0 &&

{t.chooseLevel}

} +
+ + onChange({ ...value, defaultLevel: e.target.value as ReasoningLevel | "auto" })}> + {t.table} + {REASONING_LEVELS.filter((level) => value.levels.includes(level)).map((level) => {level})} + + + + )} +
+

{t.reported}: {describe(row.reported_reasoning_effort)}

+

{t.savedEffective}: {describe(row.reasoning_effort)} · {source}

+ {!!row.reasoning_effort_filtered_levels?.length &&

{t.filtered(row.reasoning_effort_filtered_levels.join(" / "))}

} + {row.aliases.length > 0 &&

{t.aliasEffortHelp}

} +
+ {value.mode !== "auto" && } +
+ ); +} diff --git a/src/upstreams/ModelsPanel.i18n.ts b/src/upstreams/ModelsPanel.i18n.ts index 494160f6..7090eaf0 100644 --- a/src/upstreams/ModelsPanel.i18n.ts +++ b/src/upstreams/ModelsPanel.i18n.ts @@ -43,6 +43,7 @@ export const modelsPanelText = messages( manualOutput: (n: string) => `输出上限 ${n}`, manualReasoning: (on: boolean): string => (on ? "支持推理" : "不支持推理"), manualImageInput: (on: boolean): string => (on ? "支持图片输入" : "不支持图片输入"), + manualEffort: (levels: string): string => levels ? `推理档位 ${levels}` : "推理强度不可调", listSep: ",", manualTitle: (what: string) => `手动设置:${what}`, }, @@ -90,6 +91,7 @@ export const modelsPanelText = messages( manualOutput: (n: string) => `max output ${n}`, manualReasoning: (on: boolean): string => (on ? "reasoning" : "no reasoning"), manualImageInput: (on: boolean): string => (on ? "image input" : "no image input"), + manualEffort: (levels: string): string => levels ? `reasoning levels ${levels}` : "reasoning effort not adjustable", listSep: ", ", manualTitle: (what: string) => `Set by hand: ${what}`, }, diff --git a/src/upstreams/ModelsPanel.tsx b/src/upstreams/ModelsPanel.tsx index 69637fb3..a8af097c 100644 --- a/src/upstreams/ModelsPanel.tsx +++ b/src/upstreams/ModelsPanel.tsx @@ -347,6 +347,7 @@ function Row({ : null, m.reasoning_source === "manual" && m.reasoning != null ? t.manualReasoning(m.reasoning) : null, m.image_input_source === "manual" && m.image_input != null ? t.manualImageInput(m.image_input) : null, + m.manual_reasoning_effort != null ? t.manualEffort(m.manual_reasoning_effort.supported_levels.join(" / ")) : null, ].filter((x): x is string => x !== null); // 右键和行尾「…」共用这一份 const items: MenuItems = [ diff --git a/src/upstreams/ShareDialog.i18n.ts b/src/upstreams/ShareDialog.i18n.ts index 1d851724..938f4733 100644 --- a/src/upstreams/ShareDialog.i18n.ts +++ b/src/upstreams/ShareDialog.i18n.ts @@ -51,6 +51,7 @@ export const shareDialogText = messages( routes: "路由", disabled: "停用状态", tiers: "200K 以上的分档价格", + reasoningEffort: "手动推理档位(请使用配置包分享)", rejected: (what: string) => `${what}(链接不接受其中的字符)`, }, /** 链接写不进去、去掉了的那一项 */ @@ -117,6 +118,7 @@ export const shareDialogText = messages( routes: "routes", disabled: "disabled state", tiers: "tiered prices above 200K", + reasoningEffort: "manual reasoning levels (use a config package to share them)", rejected: (what: string) => `${what} (characters links do not accept)`, }, params: { diff --git a/src/upstreams/modelSpec.test.ts b/src/upstreams/modelSpec.test.ts index 673bdb46..78cf3d15 100644 --- a/src/upstreams/modelSpec.test.ts +++ b/src/upstreams/modelSpec.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from "vitest"; import type { ModelRow } from "@/types"; import { catalogOf } from "./ModelsSection"; -import { MAX_SPEC_TOKENS, hasManual, isEmptySpec, manualOf, sameSpec, specOf, tokensOf } from "./modelSpec"; +import { MAX_SPEC_TOKENS, effortOf, toggleEffortLevel, hasManual, isEmptySpec, manualOf, sameSpec, specOf, tokensOf } from "./modelSpec"; function row(patch: Partial = {}): ModelRow { return { id: "glm-5-air", enabled: true, estimated: false, aliases: [], manual: false, listed: true, ...patch }; @@ -26,10 +26,10 @@ describe("模型规格", () => { max_output_tokens: 64_000, max_output_tokens_source: "price_table", }); - expect(manualOf(both)).toEqual({ context: "1000000", output: "", reasoning: "table", imageInput: "table" }); + expect(manualOf(both)).toEqual({ context: "1000000", output: "", reasoning: "table", imageInput: "table", effort: effortOf(null) }); expect(hasManual(both)).toBe(true); const table = row({ context_window: 200_000, context_window_source: "price_table" }); - expect(manualOf(table)).toEqual({ context: "", output: "", reasoning: "table", imageInput: "table" }); + expect(manualOf(table)).toEqual({ context: "", output: "", reasoning: "table", imageInput: "table", effort: effortOf(null) }); expect(hasManual(table)).toBe(false); expect(hasManual(row({ max_output_tokens: 16_384, max_output_tokens_source: "manual" }))).toBe(true); expect(hasManual(row())).toBe(false); @@ -42,7 +42,7 @@ describe("模型规格", () => { image_input: true, image_input_source: "price_table", }); - expect(manualOf(m)).toMatchObject({ reasoning: "no", imageInput: "table" }); + expect(manualOf(m)).toMatchObject({ reasoning: "no", imageInput: "table", effort: effortOf(null) }); expect(hasManual(m)).toBe(true); expect(manualOf(row({ image_input: true, image_input_source: "manual" })).imageInput).toBe("yes"); expect(hasManual(row({ image_input: true, image_input_source: "manual" }))).toBe(true); @@ -50,13 +50,14 @@ describe("模型规格", () => { }); it("表单 → 要存的四项:「价目表」和空格子是 null;数不对就不能存", () => { - expect(specOf({ context: "128,000", output: "", reasoning: "yes", imageInput: "no" })).toEqual({ + expect(specOf({ context: "128,000", output: "", reasoning: "yes", imageInput: "no", effort: effortOf(null) })).toEqual({ context_window: 128_000, max_output_tokens: null, reasoning: true, image_input: false, + reasoning_effort: { mode: "auto" }, }); - expect(specOf({ context: "128k", output: "", reasoning: "yes", imageInput: "table" })).toBeUndefined(); + expect(specOf({ context: "128k", output: "", reasoning: "yes", imageInput: "table", effort: effortOf(null) })).toBeUndefined(); // 回填再转回去,和 core 给的是同一份 const m = row({ context_window: 200_000, @@ -71,22 +72,23 @@ describe("模型规格", () => { max_output_tokens: 32_000, reasoning: true, image_input: null, + reasoning_effort: { mode: "auto" }, }); }); it("四项都不写就是删掉;只要有一项写了就不是", () => { - const empty = specOf({ context: "", output: " ", reasoning: "table", imageInput: "table" })!; + const empty = specOf({ context: "", output: " ", reasoning: "table", imageInput: "table", effort: effortOf(null) })!; expect(isEmptySpec(empty)).toBe(true); for (const f of [ - { context: "1", output: "", reasoning: "table", imageInput: "table" }, - { context: "", output: "", reasoning: "no", imageInput: "table" }, - { context: "", output: "", reasoning: "table", imageInput: "yes" }, + { context: "1", output: "", reasoning: "table", imageInput: "table", effort: effortOf(null) }, + { context: "", output: "", reasoning: "no", imageInput: "table", effort: effortOf(null) }, + { context: "", output: "", reasoning: "table", imageInput: "yes", effort: effortOf(null) }, ] as const) expect(isEmptySpec(specOf(f)!)).toBe(false); // 千分位写法不同不算改了;是非项换了算 - const a = specOf({ context: "128,000", output: "", reasoning: "table", imageInput: "table" })!; - expect(sameSpec(a, specOf({ context: "128000", output: "", reasoning: "table", imageInput: "table" })!)).toBe(true); - expect(sameSpec(a, specOf({ context: "128000", output: "", reasoning: "no", imageInput: "table" })!)).toBe(false); + const a = specOf({ context: "128,000", output: "", reasoning: "table", imageInput: "table", effort: effortOf(null) })!; + expect(sameSpec(a, specOf({ context: "128000", output: "", reasoning: "table", imageInput: "table", effort: effortOf(null) })!)).toBe(true); + expect(sameSpec(a, specOf({ context: "128000", output: "", reasoning: "no", imageInput: "table", effort: effortOf(null) })!)).toBe(false); }); it("编辑对话框的模型一节:手写的上下文窗口和弹窗里是同一个数", () => { @@ -104,3 +106,47 @@ describe("模型规格", () => { expect(c.manualContext).toEqual({ a: 128_000 }); }); }); + + +describe("推理档位覆盖", () => { + const form = (effort = effortOf(null)) => ({ context: "", output: "", reasoning: "table" as const, imageInput: "table" as const, effort }); + + it("自动发现的档位只作参考,不写成手动配置", () => { + const m = row({ reasoning: true, reasoning_source: "upstream", reasoning_effort: { supported_levels: ["low", "high"], default_level: "high" }, reasoning_effort_source: "upstream" }); + expect(specOf(manualOf(m))?.reasoning_effort).toEqual({ mode: "auto" }); + expect(hasManual(m)).toBe(false); + }); + + it("手动原值回填时不固化自动默认值和由档位推导的推理支持", () => { + const m = row({ reasoning: true, reasoning_source: "manual", manual_reasoning_effort: { supported_levels: ["high", "low"] }, reasoning_effort: { supported_levels: ["low", "high"], default_level: "low" }, reasoning_effort_source: "manual" }); + const saved = specOf(manualOf(m))!; + expect(saved.reasoning).toBeNull(); + expect(saved.reasoning_effort).toEqual({ mode: "set", value: { supported_levels: ["low", "high"] } }); + expect(hasManual(m)).toBe(true); + expect(isEmptySpec(saved)).toBe(false); + }); + + it("未知、明确不可调和手动档位分别保存,恢复自动会明确移除覆盖", () => { + expect(specOf(form())?.reasoning_effort).toEqual({ mode: "auto" }); + const none = specOf(form(effortOf({ supported_levels: [] })))!; + expect(none.reasoning_effort).toEqual({ mode: "set", value: { supported_levels: [] } }); + expect(isEmptySpec(none)).toBe(false); + expect(sameSpec(none, specOf(form())!)).toBe(false); + const manual = specOf(form(effortOf({ supported_levels: ["high"], default_level: "high" })))!; + expect(manual.reasoning_effort).toEqual({ mode: "set", value: { supported_levels: ["high"], default_level: "high" } }); + }); + + it("空手动列表、重复档位、无效默认值和关闭推理的矛盾配置不能保存", () => { + for (const effort of [ + { mode: "manual" as const, levels: [], defaultLevel: "auto" as const }, + { mode: "manual" as const, levels: ["high", "high"] as ("high")[], defaultLevel: "auto" as const }, + { mode: "manual" as const, levels: ["low"] as ("low")[], defaultLevel: "high" as const }, + ]) expect(specOf(form(effort))).toBeUndefined(); + expect(specOf({ ...form(effortOf({ supported_levels: ["high"] })), reasoning: "no" })).toBeUndefined(); + }); + + it("去掉默认档位时恢复自动选择,不留下已不支持的默认值", () => { + expect(toggleEffortLevel(effortOf({ supported_levels: ["low", "high"], default_level: "high" }), "high")) + .toEqual({ mode: "manual", levels: ["low"], defaultLevel: "auto" }); + }); +}); diff --git a/src/upstreams/modelSpec.ts b/src/upstreams/modelSpec.ts index 9130caa5..171da83e 100644 --- a/src/upstreams/modelSpec.ts +++ b/src/upstreams/modelSpec.ts @@ -1,17 +1,9 @@ -/** - * 手写的模型规格(上下文窗口、输出上限、推理、图片输入):从 `ModelRow` 读出手写的那几项、 - * 格子里的数写得对不对、表单怎么变成要存的四项。**先后只在 core 定** - * (`tw_config::model_specs::resolve`):这里只认 core 标的来源,不自己比大小。 - */ -import type { ModelRow, ModelSpecSave } from "@/types"; +/** Manual overrides only. Core resolves upstream metadata, sources and protocol restrictions. */ +import type { ModelRow, ModelSpecSave, ReasoningEffort, ReasoningLevel } from "@/types"; -/** 一项最多写多少:core 存的是 `u32` */ export const MAX_SPEC_TOKENS = 4_294_967_295; +export const REASONING_LEVELS: readonly ReasoningLevel[] = ["minimal", "low", "medium", "high", "xhigh", "max", "ultra"]; -/** - * 格子里的 token 数。空是不写(`null`,用价目表的);写的不是 1 到 `u32` 上限的整数是 - * `undefined`。千分位的逗号、空格、下划线照常认:`128,000` 和 `128000` 是同一个数。 - */ export function tokensOf(v: string): number | null | undefined { const s = v.replace(/[\s,_]/g, ""); if (s === "") return null; @@ -20,65 +12,84 @@ export function tokensOf(v: string): number | null | undefined { return n >= 1 && n <= MAX_SPEC_TOKENS ? n : undefined; } -/** 推理、图片输入这类是非项的三个选择:用价目表的、手写「支持」、手写「不支持」 */ export type SpecFlag = "table" | "yes" | "no"; +export type EffortMode = "auto" | "none" | "manual"; +export type EffortForm = { mode: EffortMode; levels: ReasoningLevel[]; defaultLevel: ReasoningLevel | "auto" }; +export type SpecForm = { + context: string; + output: string; + reasoning: SpecFlag; + imageInput: SpecFlag; + effort: EffortForm; +}; -/** 对话框里的四项。数是格子里的原文,是非项是选中的那一段 */ -export type SpecForm = { context: string; output: string; reasoning: SpecFlag; imageInput: SpecFlag }; +export function effortOf(value: ReasoningEffort | null | undefined): EffortForm { + return { + mode: value == null ? "auto" : value.supported_levels.length === 0 ? "none" : "manual", + levels: [...(value?.supported_levels ?? [])], + defaultLevel: value?.default_level ?? "auto", + }; +} -/** 手写的是非项在表单里的选择。没手写(来自价目表或不知道)就是「价目表」 */ -function flagOf(value: boolean | null | undefined, source: ModelRow["reasoning_source"]): SpecFlag { - if (source !== "manual" || value == null) return "table"; - return value ? "yes" : "no"; +export function toggleEffortLevel(form: EffortForm, level: ReasoningLevel): EffortForm { + const levels = REASONING_LEVELS.filter((v) => v === level ? !form.levels.includes(v) : form.levels.includes(v)); + return { ...form, levels, defaultLevel: form.defaultLevel !== "auto" && !levels.includes(form.defaultLevel) ? "auto" : form.defaultLevel }; +} + +function flagOf(value: boolean | null | undefined): SpecFlag { + return value == null ? "table" : value ? "yes" : "no"; } -/** 选择 → 要存的值。「价目表」是不写(`null`) */ function flagValue(f: SpecFlag): boolean | null { return f === "table" ? null : f === "yes"; } -/** 这个模型此刻手写的几项,表单里的写法。没手写的数是空的、是非项是「价目表」 */ export function manualOf(m: ModelRow): SpecForm { return { context: m.context_window_source === "manual" && m.context_window != null ? String(m.context_window) : "", output: m.max_output_tokens_source === "manual" && m.max_output_tokens != null ? String(m.max_output_tokens) : "", - reasoning: flagOf(m.reasoning, m.reasoning_source), - imageInput: flagOf(m.image_input, m.image_input_source), + // Nonempty manual effort implies reasoning, but must not become a saved boolean override. + reasoning: flagOf(m.manual_reasoning ?? (m.manual_reasoning_effort == null && m.reasoning_source === "manual" ? m.reasoning : null)), + imageInput: flagOf(m.image_input_source === "manual" ? m.image_input : null), + effort: effortOf(m.manual_reasoning_effort), }; } -/** 要存的四项。**四项都是 `null` 就是删掉手写的**,回到价目表 */ -export type SpecValues = Required>; +export type SpecValues = Required>; -/** 表单 → 要存的四项。数写得不对时是 `undefined`,不能存 */ export function specOf(f: SpecForm): SpecValues | undefined { const context_window = tokensOf(f.context); const max_output_tokens = tokensOf(f.output); if (context_window === undefined || max_output_tokens === undefined) return undefined; - return { context_window, max_output_tokens, reasoning: flagValue(f.reasoning), image_input: flagValue(f.imageInput) }; + const { mode, levels, defaultLevel } = f.effort; + if (mode === "manual" && ( + f.reasoning === "no" || levels.length === 0 || new Set(levels).size !== levels.length || + levels.some((level) => !REASONING_LEVELS.includes(level)) || + (defaultLevel !== "auto" && !levels.includes(defaultLevel)) + )) return undefined; + return { + context_window, max_output_tokens, reasoning: flagValue(f.reasoning), image_input: flagValue(f.imageInput), + reasoning_effort: mode === "auto" ? { mode: "auto" } : { + mode: "set", + value: { + supported_levels: mode === "none" ? [] : REASONING_LEVELS.filter((level) => levels.includes(level)), + ...(mode === "manual" && defaultLevel !== "auto" ? { default_level: defaultLevel } : {}), + }, + }, + }; } -/** 四项都不写:存下去就是删掉这个模型手写的规格 */ export function isEmptySpec(v: SpecValues): boolean { - return v.context_window === null && v.max_output_tokens === null && v.reasoning === null && v.image_input === null; + return v.context_window === null && v.max_output_tokens === null && v.reasoning === null && v.image_input === null && v.reasoning_effort.mode === "auto"; } -/** 两份要存的四项是不是一样(格子里 `128,000` 和 `128000` 算一样) */ export function sameSpec(a: SpecValues, b: SpecValues): boolean { - return ( - a.context_window === b.context_window && - a.max_output_tokens === b.max_output_tokens && - a.reasoning === b.reasoning && - a.image_input === b.image_input - ); + return a.context_window === b.context_window && a.max_output_tokens === b.max_output_tokens && + a.reasoning === b.reasoning && a.image_input === b.image_input && + JSON.stringify(a.reasoning_effort) === JSON.stringify(b.reasoning_effort); } -/** 这个模型在这一家有手写的规格 */ export function hasManual(m: ModelRow): boolean { - return ( - m.context_window_source === "manual" || - m.max_output_tokens_source === "manual" || - m.reasoning_source === "manual" || - m.image_input_source === "manual" - ); + return m.context_window_source === "manual" || m.max_output_tokens_source === "manual" || + m.reasoning_source === "manual" || m.image_input_source === "manual" || m.manual_reasoning_effort != null; } diff --git a/src/upstreams/share.test.ts b/src/upstreams/share.test.ts index 7a1dc119..e72a6281 100644 --- a/src/upstreams/share.test.ts +++ b/src/upstreams/share.test.ts @@ -228,3 +228,12 @@ describe("分享上游:链接里的提议", () => { expect(dropParam(proposal, "service")).toBeNull(); }); }); + + +it("分享链接明确列出未包含的手动档位,不把自动档位写成手动配置", () => { + const manual = shareProposal(view(), { ...NONE, models: [{ id: "private", enabled: true, estimated: false, aliases: [], manual: true, listed: false, manual_reasoning_effort: { supported_levels: ["high"] } }] }, false); + expect(manual.left).toContain("reasoningEffort"); + const automatic = shareProposal(view(), { ...NONE, models: [{ id: "private", enabled: true, estimated: false, aliases: [], manual: false, listed: true, reasoning_effort: { supported_levels: ["high"] }, reasoning_effort_source: "upstream" }] }, false); + expect(automatic.left).not.toContain("reasoningEffort"); + expect(automatic.proposal.specs).toEqual([]); +}); diff --git a/src/upstreams/share.ts b/src/upstreams/share.ts index 7db0816e..b74eca1d 100644 --- a/src/upstreams/share.ts +++ b/src/upstreams/share.ts @@ -45,7 +45,8 @@ export type Left = | "proxy" | "routes" | "disabled" - | "tiers"; + | "tiers" + | "reasoningEffort"; export interface Shared { proposal: ImportProposal; @@ -109,6 +110,7 @@ function sheetOf(s: PriceSheetInput | null): { sheet: ImportSheet | null; tiers: export function shareProposal(p: ProviderView, extra: ShareExtra, secrets: boolean): Shared { const f = formFromView(p); const left = new Set(); + if (extra.models?.some((row) => row.manual_reasoning_effort != null)) left.add("reasoningEffort"); const chatgpt = p.protocol === "chatgpt"; let auth: ImportAuth; if (chatgpt || f.authMode === "account") {