Skip to content

Commit 9de0d91

Browse files
authored
feat(llms): added additional params to llm-based blocks for alternative models (#1223)
* feat(llms): added additional params to llm-based blocks for alternative models * add hidden temp param to other LLM-based blocks
1 parent 3db73ff commit 9de0d91

File tree

4 files changed

+214
-30
lines changed

4 files changed

+214
-30
lines changed

apps/sim/blocks/blocks/agent.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
supportsTemperature,
1515
} from '@/providers/utils'
1616

17-
// Get current Ollama models dynamically
1817
const getCurrentOllamaModels = () => {
1918
return useProvidersStore.getState().providers.ollama.models
2019
}

apps/sim/blocks/blocks/evaluator.ts

Lines changed: 69 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@ import { isHosted } from '@/lib/environment'
33
import { createLogger } from '@/lib/logs/console/logger'
44
import type { BlockConfig, ParamType } from '@/blocks/types'
55
import type { ProviderId } from '@/providers/types'
6-
import { getAllModelProviders, getBaseModelProviders, getHostedModels } from '@/providers/utils'
6+
import {
7+
getAllModelProviders,
8+
getBaseModelProviders,
9+
getHostedModels,
10+
getProviderIcon,
11+
providers,
12+
} from '@/providers/utils'
713
import { useProvidersStore } from '@/stores/providers/store'
814
import type { ToolResponse } from '@/tools/types'
915

1016
const logger = createLogger('EvaluatorBlock')
1117

