-
-
Notifications
You must be signed in to change notification settings - Fork 6
Integrate Azure Foundry GPT 5.5 model #607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6cca4ee
ed5de32
bdd0476
22bbebd
74c3853
217eb5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,9 @@ 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)) | ||
|
|
@@ -21,7 +23,7 @@ export function generateUUID(): string { | |
| */ | ||
| export { generateUUID as nanoid }; | ||
|
|
||
| export async function getModel(requireVision: boolean = false) { | ||
| export async function getModel(requireVision: boolean = false): Promise<LanguageModel> { | ||
| const selectedModel = await getSelectedModel(); | ||
|
|
||
| const xaiApiKey = process.env.XAI_API_KEY; | ||
|
|
@@ -31,6 +33,10 @@ export async function getModel(requireVision: boolean = false) { | |
| 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'; | ||
|
|
||
| if (selectedModel) { | ||
| switch (selectedModel) { | ||
|
|
@@ -76,10 +82,61 @@ export async function getModel(requireVision: boolean = false) { | |
| console.error('User selected "GPT-5.1" but OPENAI_API_KEY is not set.'); | ||
| throw new Error('Selected model is not configured.'); | ||
| } | ||
| case 'Azure GPT 5.5': | ||
| if (azureEndpoint && azureApiKey) { | ||
| const azureOpenAI = createOpenAI({ | ||
| baseURL: azureEndpoint, | ||
| apiKey: azureApiKey, | ||
| }); | ||
| try { | ||
| return azureOpenAI(azureDeploymentName); | ||
| } catch (error) { | ||
| console.error('Selected model "Azure GPT 5.5" (via endpoint) failed to initialize.', error); | ||
| throw new Error('Failed to initialize selected model.'); | ||
| } | ||
| } else if (azureResourceName && azureApiKey) { | ||
| const azure = createAzure({ | ||
| resourceName: azureResourceName, | ||
| apiKey: azureApiKey, | ||
| }); | ||
| try { | ||
| return azure(azureDeploymentName) as unknown as LanguageModel; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check the `@ai-sdk/azure` package type definitions
cat node_modules/@ai-sdk/azure/package.json | jq '.version, .types'
# Search for type definitions and exported interfaces
fd -e d.ts -e ts . node_modules/@ai-sdk/azure --exec cat {} \; | rg -A 5 'createAzure|LanguageModel'Repository: QueueLab/QCX Length of output: 242 🌐 Web query:
💡 Result: In Citations: 🏁 Script executed: # First, locate and examine the lib/utils/index.ts file
cat -n lib/utils/index.ts | head -100Repository: QueueLab/QCX Length of output: 4692 🏁 Script executed: # Get more context around line 91
sed -n '80,100p' lib/utils/index.tsRepository: QueueLab/QCX Length of output: 948 🏁 Script executed: # Check imports at the top of the file
head -30 lib/utils/index.tsRepository: QueueLab/QCX Length of output: 1076 Remove the double type cast on the Azure provider. The expression
Since the Azure provider follows the same invocation pattern ( 🤖 Prompt for AI Agents |
||
| } catch (error) { | ||
| console.error('Selected model "Azure GPT 5.5" (via resource) failed to initialize.', error); | ||
| throw new Error('Failed to initialize selected model.'); | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } else { | ||
| console.error('User selected "Azure GPT 5.5" but Azure environment variables are not set.'); | ||
| throw new Error('Selected model is not configured.'); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Default behavior: Azure -> Gemini -> Grok -> Bedrock -> OpenAI | ||
| if (azureEndpoint && azureApiKey) { | ||
| const azureOpenAI = createOpenAI({ | ||
| baseURL: azureEndpoint, | ||
| apiKey: azureApiKey, | ||
| }); | ||
| try { | ||
| return azureOpenAI(azureDeploymentName); | ||
| } catch (error) { | ||
| console.warn('Azure OpenAI API (via endpoint) unavailable, falling back to next provider:', error); | ||
| } | ||
| } | ||
|
|
||
| if (azureResourceName && azureApiKey) { | ||
| const azure = createAzure({ | ||
| resourceName: azureResourceName, | ||
| apiKey: azureApiKey, | ||
| }); | ||
| try { | ||
| return azure(azureDeploymentName) as unknown as LanguageModel; | ||
| } catch (error) { | ||
| console.warn('Azure OpenAI API (via resource) unavailable, falling back to next provider:', error); | ||
| } | ||
| } | ||
|
|
||
| // Default behavior: Gemini -> Grok -> Bedrock -> OpenAI | ||
| if (gemini3ProApiKey) { | ||
| const google = createGoogleGenerativeAI({ | ||
| apiKey: gemini3ProApiKey, | ||
|
|
@@ -103,6 +160,7 @@ export async function getModel(requireVision: boolean = false) { | |
| } | ||
| } | ||
|
|
||
|
|
||
| if (awsAccessKeyId && awsSecretAccessKey) { | ||
| const bedrock = createAmazonBedrock({ | ||
| bedrockOptions: { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.