feat(omo): add preset model variants for thinking level support

Add OPENCODE_PRESET_MODEL_VARIANTS constant with variant definitions
for Google, OpenAI, and Anthropic models. The omoModelVariantsMap
builder now falls back to presets when config-defined variants are
absent, enabling the variant selector for supported models.
This commit is contained in:
YoVinchen
2026-02-11 17:48:41 +08:00
parent d9f380d0fd
commit 3e9b3d0031
3 changed files with 275 additions and 1 deletions
@@ -273,6 +273,8 @@ export function OmoFormFields({
currentVariant,
);
const hasModel = Boolean(currentModel);
const hasVariants =
hasModel && (modelVariantsMap[currentModel] || []).length > 0;
const firstIsUnavailable =
Boolean(currentVariant) &&
!(modelVariantsMap[currentModel] || []).includes(currentVariant);
@@ -283,7 +285,7 @@ export function OmoFormFields({
onValueChange={(value) =>
onChange(value === EMPTY_VARIANT_VALUE ? "" : value)
}
disabled={!hasModel}
disabled={!hasModel || !hasVariants}
>
<SelectTrigger className="w-32 h-8 text-xs shrink-0">
<SelectValue
@@ -31,6 +31,7 @@ import {
} from "@/config/geminiProviderPresets";
import {
opencodeProviderPresets,
OPENCODE_PRESET_MODEL_VARIANTS,
type OpenCodeProviderPreset,
} from "@/config/opencodeProviderPresets";
import { OpenCodeFormFields } from "./OpenCodeFormFields";
@@ -695,6 +696,25 @@ export function ProviderForm({
}
variantsMap[`${providerKey}/${modelId}`] = variantKeys;
}
// Preset fallback: for models without config-defined variants,
// check if the npm package has preset variant definitions
const presetModels = OPENCODE_PRESET_MODEL_VARIANTS[parsedConfig.npm];
if (presetModels) {
for (const modelId of Object.keys(parsedConfig.models || {})) {
const fullKey = `${providerKey}/${modelId}`;
if (variantsMap[fullKey]) {
continue;
}
const preset = presetModels.find((p) => p.id === modelId);
if (preset?.variants) {
const presetKeys = Object.keys(preset.variants).filter(Boolean);
if (presetKeys.length > 0) {
variantsMap[fullKey] = presetKeys;
}
}
}
}
}
return variantsMap;