Skip to content

Commit e0c26f5

Browse files
committed
fix(bailian): show correct model params for auto-fetched models in UI (#420)(#421)
- useSelectedModel bailian case: look up routerModels.bailian first, then static presets (same pattern as deepseek). - ModelPicker: add optional sortModels prop for custom dropdown ordering. - Bailian.tsx: pass sortModels that puts preset models (bailianModels) above API-fetched models, then alphabetical within each group.
1 parent 141b567 commit e0c26f5

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

webview-ui/src/components/settings/ModelPicker.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ interface ModelPickerProps {
6868
onModelChange?: (modelId: string) => void
6969
/** Hide the "search free" hint in the automatic fetch message (for providers without free models) */
7070
hideFreeSearchHint?: boolean
71+
/** Optional custom sort for the model dropdown. Defaults to alphabetical (localeCompare). */
72+
sortModels?: (a: string, b: string) => number
7173
}
7274

7375
export const ModelPicker = ({
@@ -87,6 +89,7 @@ export const ModelPicker = ({
8789
displayTransform,
8890
onModelChange,
8991
hideFreeSearchHint,
92+
sortModels,
9093
}: ModelPickerProps) => {
9194
const { t } = useAppTranslation()
9295

@@ -134,7 +137,7 @@ export const ModelPicker = ({
134137
{} as Record<string, ModelInfo>,
135138
)
136139

137-
return Object.keys(availableModels).sort((a, b) => a.localeCompare(b))
140+
return Object.keys(availableModels).sort(sortModels ?? ((a, b) => a.localeCompare(b)))
138141
}, [models, activeProvider, organizationAllowList, selectedModelId])
139142

140143
const [searchValue, setSearchValue] = useState("")

webview-ui/src/components/settings/providers/Bailian.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ export const Bailian = ({
145145
errorMessage={modelValidationError}
146146
simplifySettings={simplifySettings}
147147
hideFreeSearchHint={true}
148+
sortModels={(a, b) => {
149+
const aPreset = Object.hasOwn(bailianModels, a)
150+
const bPreset = Object.hasOwn(bailianModels, b)
151+
if (aPreset !== bPreset) return aPreset ? -1 : 1
152+
return a.localeCompare(b)
153+
}}
148154
onModelChange={(newModelId) =>
149155
handleModelChangeSideEffects("bailian", newModelId, setApiConfigurationField)
150156
}

webview-ui/src/components/ui/hooks/useSelectedModel.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,19 @@ function getSelectedModel({
292292
}
293293
case "bailian": {
294294
const id = apiConfiguration.apiModelId ?? defaultModelId
295-
const baseInfo = bailianModels[id as keyof typeof bailianModels]
296-
// Custom models: merge default model info with bailianCustomModelInfo,
297-
// matching the API handler's getModel() fallback.
298-
// Note: supportsReasoningBinary is inherited from the default model
299-
// (qwen3.6-plus). Custom models that do not support enable_thinking
300-
// should disable reasoning via the UI checkbox.
295+
// Look up in routerModels (API-fetched) first, then static presets.
296+
// This ensures auto-fetched models show their actual parameters
297+
// instead of falling back to the default model's metadata.
298+
// Follows the same pattern as the deepseek case.
299+
const routerInfo = routerModels.bailian?.[id]
300+
const staticInfo = bailianModels[id as keyof typeof bailianModels]
301+
const baseInfo = routerInfo ?? staticInfo
302+
// Custom models (typed by user, not in any source): merge
303+
// default model info with bailianCustomModelInfo, matching
304+
// the API handler's getModel() fallback.
305+
// Note: supportsReasoningBinary is inherited from the default
306+
// model (qwen3.6-plus). Custom models that do not support
307+
// enable_thinking should disable reasoning via the UI checkbox.
301308
const effectiveInfo = baseInfo ?? {
302309
...bailianModels[defaultModelId as keyof typeof bailianModels],
303310
...(apiConfiguration.bailianCustomModelInfo || {}),

0 commit comments

Comments
 (0)