* feat: complete Groq provider integration and add Kimi K2 model - Add missing getRequiredApiKeyName() method to GroqProvider class - Register GroqProvider in ai-services-unified.js PROVIDERS object - Add Groq API key handling to config-manager.js (isApiKeySet and getMcpApiKeyStatus) - Add GROQ_API_KEY to env.example with format hint - Add moonshotai/kimi-k2-instruct model to Groq provider ($1/$3 per 1M tokens, 16k max) - Fix import sorting for linting compliance - Add GroqProvider mock to ai-services-unified tests Fixes missing implementation pieces that prevented Groq provider from working. * chore: improve changeset --------- Co-authored-by: Ben Vargas <ben@example.com> Co-authored-by: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com>
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
/**
|
|
* src/ai-providers/groq.js
|
|
*
|
|
* Implementation for interacting with Groq models
|
|
* using the Vercel AI SDK.
|
|
*/
|
|
|
|
import { createGroq } from '@ai-sdk/groq';
|
|
import { BaseAIProvider } from './base-provider.js';
|
|
|
|
export class GroqProvider extends BaseAIProvider {
|
|
constructor() {
|
|
super();
|
|
this.name = 'Groq';
|
|
}
|
|
|
|
/**
|
|
* Returns the environment variable name required for this provider's API key.
|
|
* @returns {string} The environment variable name for the Groq API key
|
|
*/
|
|
getRequiredApiKeyName() {
|
|
return 'GROQ_API_KEY';
|
|
}
|
|
|
|
/**
|
|
* Creates and returns a Groq client instance.
|
|
* @param {object} params - Parameters for client initialization
|
|
* @param {string} params.apiKey - Groq API key
|
|
* @param {string} [params.baseURL] - Optional custom API endpoint
|
|
* @returns {Function} Groq client function
|
|
* @throws {Error} If API key is missing or initialization fails
|
|
*/
|
|
getClient(params) {
|
|
try {
|
|
const { apiKey, baseURL } = params;
|
|
|
|
if (!apiKey) {
|
|
throw new Error('Groq API key is required.');
|
|
}
|
|
|
|
return createGroq({
|
|
apiKey,
|
|
...(baseURL && { baseURL })
|
|
});
|
|
} catch (error) {
|
|
this.handleError('client initialization', error);
|
|
}
|
|
}
|
|
}
|