Skip to content

Commit 26dff7c

Browse files
authored
feat(bedrock): added aws bedrock as a model provider (#2722)
1 parent 0200377 commit 26dff7c

File tree

23 files changed

+1791
-466
lines changed

23 files changed

+1791
-466
lines changed

apps/sim/app/api/providers/route.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export async function POST(request: NextRequest) {
4141
vertexProject,
4242
vertexLocation,
4343
vertexCredential,
44+
bedrockAccessKeyId,
45+
bedrockSecretKey,
46+
bedrockRegion,
4447
responseFormat,
4548
workflowId,
4649
workspaceId,
@@ -67,6 +70,9 @@ export async function POST(request: NextRequest) {
6770
hasVertexProject: !!vertexProject,
6871
hasVertexLocation: !!vertexLocation,
6972
hasVertexCredential: !!vertexCredential,
73+
hasBedrockAccessKeyId: !!bedrockAccessKeyId,
74+
hasBedrockSecretKey: !!bedrockSecretKey,
75+
hasBedrockRegion: !!bedrockRegion,
7076
hasResponseFormat: !!responseFormat,
7177
workflowId,
7278
stream: !!stream,
@@ -116,6 +122,9 @@ export async function POST(request: NextRequest) {
116122
azureApiVersion,
117123
vertexProject,
118124
vertexLocation,
125+
bedrockAccessKeyId,
126+
bedrockSecretKey,
127+
bedrockRegion,
119128
responseFormat,
120129
workflowId,
121130
workspaceId,

apps/sim/blocks/blocks/agent.ts

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ export const AgentBlock: BlockConfig<AgentResponse> = {
9494
placeholder: 'Type or select a model...',
9595
required: true,
9696
defaultValue: 'claude-sonnet-4-5',
97-
searchable: true,
9897
options: () => {
9998
const providersState = useProvidersStore.getState()
10099
const baseModels = providersState.providers.base.models
@@ -329,6 +328,43 @@ export const AgentBlock: BlockConfig<AgentResponse> = {
329328
value: providers.vertex.models,
330329
},
331330
},
331+
{
332+
id: 'bedrockAccessKeyId',
333+
title: 'AWS Access Key ID',
334+
type: 'short-input',
335+
password: true,
336+
placeholder: 'Enter your AWS Access Key ID',
337+
connectionDroppable: false,
338+
required: true,
339+
condition: {
340+
field: 'model',
341+
value: providers.bedrock.models,
342+
},
343+
},
344+
{
345+
id: 'bedrockSecretKey',
346+
title: 'AWS Secret Access Key',
347+
type: 'short-input',
348+
password: true,
349+
placeholder: 'Enter your AWS Secret Access Key',
350+
connectionDroppable: false,
351+
required: true,
352+
condition: {
353+
field: 'model',
354+
value: providers.bedrock.models,
355+
},
356+
},
357+
{
358+
id: 'bedrockRegion',
359+
title: 'AWS Region',
360+
type: 'short-input',
361+
placeholder: 'us-east-1',
362+
connectionDroppable: false,
363+
condition: {
364+
field: 'model',
365+
value: providers.bedrock.models,
366+
},
367+
},
332368
{
333369
id: 'tools',
334370
title: 'Tools',
@@ -343,11 +379,11 @@ export const AgentBlock: BlockConfig<AgentResponse> = {
343379
password: true,
344380
connectionDroppable: false,
345381
required: true,
346-
// Hide API key for hosted models, Ollama models, vLLM models, and Vertex models (uses OAuth)
382+
// Hide API key for hosted models, Ollama models, vLLM models, Vertex models (uses OAuth), and Bedrock (uses AWS credentials)
347383
condition: isHosted
348384
? {
349385
field: 'model',
350-
value: [...getHostedModels(), ...providers.vertex.models],
386+
value: [...getHostedModels(), ...providers.vertex.models, ...providers.bedrock.models],
351387
not: true, // Show for all models EXCEPT those listed
352388
}
353389
: () => ({
@@ -356,8 +392,9 @@ export const AgentBlock: BlockConfig<AgentResponse> = {
356392
...getCurrentOllamaModels(),
357393
...getCurrentVLLMModels(),
358394
...providers.vertex.models,
395+
...providers.bedrock.models,
359396
],
360-
not: true, // Show for all models EXCEPT Ollama, vLLM, and Vertex models
397+
not: true, // Show for all models EXCEPT Ollama, vLLM, Vertex, and Bedrock models
361398
}),
362399
},
363400
{
@@ -634,6 +671,9 @@ Example 3 (Array Input):
634671
azureApiVersion: { type: 'string', description: 'Azure API version' },
635672
vertexProject: { type: 'string', description: 'Google Cloud project ID for Vertex AI' },
636673
vertexLocation: { type: 'string', description: 'Google Cloud location for Vertex AI' },
674+
bedrockAccessKeyId: { type: 'string', description: 'AWS Access Key ID for Bedrock' },
675+
bedrockSecretKey: { type: 'string', description: 'AWS Secret Access Key for Bedrock' },
676+
bedrockRegion: { type: 'string', description: 'AWS region for Bedrock' },
637677
responseFormat: {
638678
type: 'json',
639679
description: 'JSON response format schema',

apps/sim/blocks/blocks/evaluator.ts

Lines changed: 4 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
11
import { createLogger } from '@sim/logger'
22
import { ChartBarIcon } from '@/components/icons'
3-
import { isHosted } from '@/lib/core/config/feature-flags'
43
import type { BlockConfig, ParamType } from '@/blocks/types'
4+
import { getProviderCredentialSubBlocks, PROVIDER_CREDENTIAL_INPUTS } from '@/blocks/utils'
55
import type { ProviderId } from '@/providers/types'
6-
import {
7-
getBaseModelProviders,
8-
getHostedModels,
9-
getProviderIcon,
10-
providers,
11-
} from '@/providers/utils'
6+
import { getBaseModelProviders, getProviderIcon } from '@/providers/utils'
127
import { useProvidersStore } from '@/stores/providers/store'
138
import type { ToolResponse } from '@/tools/types'
149

1510
const logger = createLogger('EvaluatorBlock')
1611

17-
const getCurrentOllamaModels = () => {
18-
return useProvidersStore.getState().providers.ollama.models
19-
}
20-
21-
const getCurrentVLLMModels = () => {
22-
return useProvidersStore.getState().providers.vllm.models
23-
}
24-
2512
interface Metric {
2613
name: string
2714
description: string
@@ -204,91 +191,7 @@ export const EvaluatorBlock: BlockConfig<EvaluatorResponse> = {
204191
})
205192
},
206193
},
207-
{
208-
id: 'vertexCredential',
209-
title: 'Google Cloud Account',
210-
type: 'oauth-input',
211-
serviceId: 'vertex-ai',
212-
requiredScopes: ['https://www.googleapis.com/auth/cloud-platform'],
213-
placeholder: 'Select Google Cloud account',
214-
required: true,
215-
condition: {
216-
field: 'model',
217-
value: providers.vertex.models,
218-
},
219-
},
220-
{
221-
id: 'apiKey',
222-
title: 'API Key',
223-
type: 'short-input',
224-
placeholder: 'Enter your API key',
225-
password: true,
226-
connectionDroppable: false,
227-
required: true,
228-
// Hide API key for hosted models, Ollama models, vLLM models, and Vertex models (uses OAuth)
229-
condition: isHosted
230-
? {
231-
field: 'model',
232-
value: [...getHostedModels(), ...providers.vertex.models],
233-
not: true, // Show for all models EXCEPT those listed
234-
}
235-
: () => ({
236-
field: 'model',
237-
value: [
238-
...getCurrentOllamaModels(),
239-
...getCurrentVLLMModels(),
240-
...providers.vertex.models,
241-
],
242-
not: true, // Show for all models EXCEPT Ollama, vLLM, and Vertex models
243-
}),
244-
},
245-
{
246-
id: 'azureEndpoint',
247-
title: 'Azure OpenAI Endpoint',
248-
type: 'short-input',
249-
password: true,
250-
placeholder: 'https://your-resource.openai.azure.com',
251-
connectionDroppable: false,
252-
condition: {
253-
field: 'model',
254-
value: providers['azure-openai'].models,
255-
},
256-
},
257-
{
258-
id: 'azureApiVersion',
259-
title: 'Azure API Version',
260-
type: 'short-input',
261-
placeholder: '2024-07-01-preview',
262-
connectionDroppable: false,
263-
condition: {
264-
field: 'model',
265-
value: providers['azure-openai'].models,
266-
},
267-
},
268-
{
269-
id: 'vertexProject',
270-
title: 'Vertex AI Project',
271-
type: 'short-input',
272-
placeholder: 'your-gcp-project-id',
273-
connectionDroppable: false,
274-
required: true,
275-
condition: {
276-
field: 'model',
277-
value: providers.vertex.models,
278-
},
279-
},
280-
{
281-
id: 'vertexLocation',
282-
title: 'Vertex AI Location',
283-
type: 'short-input',
284-
placeholder: 'us-central1',
285-
connectionDroppable: false,
286-
required: true,
287-
condition: {
288-
field: 'model',
289-
value: providers.vertex.models,
290-
},
291-
},
194+
...getProviderCredentialSubBlocks(),
292195
{
293196
id: 'temperature',
294197
title: 'Temperature',
@@ -403,21 +306,7 @@ export const EvaluatorBlock: BlockConfig<EvaluatorResponse> = {
403306
},
404307
},
405308
model: { type: 'string' as ParamType, description: 'AI model to use' },
406-
apiKey: { type: 'string' as ParamType, description: 'Provider API key' },
407-
azureEndpoint: { type: 'string' as ParamType, description: 'Azure OpenAI endpoint URL' },
408-
azureApiVersion: { type: 'string' as ParamType, description: 'Azure API version' },
409-
vertexProject: {
410-
type: 'string' as ParamType,
411-
description: 'Google Cloud project ID for Vertex AI',
412-
},
413-
vertexLocation: {
414-
type: 'string' as ParamType,
415-
description: 'Google Cloud location for Vertex AI',
416-
},
417-
vertexCredential: {
418-
type: 'string' as ParamType,
419-
description: 'Google Cloud OAuth credential ID for Vertex AI',
420-
},
309+
...PROVIDER_CREDENTIAL_INPUTS,
421310
temperature: {
422311
type: 'number' as ParamType,
423312
description: 'Response randomness level (low for consistent evaluation)',

apps/sim/blocks/blocks/guardrails.ts

Lines changed: 19 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import { ShieldCheckIcon } from '@/components/icons'
2-
import { isHosted } from '@/lib/core/config/feature-flags'
32
import type { BlockConfig } from '@/blocks/types'
4-
import { getHostedModels, getProviderIcon } from '@/providers/utils'
3+
import { getProviderCredentialSubBlocks, PROVIDER_CREDENTIAL_INPUTS } from '@/blocks/utils'
4+
import { getProviderIcon } from '@/providers/utils'
55
import { useProvidersStore } from '@/stores/providers/store'
66
import type { ToolResponse } from '@/tools/types'
77

8-
const getCurrentOllamaModels = () => {
9-
const providersState = useProvidersStore.getState()
10-
return providersState.providers.ollama.models
11-
}
12-
138
export interface GuardrailsResponse extends ToolResponse {
149
output: {
1510
passed: boolean
@@ -120,8 +115,11 @@ Return ONLY the regex pattern - no explanations, no quotes, no forward slashes,
120115
const providersState = useProvidersStore.getState()
121116
const baseModels = providersState.providers.base.models
122117
const ollamaModels = providersState.providers.ollama.models
118+
const vllmModels = providersState.providers.vllm.models
123119
const openrouterModels = providersState.providers.openrouter.models
124-
const allModels = Array.from(new Set([...baseModels, ...ollamaModels, ...openrouterModels]))
120+
const allModels = Array.from(
121+
new Set([...baseModels, ...ollamaModels, ...vllmModels, ...openrouterModels])
122+
)
125123

126124
return allModels.map((model) => {
127125
const icon = getProviderIcon(model)
@@ -160,44 +158,19 @@ Return ONLY the regex pattern - no explanations, no quotes, no forward slashes,
160158
value: ['hallucination'],
161159
},
162160
},
163-
{
164-
id: 'apiKey',
165-
title: 'API Key',
166-
type: 'short-input',
167-
placeholder: 'Enter your API key',
168-
password: true,
169-
connectionDroppable: false,
170-
required: true,
171-
// Show API key field only for hallucination validation
172-
// Hide for hosted models and Ollama models
173-
condition: () => {
174-
const baseCondition = {
175-
field: 'validationType' as const,
176-
value: ['hallucination'],
177-
}
178-
179-
if (isHosted) {
180-
// In hosted mode, hide for hosted models
181-
return {
182-
...baseCondition,
183-
and: {
184-
field: 'model' as const,
185-
value: getHostedModels(),
186-
not: true, // Show for all models EXCEPT hosted ones
187-
},
161+
// Provider credential subblocks - only shown for hallucination validation
162+
...getProviderCredentialSubBlocks().map((subBlock) => ({
163+
...subBlock,
164+
// Combine with hallucination condition
165+
condition: subBlock.condition
166+
? {
167+
field: 'validationType' as const,
168+
value: ['hallucination'],
169+
and:
170+
typeof subBlock.condition === 'function' ? subBlock.condition() : subBlock.condition,
188171
}
189-
}
190-
// In self-hosted mode, hide for Ollama models
191-
return {
192-
...baseCondition,
193-
and: {
194-
field: 'model' as const,
195-
value: getCurrentOllamaModels(),
196-
not: true, // Show for all models EXCEPT Ollama ones
197-
},
198-
}
199-
},
200-
},
172+
: { field: 'validationType' as const, value: ['hallucination'] },
173+
})),
201174
{
202175
id: 'piiEntityTypes',
203176
title: 'PII Types to Detect',
@@ -332,10 +305,7 @@ Return ONLY the regex pattern - no explanations, no quotes, no forward slashes,
332305
type: 'string',
333306
description: 'LLM model for hallucination scoring (default: gpt-4o-mini)',
334307
},
335-
apiKey: {
336-
type: 'string',
337-
description: 'API key for LLM provider (optional if using hosted)',
338-
},
308+
...PROVIDER_CREDENTIAL_INPUTS,
339309
piiEntityTypes: {
340310
type: 'json',
341311
description: 'PII entity types to detect (array of strings, empty = detect all)',

0 commit comments

Comments
 (0)