Skip to content

Commit 9667e88

Browse files
committed
fix: add litellm to attachments, provider store, utils, and block guards
1 parent fe39f57 commit 9667e88

5 files changed

Lines changed: 21 additions & 2 deletions

File tree

apps/sim/blocks/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ function shouldRequireApiKeyForModel(model: string): boolean {
165165
}
166166

167167
const storeProvider = getProviderFromStore(normalizedModel)
168-
if (storeProvider === 'ollama' || storeProvider === 'vllm') return false
168+
if (storeProvider === 'ollama' || storeProvider === 'vllm' || storeProvider === 'litellm') return false
169169
if (storeProvider) return true
170170

171171
if (isOllamaConfigured) {

apps/sim/providers/attachments.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export type AttachmentProvider =
2424
| 'fireworks'
2525
| 'ollama'
2626
| 'vllm'
27+
| 'litellm'
2728
| 'xai'
2829
| 'deepseek'
2930
| 'cerebras'
@@ -93,6 +94,7 @@ const PROVIDER_SUPPORTED_LABELS: Record<AttachmentProvider, string> = {
9394
fireworks: 'images through image_url message parts on vision models',
9495
ollama: 'images through image_url message parts on vision models',
9596
vllm: 'images through image_url message parts on multimodal models',
97+
litellm: 'images through image_url message parts on multimodal models',
9698
xai: 'images through image_url message parts on Grok vision models',
9799
deepseek: 'no file attachments in the current API adapter',
98100
cerebras: 'no file attachments in the current API adapter',
@@ -109,6 +111,7 @@ export function getAttachmentProvider(providerId: ProviderId | string): Attachme
109111
if (providerId === 'fireworks') return 'fireworks'
110112
if (providerId === 'ollama') return 'ollama'
111113
if (providerId === 'vllm') return 'vllm'
114+
if (providerId === 'litellm') return 'litellm'
112115
if (providerId === 'xai') return 'xai'
113116
if (providerId === 'deepseek') return 'deepseek'
114117
if (providerId === 'cerebras') return 'cerebras'
@@ -247,6 +250,7 @@ function isMimeTypeSupportedByProvider(
247250
case 'fireworks':
248251
case 'ollama':
249252
case 'vllm':
253+
case 'litellm':
250254
case 'xai':
251255
return isImageMimeType(mimeType)
252256
case 'deepseek':

apps/sim/providers/utils.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ function buildProviderMetadata(providerId: ProviderId): ProviderMetadata {
132132
export const providers: Record<ProviderId, ProviderMetadata> = {
133133
ollama: buildProviderMetadata('ollama'),
134134
vllm: buildProviderMetadata('vllm'),
135+
litellm: buildProviderMetadata('litellm'),
135136
openai: {
136137
...buildProviderMetadata('openai'),
137138
computerUseModels: ['computer-use-preview'],
@@ -167,6 +168,12 @@ export function updateVLLMProviderModels(models: string[]): void {
167168
providers.vllm.models = getProviderModelsFromDefinitions('vllm')
168169
}
169170

171+
export function updateLiteLLMProviderModels(models: string[]): void {
172+
const { updateLiteLLMModels } = require('@/providers/models')
173+
updateLiteLLMModels(models)
174+
providers.litellm.models = getProviderModelsFromDefinitions('litellm')
175+
}
176+
170177
export async function updateOpenRouterProviderModels(models: string[]): Promise<void> {
171178
const { updateOpenRouterModels } = await import('@/providers/models')
172179
updateOpenRouterModels(models)
@@ -185,6 +192,7 @@ export function getBaseModelProviders(): Record<string, ProviderId> {
185192
([providerId]) =>
186193
providerId !== 'ollama' &&
187194
providerId !== 'vllm' &&
195+
providerId !== 'litellm' &&
188196
providerId !== 'openrouter' &&
189197
providerId !== 'fireworks'
190198
)
@@ -744,6 +752,12 @@ export function getApiKey(provider: string, model: string, userProvidedKey?: str
744752
return userProvidedKey || 'empty'
745753
}
746754

755+
const isLitellmModel =
756+
provider === 'litellm' || useProvidersStore.getState().providers.litellm?.models.includes(model)
757+
if (isLitellmModel) {
758+
return userProvidedKey || 'empty'
759+
}
760+
747761
// Bedrock uses its own credentials (bedrockAccessKeyId/bedrockSecretKey), not apiKey
748762
const isBedrockModel = provider === 'bedrock' || model.startsWith('bedrock/')
749763
if (isBedrockModel) {

apps/sim/stores/providers/store.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const useProvidersStore = create<ProvidersStore>((set, get) => ({
99
base: { models: [], isLoading: false },
1010
ollama: { models: [], isLoading: false },
1111
vllm: { models: [], isLoading: false },
12+
litellm: { models: [], isLoading: false },
1213
openrouter: { models: [], isLoading: false },
1314
fireworks: { models: [], isLoading: false },
1415
},

apps/sim/stores/providers/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type ProviderName = 'ollama' | 'vllm' | 'openrouter' | 'fireworks' | 'base'
1+
export type ProviderName = 'ollama' | 'vllm' | 'litellm' | 'openrouter' | 'fireworks' | 'base'
22

33
export interface OpenRouterModelInfo {
44
id: string

0 commit comments

Comments
 (0)