Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/sim/app/api/providers/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export async function POST(request: NextRequest) {
temperature,
maxTokens,
apiKey,
azureEndpoint,
azureApiVersion,
responseFormat,
workflowId,
stream,
Expand All @@ -47,6 +49,8 @@ export async function POST(request: NextRequest) {
hasTools: !!tools?.length,
toolCount: tools?.length || 0,
hasApiKey: !!apiKey,
hasAzureEndpoint: !!azureEndpoint,
hasAzureApiVersion: !!azureApiVersion,
hasResponseFormat: !!responseFormat,
workflowId,
stream: !!stream,
Expand Down Expand Up @@ -88,6 +92,8 @@ export async function POST(request: NextRequest) {
temperature,
maxTokens,
apiKey: finalApiKey,
azureEndpoint,
azureApiVersion,
responseFormat,
workflowId,
stream,
Expand Down
27 changes: 27 additions & 0 deletions apps/sim/blocks/blocks/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,31 @@ export const AgentBlock: BlockConfig<AgentResponse> = {
}
: undefined, // Show for all models in non-hosted environments
},
{
id: 'azureEndpoint',
title: 'Azure OpenAI Endpoint',
type: 'short-input',
layout: 'full',
password: true,
placeholder: 'https://your-resource.openai.azure.com',
connectionDroppable: false,
condition: {
field: 'model',
value: ['azure/gpt-4o', 'azure/o3', 'azure/o4-mini', 'azure/gpt-4.1', 'azure/model-router'],
Comment thread
waleedlatif1 marked this conversation as resolved.
},
},
{
id: 'azureApiVersion',
title: 'Azure API Version',
type: 'short-input',
layout: 'full',
placeholder: '2024-07-01-preview',
connectionDroppable: false,
condition: {
field: 'model',
value: ['azure/gpt-4o', 'azure/o3', 'azure/o4-mini', 'azure/gpt-4.1', 'azure/model-router'],
},
},
{
id: 'tools',
title: 'Tools',
Expand Down Expand Up @@ -237,6 +262,8 @@ export const AgentBlock: BlockConfig<AgentResponse> = {
memories: { type: 'json', required: false },
model: { type: 'string', required: true },
apiKey: { type: 'string', required: true },
azureEndpoint: { type: 'string', required: false },
azureApiVersion: { type: 'string', required: false },
responseFormat: {
type: 'json',
required: false,
Expand Down
28 changes: 28 additions & 0 deletions apps/sim/executor/handlers/agent/agent-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1232,5 +1232,33 @@ describe('AgentBlockHandler', () => {
expect(requestBody.messages[1].content).toBe('What is the weather like?')
expect(requestBody.messages[1]).not.toHaveProperty('conversationId')
})

it('should pass Azure OpenAI parameters through the request pipeline', async () => {
const inputs = {
model: 'azure/gpt-4o',
systemPrompt: 'You are a helpful assistant.',
userPrompt: 'Hello!',
apiKey: 'test-azure-api-key',
azureEndpoint: 'https://my-azure-resource.openai.azure.com',
azureApiVersion: '2024-07-01-preview',
temperature: 0.7,
}

mockGetProviderFromModel.mockReturnValue('azure-openai')

await handler.execute(mockBlock, inputs, mockContext)

expect(mockFetch).toHaveBeenCalledWith(expect.any(String), expect.any(Object))

const fetchCall = mockFetch.mock.calls[0]
const requestBody = JSON.parse(fetchCall[1].body)

// Check that Azure parameters are included in the request
expect(requestBody.azureEndpoint).toBe('https://my-azure-resource.openai.azure.com')
expect(requestBody.azureApiVersion).toBe('2024-07-01-preview')
expect(requestBody.provider).toBe('azure-openai')
expect(requestBody.model).toBe('azure/gpt-4o')
expect(requestBody.apiKey).toBe('test-azure-api-key')
})
})
})
4 changes: 4 additions & 0 deletions apps/sim/executor/handlers/agent/agent-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ export class AgentBlockHandler implements BlockHandler {
temperature: inputs.temperature,
maxTokens: inputs.maxTokens,
apiKey: inputs.apiKey,
azureEndpoint: inputs.azureEndpoint,
azureApiVersion: inputs.azureApiVersion,
responseFormat,
workflowId: context.workflowId,
stream: streaming,
Expand Down Expand Up @@ -386,6 +388,8 @@ export class AgentBlockHandler implements BlockHandler {
temperature: providerRequest.temperature,
maxTokens: providerRequest.maxTokens,
apiKey: finalApiKey,
azureEndpoint: providerRequest.azureEndpoint,
azureApiVersion: providerRequest.azureApiVersion,
responseFormat: providerRequest.responseFormat,
workflowId: providerRequest.workflowId,
stream: providerRequest.stream,
Expand Down
2 changes: 2 additions & 0 deletions apps/sim/executor/handlers/agent/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export interface AgentInputs {
temperature?: number
maxTokens?: number
apiKey?: string
azureEndpoint?: string
azureApiVersion?: string
}

export interface ToolInput {
Expand Down
2 changes: 2 additions & 0 deletions apps/sim/lib/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export const env = createEnv({
NODE_ENV: z.string().optional(),
GITHUB_TOKEN: z.string().optional(),
ELEVENLABS_API_KEY: z.string().min(1).optional(),
AZURE_OPENAI_ENDPOINT: z.string().url().optional(),
AZURE_OPENAI_API_VERSION: z.string().optional(),
Comment thread
waleedlatif1 marked this conversation as resolved.

// OAuth blocks (all optional)
GOOGLE_CLIENT_ID: z.string().optional(),
Expand Down
Loading