/** * Interface for token count estimates */ export interface TokenEstimate { estimated: number; method: 'gpt-tokenizer' | 'character-based' | 'word-based'; } /** * Service for estimating token counts in text * Provides multiple estimation methods including GPT tokenizer fallback */ export declare class TokenEstimatorService { /** * Estimate token count based on text using the best available method * @param text The text to estimate token count for * @returns Token estimate with method used */ static estimateTokenCount(text: string): TokenEstimate; /** * Try to load the GPT tokenizer if available * @returns The tokenizer or null if not available */ private static tryLoadGptTokenizer; /** * Estimate tokens using character-based method * @param text The text to estimate * @returns Token estimate */ private static estimateByCharacters; /** * Estimate tokens using word-based method * @param text The text to estimate * @returns Token estimate */ private static estimateByWords; /** * Calculate tokens per second based on token count and execution time * @param tokenCount Number of tokens * @param executionTimeSeconds Execution time in seconds * @returns Tokens per second as a formatted string */ static calculateTokensPerSecond(tokenCount: number, executionTimeSeconds: number): string; /** * Estimate token count for system message and user prompt combined * @param systemMessage The system message * @param userPrompt The user prompt * @returns Combined token estimate */ static estimateInputTokens(systemMessage: string, userPrompt: string): TokenEstimate; /** * Estimate tokens for a conversation with multiple messages * @param messages Array of message strings * @returns Token estimate for the entire conversation */ static estimateConversationTokens(messages: string[]): TokenEstimate; /** * Check if text exceeds a token limit * @param text The text to check * @param limit The token limit * @returns Object indicating if limit is exceeded and by how much */ static checkTokenLimit(text: string, limit: number): { exceeded: boolean; estimated: number; limit: number; overage: number; percentage: number; }; /** * Truncate text to fit within a token limit * @param text The text to truncate * @param limit The token limit * @param method Truncation method ('end' | 'start' | 'middle') * @returns Truncated text and information about the truncation */ static truncateToTokenLimit(text: string, limit: number, method?: 'end' | 'start' | 'middle'): { truncatedText: string; originalTokens: number; finalTokens: number; truncated: boolean; }; /** * Get statistics about text in terms of characters, words, and estimated tokens * @param text The text to analyze * @returns Detailed statistics */ static getTextStatistics(text: string): { characters: number; charactersNoSpaces: number; words: number; lines: number; tokens: TokenEstimate; averageWordsPerToken: number; averageCharsPerToken: number; }; } //# sourceMappingURL=token-estimator.service.d.ts.map