feat(models): 最大输出未匹配 models.dev 时回填默认值 131072(打开编辑页一次性回填 + 获取模型列表预填同口径)

This commit is contained in:
KimiSwitch Dev committed 2026-10-04 00:51:50 +08:00
1 parent 24cb04b98f
commit ef6749b208
1 file changed
+22 -9
+22 -9
View File
@@ -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
),
}
: {}),
});
}