Skip to content
Closed
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
7 changes: 7 additions & 0 deletions apps/sim/app/api/copilot/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ export async function POST(req: NextRequest) {
apiVersion: 'preview',
endpoint: env.AZURE_OPENAI_ENDPOINT,
}
} else if (providerEnv === 'azure-anthropic') {
providerConfig = {
provider: 'azure-anthropic',
model: envModel,
apiKey: env.AZURE_ANTHROPIC_API_KEY,
endpoint: env.AZURE_ANTHROPIC_ENDPOINT,
}
} else if (providerEnv === 'vertex') {
providerConfig = {
provider: 'vertex',
Expand Down
10 changes: 5 additions & 5 deletions apps/sim/blocks/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function getApiKeyCondition() {

/**
* Returns the standard provider credential subblocks used by LLM-based blocks.
* This includes: Vertex AI OAuth, API Key, Azure OpenAI, Vertex AI config, and Bedrock config.
* This includes: Vertex AI OAuth, API Key, Azure (OpenAI + Anthropic), Vertex AI config, and Bedrock config.
*
* Usage: Spread into your block's subBlocks array after block-specific fields
*/
Expand Down Expand Up @@ -111,14 +111,14 @@ export function getProviderCredentialSubBlocks(): SubBlockConfig[] {
},
{
id: 'azureEndpoint',
title: 'Azure OpenAI Endpoint',
title: 'Azure Endpoint',
type: 'short-input',
password: true,
placeholder: 'https://your-resource.openai.azure.com',
placeholder: 'https://your-resource.services.ai.azure.com',
connectionDroppable: false,
condition: {
field: 'model',
value: providers['azure-openai'].models,
value: [...providers['azure-openai'].models, ...providers['azure-anthropic'].models],
},
},
{
Expand Down Expand Up @@ -202,7 +202,7 @@ export function getProviderCredentialSubBlocks(): SubBlockConfig[] {
*/
export const PROVIDER_CREDENTIAL_INPUTS = {
apiKey: { type: 'string', description: 'Provider API key' },
azureEndpoint: { type: 'string', description: 'Azure OpenAI endpoint URL' },
azureEndpoint: { type: 'string', description: 'Azure endpoint URL' },
azureApiVersion: { type: 'string', description: 'Azure API version' },
vertexProject: { type: 'string', description: 'Google Cloud project ID for Vertex AI' },
vertexLocation: { type: 'string', description: 'Google Cloud location for Vertex AI' },
Expand Down
6 changes: 4 additions & 2 deletions apps/sim/executor/handlers/evaluator/evaluator-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ export class EvaluatorBlockHandler implements BlockHandler {
providerRequest.vertexLocation = evaluatorConfig.vertexLocation
}

if (providerId === 'azure-openai') {
if (providerId === 'azure-openai' || providerId === 'azure-anthropic') {
providerRequest.azureEndpoint = inputs.azureEndpoint
providerRequest.azureApiVersion = inputs.azureApiVersion
if (providerId === 'azure-openai') {
providerRequest.azureApiVersion = inputs.azureApiVersion
}
}

if (providerId === 'bedrock') {
Expand Down
12 changes: 8 additions & 4 deletions apps/sim/executor/handlers/router/router-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ export class RouterBlockHandler implements BlockHandler {
providerRequest.vertexLocation = routerConfig.vertexLocation
}

if (providerId === 'azure-openai') {
if (providerId === 'azure-openai' || providerId === 'azure-anthropic') {
providerRequest.azureEndpoint = inputs.azureEndpoint
providerRequest.azureApiVersion = inputs.azureApiVersion
if (providerId === 'azure-openai') {
providerRequest.azureApiVersion = inputs.azureApiVersion
}
}

if (providerId === 'bedrock') {
Expand Down Expand Up @@ -262,9 +264,11 @@ export class RouterBlockHandler implements BlockHandler {
providerRequest.vertexLocation = routerConfig.vertexLocation
}

if (providerId === 'azure-openai') {
if (providerId === 'azure-openai' || providerId === 'azure-anthropic') {
providerRequest.azureEndpoint = inputs.azureEndpoint
providerRequest.azureApiVersion = inputs.azureApiVersion
if (providerId === 'azure-openai') {
providerRequest.azureApiVersion = inputs.azureApiVersion
}
}

if (providerId === 'bedrock') {
Expand Down
1 change: 1 addition & 0 deletions apps/sim/lib/copilot/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const VALID_PROVIDER_IDS: readonly ProviderId[] = [
'openai',
'azure-openai',
'anthropic',
'azure-anthropic',
'google',
'deepseek',
'xai',
Expand Down
8 changes: 7 additions & 1 deletion apps/sim/lib/copilot/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ export type CopilotProviderConfig =
apiVersion?: string
endpoint?: string
}
| {
provider: 'azure-anthropic'
model: string
apiKey?: string
endpoint?: string
}
| {
provider: 'vertex'
model: string
Expand All @@ -155,7 +161,7 @@ export type CopilotProviderConfig =
vertexLocation?: string
}
| {
provider: Exclude<ProviderId, 'azure-openai' | 'vertex'>
provider: Exclude<ProviderId, 'azure-openai' | 'azure-anthropic' | 'vertex'>
model?: string
apiKey?: string
}
5 changes: 5 additions & 0 deletions apps/sim/lib/tokenization/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export const TOKENIZATION_CONFIG = {
confidence: 'high',
supportedMethods: ['heuristic', 'fallback'],
},
'azure-anthropic': {
avgCharsPerToken: 4.5,
confidence: 'high',
supportedMethods: ['heuristic', 'fallback'],
},
google: {
avgCharsPerToken: 5,
confidence: 'medium',
Expand Down
1 change: 1 addition & 0 deletions apps/sim/lib/tokenization/estimators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export function estimateTokenCount(text: string, providerId?: string): TokenEsti
estimatedTokens = estimateOpenAITokens(text)
break
case 'anthropic':
case 'azure-anthropic':
estimatedTokens = estimateAnthropicTokens(text)
break
case 'google':
Expand Down
Loading
Loading