UNPKG

@bobmatnyc/ai-code-review

Version:

A TypeScript-based tool for automated code reviews using AI models from Google Gemini, Anthropic Claude, and OpenRouter

61 lines (60 loc) 2.32 kB
/** * @fileoverview Abstract base class for token and cost estimators. * * This module provides a common implementation for token estimators that * can be extended by specific provider implementations. */ import { CostInfo, TokenEstimator } from './baseEstimator'; /** * Abstract base class for token and cost estimators */ export declare abstract class AbstractTokenEstimator implements TokenEstimator { /** * Estimate the number of tokens in a text * @param text Text to estimate tokens for * @param modelName Optional model name to use for tokenization * @returns Estimated token count */ estimateTokenCount(text: string, modelName?: string): number; /** * Calculate the cost for a given number of input and output tokens * @param inputTokens Number of input tokens * @param outputTokens Number of output tokens * @param modelName Name of the model (optional, uses default if not provided) * @returns Estimated cost in USD */ abstract calculateCost(inputTokens: number, outputTokens: number, modelName?: string): number; /** * Format a cost value as a currency string * @param cost Cost value in USD * @returns Formatted cost string */ formatCost(cost: number): string; /** * Get cost information based on token counts * @param inputTokens Number of input tokens * @param outputTokens Number of output tokens * @param modelName Name of the model (optional) * @returns Cost information */ getCostInfo(inputTokens: number, outputTokens: number, modelName?: string): CostInfo; /** * Get cost information based on text * @param inputText Input text * @param outputText Output text * @param modelName Name of the model (optional) * @returns Cost information */ getCostInfoFromText(inputText: string, outputText: string, modelName?: string): CostInfo; /** * Get the default model name for this estimator * @returns Default model name */ abstract getDefaultModel(): string; /** * Check if this estimator supports a given model * @param modelName Name of the model to check * @returns True if the model is supported, false otherwise */ abstract supportsModel(modelName: string): boolean; }