Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

handle hidden models more elegantly.

Forhad Hosain9bd2d19f0738
diff --git a/packages/app/src/backend/services/LLMHelper/index.ts b/packages/app/src/backend/services/LLMHelper/index.ts
index e5bcd08f..d9bbdea4 100644
--- a/packages/app/src/backend/services/LLMHelper/index.ts
+++ b/packages/app/src/backend/services/LLMHelper/index.ts
@@ -18,13 +18,21 @@ async function getUserLLMModels(req: Request) {
const keys: any = await vault.get({ team, scope: ['global'] }, req);
const enabledSmythOSProviders = await _getEnabledSmythOSProviders(req);
- for (let modelId in LLMModels) {
- let modelTpl = JSON.parse(JSON.stringify(LLMModels[modelId]));
+ for (let modelEntryId in LLMModels) {
+ let modelTpl = JSON.parse(JSON.stringify(LLMModels[modelEntryId]));
if (modelTpl.alias) {
const aliasOptions = JSON.parse(JSON.stringify(LLMModels[modelTpl.alias] || {}));
delete aliasOptions.hidden; //do not override hide option because we may want to hide the original model but keep the alias
- modelTpl = { ...modelTpl, ...aliasOptions }; //override the model config with the alias config
+
+ const aliasOverrides = {
+ label: modelTpl.label,
+ modelId: modelTpl.modelId,
+ tags: modelTpl.tags,
+ };
+
+ modelTpl = { ...modelTpl, ...aliasOptions, ...aliasOverrides }; //override the model config with the alias config
+ modelTpl.tags.push('alias: ' + modelTpl.alias);
}
// get the key options
@@ -40,17 +48,17 @@ async function getUserLLMModels(req: Request) {
}
let enabled =
- typeof LLMModels[modelId].enabled === 'function'
- ? LLMModels[modelId].enabled({ user: req.user, team: req._team })
+ typeof LLMModels[modelEntryId].enabled === 'function'
+ ? LLMModels[modelEntryId].enabled({ user: req.user, team: req._team })
: modelTpl.enabled;
// Skip legacy models for users with built-in model access to avoid confusion
- if (_hasBuiltInModels(req) && modelId.startsWith('legacy/')) {
+ if (_hasBuiltInModels(req) && modelEntryId.startsWith('legacy/')) {
enabled = false;
}
// V2: only applicable for GenAI LLM and SmythOS models
- if (modelId.startsWith('smythos/')) {
+ if (modelEntryId.startsWith('smythos/')) {
enabled = enabled && enabledSmythOSProviders.includes(modelTpl?.provider?.toLowerCase());
}
@@ -60,11 +68,11 @@ async function getUserLLMModels(req: Request) {
}
// Hide DALL-E models from users with builtin models
- if (_hasBuiltInModels(req) && modelId.startsWith('dall-e')) {
+ if (_hasBuiltInModels(req) && modelEntryId.startsWith('dall-e')) {
enabled = false;
}
- if (!enabled || modelTpl.hidden || (!modelTpl?.components && !modelTpl?.features)) {
+ if (!enabled || (!modelTpl?.components && !modelTpl?.features)) {
continue;
}
@@ -74,10 +82,9 @@ async function getUserLLMModels(req: Request) {
}
delete modelTpl.enabled;
- delete modelTpl.hidden;
delete modelTpl.alias;
- models[modelId] = modelTpl;
+ models[modelEntryId] = modelTpl;
}
} catch (error) {
console.error('Error getting User LLMs', error?.message);
diff --git a/packages/app/src/builder-ui/components/AgentPlugin.class.ts b/packages/app/src/builder-ui/components/AgentPlugin.class.ts
index e5a57360..79e11a40 100644
--- a/packages/app/src/builder-ui/components/AgentPlugin.class.ts
+++ b/packages/app/src/builder-ui/components/AgentPlugin.class.ts
@@ -88,7 +88,15 @@ export class AgentPlugin extends Component {
}
//remove undefined models
- this.modelOptions = modelOptions.filter((e) => e);
+ this.modelOptions = modelOptions.filter((item) => {
+ if (!item) return false;
+
+ // Keep the currently selected model even if it's hidden
+ if (item?.value === model) return true;
+
+ // Otherwise, filter out hidden models
+ return !item?.hidden;
+ });
return true;
}
diff --git a/packages/app/src/builder-ui/components/GPTPlugin.class.ts b/packages/app/src/builder-ui/components/GPTPlugin.class.ts
index 605eb8b4..5e6343cb 100644
--- a/packages/app/src/builder-ui/components/GPTPlugin.class.ts
+++ b/packages/app/src/builder-ui/components/GPTPlugin.class.ts
@@ -47,7 +47,15 @@ export class GPTPlugin extends Component {
}
//remove undefined models
- this.modelOptions = modelOptions.filter((e) => e);
+ this.modelOptions = modelOptions.filter((item) => {
+ if (!item) return false;
+
+ // Keep the currently selected model even if it's hidden
+ if (item?.value === model) return true;
+
+ // Otherwise, filter out hidden models
+ return !item?.hidden;
+ });
return true;
}
diff --git a/packages/app/src/builder-ui/components/GenAILLM.class.ts b/packages/app/src/builder-ui/components/GenAILLM.class.ts
index a91542eb..88c25467 100644
--- a/packages/app/src/builder-ui/components/GenAILLM.class.ts
+++ b/packages/app/src/builder-ui/components/GenAILLM.class.ts
@@ -101,7 +101,15 @@ export class GenAILLM extends Component {
// TODO: set warning if the model is not available
//remove undefined models
- this.modelOptions = modelOptions.filter((e) => e);
+ this.modelOptions = modelOptions.filter((item) => {
+ if (!item) return false;
+
+ // Keep the currently selected model even if it's hidden
+ if (item?.value === model) return true;
+
+ // Otherwise, filter out hidden models
+ return !item?.hidden;
+ });
this.setModelParams(model);
diff --git a/packages/app/src/builder-ui/components/ImageGenerator.class.ts b/packages/app/src/builder-ui/components/ImageGenerator.class.ts
index aa6505ca..5695cfd3 100644
--- a/packages/app/src/builder-ui/components/ImageGenerator.class.ts
+++ b/packages/app/src/builder-ui/components/ImageGenerator.class.ts
@@ -37,7 +37,15 @@ export class ImageGenerator extends Component {
// TODO: set warning if the model is not available
//remove undefined models
- this.modelOptions = modelOptions.filter((e) => e);
+ this.modelOptions = modelOptions.filter((item) => {
+ if (!item) return false;
+
+ // Keep the currently selected model even if it's hidden
+ if (item?.value === model) return true;
+
+ // Otherwise, filter out hidden models
+ return !item?.hidden;
+ });
return true;
}
diff --git a/packages/app/src/builder-ui/components/LLMAssistant.class.ts b/packages/app/src/builder-ui/components/LLMAssistant.class.ts
index 8113a410..d83f6f36 100644
--- a/packages/app/src/builder-ui/components/LLMAssistant.class.ts
+++ b/packages/app/src/builder-ui/components/LLMAssistant.class.ts
@@ -29,7 +29,15 @@ export class LLMAssistant extends Component {
// TODO: set warning if the model is not available
//remove undefined models
- this.modelOptions = modelOptions.filter((e) => e);
+ this.modelOptions = modelOptions.filter((item) => {
+ if (!item) return false;
+
+ // Keep the currently selected model even if it's hidden
+ if (item?.value === model) return true;
+
+ // Otherwise, filter out hidden models
+ return !item?.hidden;
+ });
return true;
}
diff --git a/packages/app/src/builder-ui/components/MultimodalLLM.class.ts b/packages/app/src/builder-ui/components/MultimodalLLM.class.ts
index cc4f5048..a8e2872c 100644
--- a/packages/app/src/builder-ui/components/MultimodalLLM.class.ts
+++ b/packages/app/src/builder-ui/components/MultimodalLLM.class.ts
@@ -41,7 +41,15 @@ export class MultimodalLLM extends Component {
}
//remove undefined models
- this.modelOptions = modelOptions.filter((e) => e);
+ this.modelOptions = modelOptions.filter((item) => {
+ if (!item) return false;
+
+ // Keep the currently selected model even if it's hidden
+ if (item?.value === model) return true;
+
+ // Otherwise, filter out hidden models
+ return !item?.hidden;
+ });
this.setModelParams(model);
@@ -133,8 +141,9 @@ export class MultimodalLLM extends Component {
},
maxContextTokens: {
type: 'div',
- html: `<strong class="px-2">Context window size: <span class="tokens_num">${allowedContextTokens ? allowedContextTokens.toLocaleString() : 'Unknown'
- }</span> tokens</strong><br/>`,
+ html: `<strong class="px-2">Context window size: <span class="tokens_num">${
+ allowedContextTokens ? allowedContextTokens.toLocaleString() : 'Unknown'
+ }</span> tokens</strong><br/>`,
attributes: {
'data-supported-models':
'OpenAI,Anthropic,GoogleAI,Groq,xAI,TogetherAI,VertexAI,Bedrock,cohere',
diff --git a/packages/app/src/builder-ui/components/PromptGenerator.class.ts b/packages/app/src/builder-ui/components/PromptGenerator.class.ts
index d78e5b4f..3a4353e4 100644
--- a/packages/app/src/builder-ui/components/PromptGenerator.class.ts
+++ b/packages/app/src/builder-ui/components/PromptGenerator.class.ts
@@ -48,7 +48,15 @@ export class PromptGenerator extends Component {
// TODO: set warning if the model is not available
//remove undefined models
- this.modelOptions = modelOptions.filter((e) => e);
+ this.modelOptions = modelOptions.filter((item) => {
+ if (!item) return false;
+
+ // Keep the currently selected model even if it's hidden
+ if (item?.value === model) return true;
+
+ // Otherwise, filter out hidden models
+ return !item?.hidden;
+ });
this.setModelParams(model);
@@ -293,8 +301,9 @@ export class PromptGenerator extends Component {
},
maxContextTokens: {
type: 'div',
- html: `<strong class="px-2">Context window size: <span class="tokens_num">${allowedContextTokens ? allowedContextTokens.toLocaleString() : 'Unknown'
- }</span> tokens</strong><br/>`,
+ html: `<strong class="px-2">Context window size: <span class="tokens_num">${
+ allowedContextTokens ? allowedContextTokens.toLocaleString() : 'Unknown'
+ }</span> tokens</strong><br/>`,
attributes: {
'data-supported-models':
'OpenAI,Anthropic,GoogleAI,xAI,TogetherAI,VertexAI,Bedrock,cohere',
diff --git a/packages/app/src/builder-ui/components/VisionLLM.class.ts b/packages/app/src/builder-ui/components/VisionLLM.class.ts
index aa37cad6..16f58f9a 100644
--- a/packages/app/src/builder-ui/components/VisionLLM.class.ts
+++ b/packages/app/src/builder-ui/components/VisionLLM.class.ts
@@ -35,7 +35,15 @@ export class VisionLLM extends Component {
}
//remove undefined models
- this.modelOptions = modelOptions.filter((e) => e);
+ this.modelOptions = modelOptions.filter((item) => {
+ if (!item) return false;
+
+ // Keep the currently selected model even if it's hidden
+ if (item?.value === model) return true;
+
+ // Otherwise, filter out hidden models
+ return !item?.hidden;
+ });
this.setModelParams(this.data?.model);
@@ -126,8 +134,9 @@ export class VisionLLM extends Component {
},
maxContextTokens: {
type: 'div',
- html: `<strong class="px-2">Context window size: <span class="tokens_num">${allowedContextTokens ? allowedContextTokens.toLocaleString() : 'Unknown'
- }</span> tokens</strong><br/>`,
+ html: `<strong class="px-2">Context window size: <span class="tokens_num">${
+ allowedContextTokens ? allowedContextTokens.toLocaleString() : 'Unknown'
+ }</span> tokens</strong><br/>`,
attributes: {
'data-supported-models':
'OpenAI,Anthropic,GoogleAI,Groq,xAI,TogetherAI,VertexAI,Bedrock,cohere',
diff --git a/packages/app/src/builder-ui/helpers/LLMFormController.helper.ts b/packages/app/src/builder-ui/helpers/LLMFormController.helper.ts
index 5adde80e..33e71481 100644
--- a/packages/app/src/builder-ui/helpers/LLMFormController.helper.ts
+++ b/packages/app/src/builder-ui/helpers/LLMFormController.helper.ts
@@ -327,8 +327,8 @@ export class LLMFormController {
const models = LLMRegistry.getSortedModelsByFeatures(targetFeatures);
for (const model of models) {
- let tags = model?.['tags'] || [];
- let features = model?.['features'] || [];
+ let tags = model?.tags || [];
+ let features = model?.features || [];
// Show badges for supported features from target features
const featuresSet = new Set(features);
@@ -344,6 +344,7 @@ export class LLMFormController {
badge: `<span class="model-name-badge"><span class="model-name">${model?.label}</span> <span class="all-badges">${statusBadges}</span></span> <span class="float-right">${capabilityBadges}</span>`,
tags,
default: model?.default || false,
+ hidden: model?.hidden || false,
});
}
diff --git a/packages/app/src/builder-ui/ui/badges.ts b/packages/app/src/builder-ui/ui/badges.ts
index 581a3863..7980412f 100644
--- a/packages/app/src/builder-ui/ui/badges.ts
+++ b/packages/app/src/builder-ui/ui/badges.ts
@@ -32,9 +32,10 @@ export type FeatureType =
export type ModelStatus =
| 'new'
- | 'legacy'
| 'limited'
+ | 'legacy'
| 'deprecated'
+ | 'retired'
| 'removed'
| 'groq'
| 'togetherai'
@@ -58,14 +59,14 @@ const statusBadgeConfigs: Record<ModelStatus, BadgeConfig> = {
classes:
'text-smyth-emerald-400 border-smyth-emerald-400 [.drop-container_&]:bg-smyth-emerald-400 [.drop-container_&]:text-white',
},
- legacy: {
- label: 'Legacy',
+ limited: {
+ label: 'Limited',
icon: '',
classes:
'text-smyth-amber-500 border-smyth-amber-500 [.drop-container_&]:bg-smyth-amber-500 [.drop-container_&]:text-gray-100',
},
- limited: {
- label: 'Limited',
+ legacy: {
+ label: 'Legacy',
icon: '',
classes:
'text-smyth-amber-500 border-smyth-amber-500 [.drop-container_&]:bg-smyth-amber-500 [.drop-container_&]:text-gray-100',
@@ -74,13 +75,19 @@ const statusBadgeConfigs: Record<ModelStatus, BadgeConfig> = {
label: 'Deprecated',
icon: '',
classes:
- 'text-smyth-red-500 border-smyth-red-500 [.drop-container_&]:bg-smyth-red-500 [.drop-container_&]:text-white',
+ 'text-smyth-red-500 border-smyth-red-500 [.drop-container_&]:bg-smyth-red-500 [.drop-container_&]:text-gray-100',
+ },
+ retired: {
+ label: 'Retired',
+ icon: '',
+ classes:
+ 'text-orange-600 border-orange-600 [.drop-container_&]:bg-orange-600 [.drop-container_&]:text-gray-100',
},
removed: {
label: 'Removed',
icon: '',
classes:
- 'text-smyth-red-500 border-smyth-red-500 [.drop-container_&]:bg-smyth-red-500 [.drop-container_&]:text-white',
+ 'text-smyth-red-500 border-smyth-red-500 [.drop-container_&]:bg-smyth-red-500 [.drop-container_&]:text-gray-100',
},
groq: {
label: 'Groq',
diff --git a/packages/app/src/shared/types.ts b/packages/app/src/shared/types.ts
index df7a8f9f..be47da28 100644
--- a/packages/app/src/shared/types.ts
+++ b/packages/app/src/shared/types.ts
@@ -32,6 +32,7 @@ export interface LLMModel {
tokens: number;
completionTokens: number;
default?: boolean;
+ hidden?: boolean;
searchContextTokens?: number;
maxReasoningTokens?: number;
}