Fix : Add custom to model selector

This commit is contained in:
decolua 2026-03-11 11:59:07 +07:00
parent a501c05969
commit d9dad5bcf3
8 changed files with 699 additions and 451 deletions

View file

@ -139,17 +139,32 @@ export default function ModelSelectModal({
hasModels: nodeModels.length > 0,
};
} else {
const models = getModelsByProviderId(providerId);
if (models.length > 0) {
const hardcodedModels = getModelsByProviderId(providerId);
const hardcodedIds = new Set(hardcodedModels.map((m) => m.id));
// Custom models user added via "Add Model" button (alias === modelId pattern)
const customModels = Object.entries(modelAliases)
.filter(([aliasName, fullModel]) =>
fullModel.startsWith(`${alias}/`) &&
aliasName === fullModel.replace(`${alias}/`, "") &&
!hardcodedIds.has(fullModel.replace(`${alias}/`, ""))
)
.map(([, fullModel]) => {
const modelId = fullModel.replace(`${alias}/`, "");
return { id: modelId, name: modelId, value: fullModel, isCustom: true };
});
const allModels = [
...hardcodedModels.map((m) => ({ id: m.id, name: m.name, value: `${alias}/${m.id}` })),
...customModels,
];
if (allModels.length > 0) {
groups[providerId] = {
name: providerInfo.name,
alias: alias,
color: providerInfo.color,
models: models.map((m) => ({
id: m.id,
name: m.name,
value: `${alias}/${m.id}`,
})),
models: allModels,
};
}
}
@ -299,6 +314,11 @@ export default function ModelSelectModal({
<span className="material-symbols-outlined text-[11px]">edit</span>
{model.name}
</span>
) : model.isCustom ? (
<span className="flex items-center gap-1">
{model.name}
<span className="text-[9px] opacity-60 font-normal">custom</span>
</span>
) : model.name}
</button>
);