Skip to content

Commit b35606d

Browse files
committed
fix(litellm): final parity gaps from second audit
- blocks/utils.ts getModelOptions(): include litellm models in the combined model dropdown — was previously dropping any proxy-discovered models from the agent block model picker. - get-blocks-metadata-tool.ts mockProvidersState: add litellm bucket so the server-side copilot block-metadata fallback can render model options when the providers store is not initialized. - blocks/utils.test.ts: add litellm to mock providers state (initial + beforeEach reset) and add a parallel store-bucket guard test mirroring the vLLM case. - providers/utils.test.ts: add parallel getApiKey test for litellm.
1 parent 3f1b94b commit b35606d

4 files changed

Lines changed: 23 additions & 0 deletions

File tree

apps/sim/blocks/utils.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const { mockProviders } = vi.hoisted(() => ({
2727
base: { models: [] as string[], isLoading: false },
2828
ollama: { models: [] as string[], isLoading: false },
2929
vllm: { models: [] as string[], isLoading: false },
30+
litellm: { models: [] as string[], isLoading: false },
3031
openrouter: { models: [] as string[], isLoading: false },
3132
fireworks: { models: [] as string[], isLoading: false },
3233
},
@@ -101,6 +102,7 @@ describe('getApiKeyCondition / shouldRequireApiKeyForModel', () => {
101102
base: { models: [], isLoading: false },
102103
ollama: { models: [], isLoading: false },
103104
vllm: { models: [], isLoading: false },
105+
litellm: { models: [], isLoading: false },
104106
openrouter: { models: [], isLoading: false },
105107
fireworks: { models: [], isLoading: false },
106108
}
@@ -185,6 +187,11 @@ describe('getApiKeyCondition / shouldRequireApiKeyForModel', () => {
185187
expect(evaluateCondition('my-custom-model')).toBe(false)
186188
})
187189

190+
it('does not require API key when model is in the LiteLLM store bucket', () => {
191+
mockProviders.value.litellm.models = ['litellm/anthropic/claude-sonnet-4-6']
192+
expect(evaluateCondition('litellm/anthropic/claude-sonnet-4-6')).toBe(false)
193+
})
194+
188195
it('requires API key when model is in the fireworks store bucket', () => {
189196
mockProviders.value.fireworks.models = ['fireworks/llama-3']
190197
expect(evaluateCondition('fireworks/llama-3')).toBe(true)

apps/sim/blocks/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,15 @@ export function getModelOptions() {
5151
const baseModels = providersState.providers.base.models
5252
const ollamaModels = providersState.providers.ollama.models
5353
const vllmModels = providersState.providers.vllm.models
54+
const litellmModels = providersState.providers.litellm.models
5455
const openrouterModels = providersState.providers.openrouter.models
5556
const fireworksModels = providersState.providers.fireworks.models
5657
const allModels = Array.from(
5758
new Set([
5859
...baseModels,
5960
...ollamaModels,
6061
...vllmModels,
62+
...litellmModels,
6163
...openrouterModels,
6264
...fireworksModels,
6365
])

apps/sim/lib/copilot/tools/server/blocks/get-blocks-metadata-tool.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,7 @@ function callOptionsWithFallback(
768768
base: { models: staticModels.map((m) => m.id) },
769769
ollama: { models: [] },
770770
vllm: { models: [] },
771+
litellm: { models: [] },
771772
openrouter: { models: [] },
772773
fireworks: { models: [] },
773774
},

apps/sim/providers/utils.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,19 @@ describe('getApiKey', () => {
168168
expect(key2).toBe('user-key')
169169
}
170170
)
171+
172+
it.concurrent(
173+
'should return empty or user-provided key for litellm provider without requiring API key',
174+
() => {
175+
isHostedSpy.mockReturnValue(false)
176+
177+
const key = getApiKey('litellm', 'litellm/anthropic/claude-sonnet-4-6')
178+
expect(key).toBe('empty')
179+
180+
const key2 = getApiKey('litellm', 'litellm/openai/gpt-4', 'user-key')
181+
expect(key2).toBe('user-key')
182+
}
183+
)
171184
})
172185

173186
describe('Model Capabilities', () => {

0 commit comments

Comments
 (0)