From ef6749b2080484830684185f12039a13fa85ae54 Mon Sep 17 00:00:00 2001 From: KimiSwitch Dev Date: Sun, 4 Oct 2026 00:51:50 +0800 Subject: [PATCH] =?UTF-8?q?feat(models):=20=E6=9C=80=E5=A4=A7=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E6=9C=AA=E5=8C=B9=E9=85=8D=20models.dev=20=E6=97=B6?= =?UTF-8?q?=E5=9B=9E=E5=A1=AB=E9=BB=98=E8=AE=A4=E5=80=BC=20131072=EF=BC=88?= =?UTF-8?q?=E6=89=93=E5=BC=80=E7=BC=96=E8=BE=91=E9=A1=B5=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=E6=80=A7=E5=9B=9E=E5=A1=AB=20+=20=E8=8E=B7=E5=8F=96=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E5=88=97=E8=A1=A8=E9=A2=84=E5=A1=AB=E5=90=8C=E5=8F=A3?= =?UTF-8?q?=E5=BE=84=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ProviderEdit.tsx | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/components/ProviderEdit.tsx b/src/components/ProviderEdit.tsx index 229d345..2ad0a58 100644 --- a/src/components/ProviderEdit.tsx +++ b/src/components/ProviderEdit.tsx @@ -39,6 +39,9 @@ const CAPABILITY_LABELS: Record< tool_use: "capToolUse", }; +/** Fallback max-output cap (128K) for models models.dev doesn't know. */ +const FALLBACK_MAX_OUTPUT = 131_072; + const PROVIDER_TYPES: ProviderType[] = [ "openai", "openai_responses", @@ -577,8 +580,9 @@ function ModelMapping({ // the max-output "参考" hints appear even when this panel mounted first. const [, forceModelsDevReady] = useReducer((x: number) => x + 1, 0); // One-shot backfill: models with no max_output_size yet get the models.dev - // `output` cap filled in automatically. onModelChange only mutates the - // in-memory config — the user still reviews and presses 保存配置. + // `output` cap, or the 128K fallback when nothing matches. onModelChange + // only mutates the in-memory config — the user still reviews and presses + // 保存配置. const backfillDone = useRef(false); const modelsRef = useRef(models); modelsRef.current = models; @@ -591,8 +595,12 @@ function ModelMapping({ backfillDone.current = true; for (const m of modelsRef.current) { if (readMaxOutputSize(m.raw_other) !== undefined) continue; - const output = getModelRef(m.model)?.output; - if (output !== undefined) onModelChange(withMaxOutputSize(m, output)); + onModelChange( + withMaxOutputSize( + m, + getModelRef(m.model)?.output ?? FALLBACK_MAX_OUTPUT + ) + ); } }); return () => { @@ -669,11 +677,16 @@ function ModelMapping({ : fetchThinking ? ["thinking"] : [], - // Seed the max_output_size override only when models.dev knows the - // cap — an absent key means the upstream default applies. kimi_code - // only: Pi's equivalent is `maxTokens` (not written by this UI). - ...(agent === "kimi_code" && ref?.output - ? { raw_other: setMaxOutputSize(undefined, ref.output) } + // Seed the max_output_size override with the models.dev cap, falling + // back to 128K when nothing matches. kimi_code only: Pi's equivalent + // is `maxTokens` (not written by this UI). + ...(agent === "kimi_code" + ? { + raw_other: setMaxOutputSize( + undefined, + ref?.output ?? FALLBACK_MAX_OUTPUT + ), + } : {}), }); }