Skip to content
Open
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
5 changes: 3 additions & 2 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ NEXT_PUBLIC_COMPOSIO_USER_ID=user@example.com
# NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN=your_mapbox_public_token_here

# AI Provider API Keys
# Azure AI Foundry (Azure OpenAI)
AZURE_RESOURCE_NAME=your_azure_resource_name_here
# Azure AI Foundry
# Set AZURE_ENDPOINT to your Azure AI Foundry inference endpoint URL
# e.g. https://<resource>.services.ai.azure.com/models or https://<resource>.openai.azure.com/openai/deployments/<deployment>/extensions
AZURE_ENDPOINT=your_azure_endpoint_here
AZURE_API_KEY=your_azure_api_key_here
AZURE_DEPLOYMENT_NAME=gpt-5.5
Expand Down
13 changes: 0 additions & 13 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 12 additions & 24 deletions lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { createOpenAI } from '@ai-sdk/openai'
import { createGoogleGenerativeAI } from '@ai-sdk/google'
import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock'
import { createXai } from '@ai-sdk/xai';
import { createAzure } from '@ai-sdk/azure';
import { v4 as uuidv4 } from 'uuid';
import { LanguageModel } from 'ai'

export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
Expand All @@ -23,7 +21,7 @@ export function generateUUID(): string {
*/
export { generateUUID as nanoid };

export async function getModel(requireVision: boolean = false): Promise<LanguageModel> {
export async function getModel(requireVision: boolean = false) {
const selectedModel = await getSelectedModel();

const xaiApiKey = process.env.XAI_API_KEY;
Expand All @@ -33,7 +31,6 @@ export async function getModel(requireVision: boolean = false): Promise<Language
const awsRegion = process.env.AWS_REGION;
const bedrockModelId = process.env.BEDROCK_MODEL_ID || 'anthropic.claude-3-5-sonnet-20241022-v2:0';
const openaiApiKey = process.env.OPENAI_API_KEY;
const azureResourceName = process.env.AZURE_RESOURCE_NAME;
const azureApiKey = process.env.AZURE_API_KEY;
const azureEndpoint = process.env.AZURE_ENDPOINT;
const azureDeploymentName = process.env.AZURE_DEPLOYMENT_NAME || 'gpt-5.5';
Expand Down Expand Up @@ -83,20 +80,15 @@ export async function getModel(requireVision: boolean = false): Promise<Language
throw new Error('Selected model is not configured.');
}
case 'Azure GPT 5.5':
if ((azureResourceName || azureEndpoint) && azureApiKey) {
const azure = createAzure({
resourceName: azureResourceName,
baseURL: azureEndpoint?.replace(/\/v1\/?$/, ''),
if (azureEndpoint && azureApiKey) {
const azureOpenai = createOpenAI({
apiKey: azureApiKey,
baseURL: azureEndpoint,
compatibility: 'compatible',
});
try {
return azure(azureDeploymentName) as unknown as LanguageModel;
} catch (error) {
console.error('Selected model "Azure GPT 5.5" is configured but failed to initialize.', error);
throw new Error('Failed to initialize selected model.');
}
return azureOpenai(azureDeploymentName);
} else {
console.error('User selected "Azure GPT 5.5" but Azure environment variables are not set.');
console.error('User selected "Azure GPT 5.5" but AZURE_ENDPOINT and AZURE_API_KEY are not set.');
throw new Error('Selected model is not configured.');
}
}
Expand Down Expand Up @@ -126,17 +118,13 @@ export async function getModel(requireVision: boolean = false): Promise<Language
}
}

if ((azureResourceName || azureEndpoint) && azureApiKey) {
const azure = createAzure({
resourceName: azureResourceName,
baseURL: azureEndpoint?.replace(/\/v1\/?$/, ''),
if (azureEndpoint && azureApiKey) {
const azureOpenai = createOpenAI({
apiKey: azureApiKey,
baseURL: azureEndpoint,
compatibility: 'compatible',
});
try {
return azure(azureDeploymentName) as unknown as LanguageModel;
} catch (error) {
console.warn('Azure OpenAI API unavailable, falling back to next provider:', error);
}
return azureOpenai(azureDeploymentName);
}

if (awsAccessKeyId && awsSecretAccessKey) {
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
"dependencies": {
"@ai-sdk/amazon-bedrock": "^1.1.6",
"@ai-sdk/anthropic": "^1.2.12",
"@ai-sdk/azure": "^3.0.64",
"@ai-sdk/google": "^1.2.22",
"@ai-sdk/openai": "^1.3.24",
"@ai-sdk/xai": "^1.2.18",
"@composio/core": "^0.3.3",

"@google-cloud/storage": "^7.18.0",
"@google/generative-ai": "^0.24.1",
"@heroicons/react": "^2.2.0",
Expand Down