Feat/add.azure.and.other.providers (#607)
* fix: claude-4 not having the right max_tokens * feat: add bedrock support * chore: fix package-lock.json * fix: rename baseUrl to baseURL * feat: add azure support * fix: final touches of azure integration * feat: add google vertex provider * chore: fix tests and refactor task-manager.test.js * chore: move task 92 to 94
This commit is contained in:
52
src/ai-providers/azure.js
Normal file
52
src/ai-providers/azure.js
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* azure.js
|
||||
* AI provider implementation for Azure OpenAI models using Vercel AI SDK.
|
||||
*/
|
||||
|
||||
import { createAzure } from '@ai-sdk/azure';
|
||||
import { BaseAIProvider } from './base-provider.js';
|
||||
|
||||
export class AzureProvider extends BaseAIProvider {
|
||||
constructor() {
|
||||
super();
|
||||
this.name = 'Azure OpenAI';
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates Azure-specific authentication parameters
|
||||
* @param {object} params - Parameters to validate
|
||||
* @throws {Error} If required parameters are missing
|
||||
*/
|
||||
validateAuth(params) {
|
||||
if (!params.apiKey) {
|
||||
throw new Error('Azure API key is required');
|
||||
}
|
||||
|
||||
if (!params.baseURL) {
|
||||
throw new Error(
|
||||
'Azure endpoint URL is required. Set it in .taskmasterconfig global.azureBaseURL or models.[role].baseURL'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns an Azure OpenAI client instance.
|
||||
* @param {object} params - Parameters for client initialization
|
||||
* @param {string} params.apiKey - Azure OpenAI API key
|
||||
* @param {string} params.baseURL - Azure OpenAI endpoint URL (from .taskmasterconfig global.azureBaseURL or models.[role].baseURL)
|
||||
* @returns {Function} Azure OpenAI client function
|
||||
* @throws {Error} If required parameters are missing or initialization fails
|
||||
*/
|
||||
getClient(params) {
|
||||
try {
|
||||
const { apiKey, baseURL } = params;
|
||||
|
||||
return createAzure({
|
||||
apiKey,
|
||||
baseURL
|
||||
});
|
||||
} catch (error) {
|
||||
this.handleError('client initialization', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user