* 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
40 lines
997 B
JavaScript
40 lines
997 B
JavaScript
/**
|
|
* google.js
|
|
* AI provider implementation for Google AI models using Vercel AI SDK.
|
|
*/
|
|
|
|
import { createGoogleGenerativeAI } from '@ai-sdk/google';
|
|
import { BaseAIProvider } from './base-provider.js';
|
|
|
|
export class GoogleAIProvider extends BaseAIProvider {
|
|
constructor() {
|
|
super();
|
|
this.name = 'Google';
|
|
}
|
|
|
|
/**
|
|
* Creates and returns a Google AI client instance.
|
|
* @param {object} params - Parameters for client initialization
|
|
* @param {string} params.apiKey - Google API key
|
|
* @param {string} [params.baseURL] - Optional custom API endpoint
|
|
* @returns {Function} Google AI client function
|
|
* @throws {Error} If API key is missing or initialization fails
|
|
*/
|
|
getClient(params) {
|
|
try {
|
|
const { apiKey, baseURL } = params;
|
|
|
|
if (!apiKey) {
|
|
throw new Error('Google API key is required.');
|
|
}
|
|
|
|
return createGoogleGenerativeAI({
|
|
apiKey,
|
|
...(baseURL && { baseURL })
|
|
});
|
|
} catch (error) {
|
|
this.handleError('client initialization', error);
|
|
}
|
|
}
|
|
}
|