Skip to content

Commit 2ad74a7

Browse files
committed
chore(providers): share one unpriced-model builder across discovered providers
1 parent cd35d04 commit 2ad74a7

3 files changed

Lines changed: 13 additions & 55 deletions

File tree

‎apps/sim/app/(auth)/components/social-login-buttons.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface SocialLoginButtonsProps {
2323
microsoftAvailable: boolean
2424
view: 'login' | 'signup'
2525
callbackURL?: string
26-
ssoEnabled?: boolean
26+
ssoEnabled: boolean
2727
disabled?: boolean
2828
}
2929

‎apps/sim/providers/models.ts‎

Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7067,22 +7067,22 @@ export function supportsForcedToolUse(modelId: string): boolean {
70677067
return capabilities?.forcedToolUse ?? capabilities?.toolUsageControl ?? false
70687068
}
70697069

7070-
/** A self-hosted server's model ids as free, capability-less catalog entries. */
7071-
function toSelfHostedModels(models: string[]): ModelDefinition[] {
7070+
/** Discovered model ids as unpriced, capability-less catalog entries. */
7071+
function toUnpricedModels(models: string[]): ModelDefinition[] {
70727072
const updatedAt = new Date().toISOString().split('T')[0]
70737073
return models.map((id) => ({ id, pricing: { input: 0, output: 0, updatedAt }, capabilities: {} }))
70747074
}
70757075

70767076
export function updateOllamaModels(models: string[]): void {
7077-
PROVIDER_DEFINITIONS.ollama.models = toSelfHostedModels(models)
7077+
PROVIDER_DEFINITIONS.ollama.models = toUnpricedModels(models)
70787078
}
70797079

70807080
export function updateVLLMModels(models: string[]): void {
7081-
PROVIDER_DEFINITIONS.vllm.models = toSelfHostedModels(models)
7081+
PROVIDER_DEFINITIONS.vllm.models = toUnpricedModels(models)
70827082
}
70837083

70847084
export function updateLiteLLMModels(models: string[]): void {
7085-
PROVIDER_DEFINITIONS.litellm.models = toSelfHostedModels(models)
7085+
PROVIDER_DEFINITIONS.litellm.models = toUnpricedModels(models)
70867086
}
70877087

70887088
/**
@@ -7098,66 +7098,24 @@ export function updateFireworksModels(models: string[]): void {
70987098
const staticIds = new Set(STATIC_FIREWORKS_MODELS.map((model) => model.id.toLowerCase()))
70997099
PROVIDER_DEFINITIONS.fireworks.models = [
71007100
...STATIC_FIREWORKS_MODELS,
7101-
...models
7102-
.filter((modelId) => !staticIds.has(modelId.toLowerCase()))
7103-
.map((modelId) => ({
7104-
id: modelId,
7105-
pricing: {
7106-
input: 0,
7107-
output: 0,
7108-
updatedAt: new Date().toISOString().split('T')[0],
7109-
},
7110-
capabilities: {},
7111-
})),
7101+
...toUnpricedModels(models.filter((modelId) => !staticIds.has(modelId.toLowerCase()))),
71127102
]
71137103
}
71147104

71157105
export function updateTogetherModels(models: string[]): void {
7116-
PROVIDER_DEFINITIONS.together.models = models.map((modelId) => ({
7117-
id: modelId,
7118-
pricing: {
7119-
input: 0,
7120-
output: 0,
7121-
updatedAt: new Date().toISOString().split('T')[0],
7122-
},
7123-
capabilities: {},
7124-
}))
7106+
PROVIDER_DEFINITIONS.together.models = toUnpricedModels(models)
71257107
}
71267108

71277109
export function updateBasetenModels(models: string[]): void {
7128-
PROVIDER_DEFINITIONS.baseten.models = models.map((modelId) => ({
7129-
id: modelId,
7130-
pricing: {
7131-
input: 0,
7132-
output: 0,
7133-
updatedAt: new Date().toISOString().split('T')[0],
7134-
},
7135-
capabilities: {},
7136-
}))
7110+
PROVIDER_DEFINITIONS.baseten.models = toUnpricedModels(models)
71377111
}
71387112

71397113
export function updateOllamaCloudModels(models: string[]): void {
7140-
PROVIDER_DEFINITIONS['ollama-cloud'].models = models.map((modelId) => ({
7141-
id: modelId,
7142-
pricing: {
7143-
input: 0,
7144-
output: 0,
7145-
updatedAt: new Date().toISOString().split('T')[0],
7146-
},
7147-
capabilities: {},
7148-
}))
7114+
PROVIDER_DEFINITIONS['ollama-cloud'].models = toUnpricedModels(models)
71497115
}
71507116

71517117
export function updateOpenRouterModels(models: string[]): void {
7152-
PROVIDER_DEFINITIONS.openrouter.models = models.map((modelId) => ({
7153-
id: modelId,
7154-
pricing: {
7155-
input: 0,
7156-
output: 0,
7157-
updatedAt: new Date().toISOString().split('T')[0],
7158-
},
7159-
capabilities: {},
7160-
}))
7118+
PROVIDER_DEFINITIONS.openrouter.models = toUnpricedModels(models)
71617119
}
71627120

71637121
export const EMBEDDING_MODEL_PRICING: Record<string, ModelPricing> = {

‎apps/sim/providers/utils.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import {
4242
isKnownModelLevelValue,
4343
PROVIDER_DEFINITIONS,
4444
updateLiteLLMModels,
45-
updateOllamaModels as updateOllamaModelsInDefinitions,
45+
updateOllamaModels,
4646
updateVLLMModels,
4747
} from '@/providers/models'
4848
import {
@@ -173,7 +173,7 @@ export const providers: Record<ProviderId, ProviderMetadata> = {
173173
}
174174

175175
export function updateOllamaProviderModels(models: string[]): void {
176-
updateOllamaModelsInDefinitions(models)
176+
updateOllamaModels(models)
177177
providers.ollama.models = getProviderModels('ollama')
178178
}
179179

0 commit comments

Comments
 (0)