sfcoe-ailabs
Version:
AI-powered code review tool with static analysis integration for comprehensive code quality assessment.
81 lines (80 loc) • 2.47 kB
TypeScript
import { ReviewHint, ReviewResponse } from './index.js';
export default abstract class AIProvider {
private apiKey;
private model;
private maxTokens;
private apiEndpoint?;
private apiVersion?;
/**
* Creates a new AI provider instance
*
* @param apiKey - The API key for the AI provider
* @param model - The model name to use for AI processing
*/
constructor(apiKey: string, model: string, apiEndpoint: string, apiVersion: string);
/**
* Generates a prompt for AI code review based on code snippet and hints
*
* @param codeSnippet - The code to be reviewed
* @param hints - Array of review hints from static analysis tools
* @returns Formatted prompt string for AI review
*/
protected static generatePrompt(codeSnippet: string, hints: ReviewHint[]): string;
/**
* Gets the review instructions for AI providers
*
* @returns The review instructions string
*/
protected static getReviewInstructions(): string;
/**
* Formats review hints into a readable string format
*
* @param hint - The review hint to format
* @returns Formatted hint string
*/
private static formatHints;
/**
* Gets the API endpoint for the AI provider, if set
*
* @returns The API endpoint for the AI provider, if set
*/
getAPIEndpoint(): string | undefined;
/**
* Gets the API version for the AI provider, if set
*
* @returns The API version for the AI provider, if set
*/
getAPIVersion(): string | undefined;
/**
* Gets the AI model name
*
* @returns The model name
*/
getModel(): string;
/**
* Gets the API key
*
* @returns The API key
*/
getApiKey(): string;
/**
* Gets the maximum number of tokens for AI requests
*
* @returns The maximum token count
*/
getMaxTokens(): number;
/**
* Sets the maximum number of tokens for AI requests
*
* @param maxTokens - The maximum token count to set
*/
setMaxTokens(maxTokens: number): void;
/**
* Reviews code using the AI provider
*
* @param codeSnippet - The code to be reviewed
* @param hints - Array of review hints from static analysis tools
* @returns Promise that resolves to the AI review response
*/
abstract reviewCode(codeSnippet: string, hints: ReviewHint[]): Promise<ReviewResponse>;
}