UNPKG

@entro314labs/ai-changelog-generator

Version:

AI-powered changelog generator with MCP server support - works with most providers, online and local models

108 lines (107 loc) 4.26 kB
export interface ProviderMessage { role: string; content: any; } export interface ProviderCapabilities { [key: string]: boolean | number | string | undefined; } export type ProviderConfig = Record<string, any>; export type ProviderResult = Record<string, any>; export type ProviderModelDescriptor = string | Record<string, any>; export declare class BaseProvider { [key: string]: any; config: ProviderConfig; modelConfig: ProviderConfig | null; capabilities: ProviderCapabilities; constructor(config: ProviderConfig); /** * Returns the name of the provider. * @returns {string} The provider's name (e.g., 'openai', 'azure'). */ getName(): void; /** * Checks if the provider is available and configured correctly. * @returns {boolean} True if the provider is available, false otherwise. */ isAvailable(): boolean; /** * Generates a completion from the AI model. * @param {Array<object>} messages - The array of messages for the conversation. * @param {object} options - Additional options for the completion (e.g., max_tokens). * @returns {Promise<object>} The AI's response. */ generateCompletion(_messages: ProviderMessage[], _options?: ProviderConfig): Promise<ProviderResult>; /** * Recommends a model based on the commit details. * @param {object} commitDetails - Details about the commit (e.g., files changed, lines changed). * @returns {object} The recommended model and reason. */ getModelRecommendation(_commitDetails: ProviderConfig): ProviderResult; /** * Selects optimal model based on analysis * @param {object} commitInfo - Commit analysis information * @returns {Promise<object>} Optimal model selection */ selectOptimalModel(commitInfo: ProviderConfig): Promise<ProviderResult>; /** * Validates if a specific model is available for the provider. * @param {string} modelName - The name of the model to validate. * @returns {Promise<object>} An object indicating availability and capabilities. */ validateModelAvailability(_modelName: string): Promise<ProviderResult>; /** * Tests the connection to the provider's API. * @returns {Promise<object>} An object indicating success or failure. */ testConnection(): Promise<ProviderResult>; /** * Gets the capabilities of the provider or a specific model. * @param {string} [modelName] - Optional model name to get specific capabilities. * @returns {object} An object listing the provider's capabilities. */ getCapabilities(_modelName?: string): ProviderCapabilities; /** * Gets available models for this provider * @returns {Promise<Array>} List of available models */ getAvailableModels(): ProviderModelDescriptor[] | Promise<ProviderModelDescriptor[]>; /** * Gets the default model for this provider * @returns {string} Default model name */ getDefaultModel(): string; /** * Gets provider configuration * @returns {object} Provider configuration */ getConfiguration(): ProviderConfig; /** * Gets required environment variables for this provider * @returns {Array<string>} List of required env vars */ getRequiredEnvVars(): string[]; /** * Gets provider information for display purposes. * @returns {string} Provider information string. */ getProviderInfo(): string | ProviderConfig; /** * Test a specific model * @param {string} modelName - Model to test * @returns {Promise<object>} Test result */ testModel(modelName: string): Promise<ProviderResult>; /** * Gets provider-specific configuration for the model config system * @returns {object} Provider model configuration */ getProviderModelConfig(): ProviderConfig; /** * Gets provider configuration for client initialization * @returns {object} Provider configuration */ getProviderConfig(): ProviderConfig; buildClientOptions(extraDefaults?: ProviderConfig): ProviderConfig; handleProviderError(error: Error, operation: string, context?: ProviderConfig): ProviderResult; } export default BaseProvider;