18+
const getCurrentOllamaModels = () => {
19+
return useProvidersStore.getState().providers.ollama.models
20+
}
21+
1222
interface Metric {
1323
name: string
1424
description: string
@@ -173,16 +183,21 @@ export const EvaluatorBlock: BlockConfig<EvaluatorResponse> = {
173183
{
174184
id: 'model',
175185
title: 'Model',
176-
type: 'dropdown',
186+
type: 'combobox',
177187
layout: 'half',
188+
placeholder: 'Type or select a model...',
178189
required: true,
179190
options: () => {
180-
const ollamaModels = useProvidersStore.getState().providers.ollama.models
191+
const providersState = useProvidersStore.getState()
192+
const ollamaModels = providersState.providers.ollama.models
193+
const openrouterModels = providersState.providers.openrouter.models
181194
const baseModels = Object.keys(getBaseModelProviders())
182-
return [...baseModels, ...ollamaModels].map((model) => ({
183-
label: model,
184-
id: model,
185-
}))
195+
const allModels = Array.from(new Set([...baseModels, ...ollamaModels, ...openrouterModels]))
196+
197+
return allModels.map((model) => {
198+
const icon = getProviderIcon(model)
199+
return { label: model, id: model, ...(icon && { icon }) }
200+
})
186201
},
187202
},
188203
{
@@ -198,9 +213,48 @@ export const EvaluatorBlock: BlockConfig<EvaluatorResponse> = {
198213
? {
199214
field: 'model',
200215
value: getHostedModels(),
201-
not: true,
216+
not: true, // Show for all models EXCEPT those listed
202217
}
203-
: undefined,
218+
: () => ({
219+
field: 'model',
220+
value: getCurrentOllamaModels(),
221+
not: true, // Show for all models EXCEPT Ollama models
222+
}),
223+
},
224+
{
225+
id: 'azureEndpoint',
226+
title: 'Azure OpenAI Endpoint',
227+
type: 'short-input',
228+
layout: 'full',
229+
password: true,
230+
placeholder: 'https://your-resource.openai.azure.com',
231+
connectionDroppable: false,
232+
condition: {
233+
field: 'model',
234+
value: providers['azure-openai'].models,
235+
},
236+
},
237+
{
238+
id: 'azureApiVersion',
239+
title: 'Azure API Version',
240+
type: 'short-input',
241+
layout: 'full',
242+
placeholder: '2024-07-01-preview',
243+
connectionDroppable: false,
244+
condition: {
245+
field: 'model',
246+
value: providers['azure-openai'].models,
247+
},
248+
},
249+
{
250+
id: 'temperature',
251+
title: 'Temperature',
252+
type: 'slider',
253+
layout: 'half',
254+
min: 0,
255+
max: 2,
256+
value: () => '0.1',
257+
hidden: true,
204258
},
205259
{
206260
id: 'systemPrompt',
@@ -310,6 +364,12 @@ export const EvaluatorBlock: BlockConfig<EvaluatorResponse> = {
310364
},
311365
model: { type: 'string' as ParamType, description: 'AI model to use' },
312366
apiKey: { type: 'string' as ParamType, description: 'Provider API key' },
367+
azureEndpoint: { type: 'string' as ParamType, description: 'Azure OpenAI endpoint URL' },
368+
azureApiVersion: { type: 'string' as ParamType, description: 'Azure API version' },
369+
temperature: {
370+
type: 'number' as ParamType,
371+
description: 'Response randomness level (low for consistent evaluation)',
372+
},
313373
content: { type: 'string' as ParamType, description: 'Content to evaluate' },
314374
},
315375
outputs: {

apps/sim/blocks/blocks/router.ts

Lines changed: 70 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@ import { ConnectIcon } from '@/components/icons'
22
import { isHosted } from '@/lib/environment'
33
import type { BlockConfig } from '@/blocks/types'
44
import type { ProviderId } from '@/providers/types'
5-
import { getAllModelProviders, getBaseModelProviders, getHostedModels } from '@/providers/utils'
5+
import {
6+
getAllModelProviders,
7+
getBaseModelProviders,
8+
getHostedModels,
9+
getProviderIcon,
10+
providers,
11+
} from '@/providers/utils'
612
import { useProvidersStore } from '@/stores/providers/store'
713
import type { ToolResponse } from '@/tools/types'
814

15+
const getCurrentOllamaModels = () => {
16+
return useProvidersStore.getState().providers.ollama.models
17+
}
18+
919
interface RouterResponse extends ToolResponse {
1020
output: {
1121
content: string
@@ -116,17 +126,22 @@ export const RouterBlock: BlockConfig<RouterResponse> = {
116126
{
117127
id: 'model',
118128
title: 'Model',
119-
type: 'dropdown',
129+
type: 'combobox',
120130
layout: 'half',
131+
placeholder: 'Type or select a model...',
132+
required: true,
121133
options: () => {
122-
const ollamaModels = useProvidersStore.getState().providers.ollama.models
134+
const providersState = useProvidersStore.getState()
135+
const ollamaModels = providersState.providers.ollama.models
136+
const openrouterModels = providersState.providers.openrouter.models
123137
const baseModels = Object.keys(getBaseModelProviders())
124-
return [...baseModels, ...ollamaModels].map((model) => ({
125-
label: model,
126-
id: model,
127-
}))
138+
const allModels = Array.from(new Set([...baseModels, ...ollamaModels, ...openrouterModels]))
139+
140+
return allModels.map((model) => {
141+
const icon = getProviderIcon(model)
142+
return { label: model, id: model, ...(icon && { icon }) }
143+
})
128144
},
129-
required: true,
130145
},
131146
{
132147
id: 'apiKey',
@@ -137,14 +152,53 @@ export const RouterBlock: BlockConfig<RouterResponse> = {
137152
password: true,
138153
connectionDroppable: false,
139154
required: true,
140-
// Hide API key for all hosted models when running on hosted version
155+
// Hide API key for hosted models and Ollama models
141156
condition: isHosted
142157
? {
143158
field: 'model',
144159
value: getHostedModels(),
145160
not: true, // Show for all models EXCEPT those listed
146161
}
147-
: undefined, // Show for all models in non-hosted environments
162+
: () => ({
163+
field: 'model',
164+
value: getCurrentOllamaModels(),
165+
not: true, // Show for all models EXCEPT Ollama models
166+
}),
167+
},
168+
{
169+
id: 'azureEndpoint',
170+
title: 'Azure OpenAI Endpoint',
171+
type: 'short-input',
172+
layout: 'full',
173+
password: true,
174+
placeholder: 'https://your-resource.openai.azure.com',
175+
connectionDroppable: false,
176+
condition: {
177+
field: 'model',
178+
value: providers['azure-openai'].models,
179+
},
180+
},
181+
{
182+
id: 'azureApiVersion',
183+
title: 'Azure API Version',
184+
type: 'short-input',
185+
layout: 'full',
186+
placeholder: '2024-07-01-preview',
187+
connectionDroppable: false,
188+
condition: {
189+
field: 'model',
190+
value: providers['azure-openai'].models,
191+
},
192+
},
193+
{
194+
id: 'temperature',
195+
title: 'Temperature',
196+
type: 'slider',
197+
layout: 'half',
198+
hidden: true,
199+
min: 0,
200+
max: 2,
201+
value: () => '0.1',
148202
},
149203
{
150204
id: 'systemPrompt',
@@ -184,6 +238,12 @@ export const RouterBlock: BlockConfig<RouterResponse> = {
184238
prompt: { type: 'string', description: 'Routing prompt content' },
185239
model: { type: 'string', description: 'AI model to use' },
186240
apiKey: { type: 'string', description: 'Provider API key' },
241+
azureEndpoint: { type: 'string', description: 'Azure OpenAI endpoint URL' },
242+
azureApiVersion: { type: 'string', description: 'Azure API version' },
243+
temperature: {
244+
type: 'number',
245+
description: 'Response randomness level (low for consistent routing)',
246+
},
187247
},
188248
outputs: {
189249
content: { type: 'string', description: 'Routing response content' },

apps/sim/blocks/blocks/translate.ts

Lines changed: 75 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
import { TranslateIcon } from '@/components/icons'
2+
import { isHosted } from '@/lib/environment'
23
import type { BlockConfig } from '@/blocks/types'
3-
import type { ProviderId } from '@/providers/types'
4-
import { getBaseModelProviders } from '@/providers/utils'
4+
import {
5+
getAllModelProviders,
6+
getBaseModelProviders,
7+
getHostedModels,
8+
getProviderIcon,
9+
providers,
10+
} from '@/providers/utils'
11+
import { useProvidersStore } from '@/stores/providers/store'
12+
13+
const getCurrentOllamaModels = () => {
14+
return useProvidersStore.getState().providers.ollama.models
15+
}
516

617
const getTranslationPrompt = (
718
targetLanguage: string
@@ -44,10 +55,22 @@ export const TranslateBlock: BlockConfig = {
4455
{
4556
id: 'model',
4657
title: 'Model',
47-
type: 'dropdown',
58+
type: 'combobox',
4859
layout: 'half',
49-
options: Object.keys(getBaseModelProviders()).map((key) => ({ label: key, id: key })),
60+
placeholder: 'Type or select a model...',
5061
required: true,
62+
options: () => {
63+
const providersState = useProvidersStore.getState()
64+
const ollamaModels = providersState.providers.ollama.models
65+
const openrouterModels = providersState.providers.openrouter.models
66+
const baseModels = Object.keys(getBaseModelProviders())
67+
const allModels = Array.from(new Set([...baseModels, ...ollamaModels, ...openrouterModels]))
68+
69+
return allModels.map((model) => {
70+
const icon = getProviderIcon(model)
71+
return { label: model, id: model, ...(icon && { icon }) }
72+
})
73+
},
5174
},
5275
{
5376
id: 'apiKey',
@@ -58,6 +81,43 @@ export const TranslateBlock: BlockConfig = {
5881
password: true,
5982
connectionDroppable: false,
6083
required: true,
84+
// Hide API key for hosted models and Ollama models
85+
condition: isHosted
86+
? {
87+
field: 'model',
88+
value: getHostedModels(),
89+
not: true, // Show for all models EXCEPT those listed
90+
}
91+
: () => ({
92+
field: 'model',
93+
value: getCurrentOllamaModels(),
94+
not: true, // Show for all models EXCEPT Ollama models
95+
}),
96+
},
97+
{
98+
id: 'azureEndpoint',
99+
title: 'Azure OpenAI Endpoint',
100+
type: 'short-input',
101+
layout: 'full',
102+
password: true,
103+
placeholder: 'https://your-resource.openai.azure.com',
104+
connectionDroppable: false,
105+
condition: {
106+
field: 'model',
107+
value: providers['azure-openai'].models,
108+
},
109+
},
110+
{
111+
id: 'azureApiVersion',
112+
title: 'Azure API Version',
113+
type: 'short-input',
114+
layout: 'full',
115+
placeholder: '2024-07-01-preview',
116+
connectionDroppable: false,
117+
condition: {
118+
field: 'model',
119+
value: providers['azure-openai'].models,
120+
},
61121
},
62122
{
63123
id: 'systemPrompt',
@@ -71,21 +131,24 @@ export const TranslateBlock: BlockConfig = {
71131
},
72132
],
73133
tools: {
74-
access: ['openai_chat', 'anthropic_chat', 'google_chat'],
134+
access: [
135+
'openai_chat',
136+
'anthropic_chat',
137+
'google_chat',
138+
'xai_chat',
139+
'deepseek_chat',
140+
'deepseek_reasoner',
141+
],
75142
config: {
76143
tool: (params: Record<string, any>) => {
77144
const model = params.model || 'gpt-4o'
78-
79145
if (!model) {
80146
throw new Error('No model selected')
81147
}
82-
83-
const tool = getBaseModelProviders()[model as ProviderId]
84-
148+
const tool = getAllModelProviders()[model]
85149
if (!tool) {
86150
throw new Error(`Invalid model selected: ${model}`)
87151
}
88-
89152
return tool
90153
},
91154
},
@@ -94,6 +157,8 @@ export const TranslateBlock: BlockConfig = {
94157
context: { type: 'string', description: 'Text to translate' },
95158
targetLanguage: { type: 'string', description: 'Target language' },
96159
apiKey: { type: 'string', description: 'Provider API key' },
160+
azureEndpoint: { type: 'string', description: 'Azure OpenAI endpoint URL' },
161+
azureApiVersion: { type: 'string', description: 'Azure API version' },
97162
systemPrompt: { type: 'string', description: 'Translation instructions' },
98163
},
99164
outputs: {

0 commit comments

Comments
 (0)