fix(models): show custom provider models in combo picker
Merge customModels from /api/models/custom into the isCustomProvider branch so custom compatible providers display imported models instead of the prefix/model-id placeholder. Mirrors the passthrough pattern; filter by providerId since providerAlias stores the raw provider ID. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -249,9 +249,22 @@ export default function ModelSelectModal({
|
|||||||
value: `${nodePrefix}/${fullModel.replace(`${providerId}/`, "")}`,
|
value: `${nodePrefix}/${fullModel.replace(`${providerId}/`, "")}`,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// Merge custom models registered via /api/models/custom for this provider
|
||||||
|
// providerAlias in DB uses the raw providerId, not the display prefix
|
||||||
|
const registeredCustom = customModels
|
||||||
|
.filter((m) => m.providerAlias === providerId)
|
||||||
|
.map((m) => ({
|
||||||
|
id: m.id,
|
||||||
|
name: m.name || m.id,
|
||||||
|
value: `${nodePrefix}/${m.id}`,
|
||||||
|
isCustom: true,
|
||||||
|
}));
|
||||||
|
const seen = new Set(nodeModels.map((m) => m.value));
|
||||||
|
const mergedModels = [...nodeModels, ...registeredCustom.filter((m) => !seen.has(m.value))];
|
||||||
|
|
||||||
// Always show compatible providers that are connected, even with no aliases.
|
// Always show compatible providers that are connected, even with no aliases.
|
||||||
// When no aliases exist, show a placeholder so users know it's available.
|
// When no aliases exist, show a placeholder so users know it's available.
|
||||||
const modelsToShow = nodeModels.length > 0 ? nodeModels : [{
|
const modelsToShow = mergedModels.length > 0 ? mergedModels : [{
|
||||||
id: `__placeholder__${providerId}`,
|
id: `__placeholder__${providerId}`,
|
||||||
name: `${nodePrefix}/model-id`,
|
name: `${nodePrefix}/model-id`,
|
||||||
value: `${nodePrefix}/model-id`,
|
value: `${nodePrefix}/model-id`,
|
||||||
@@ -264,7 +277,7 @@ export default function ModelSelectModal({
|
|||||||
color: providerInfo.color,
|
color: providerInfo.color,
|
||||||
models: modelsToShow,
|
models: modelsToShow,
|
||||||
isCustom: true,
|
isCustom: true,
|
||||||
hasModels: nodeModels.length > 0,
|
hasModels: mergedModels.length > 0,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const hardcodedModels = getModelsByProviderId(providerId);
|
const hardcodedModels = getModelsByProviderId(providerId);
|
||||||
|
|||||||
Reference in New Issue
Block a user