@callmedayz/ai-prompt-toolkit
Version:
Professional AI prompt engineering toolkit with advanced template features, real-time dashboards, conditional logic, template inheritance, live monitoring, OpenRouter integration, and 310+ model support
63 lines • 1.87 kB
TypeScript
import { OpenRouterClient } from './openrouter-client';
import { SupportedModel, TokenCountResult } from './types';
/**
* Advanced tokenization service with caching and multiple counting methods
*/
export declare class TokenizationService {
private client;
private cache;
private cacheTimeout;
constructor(client: OpenRouterClient);
/**
* Get accurate token count using OpenRouter API with caching
*/
getAccurateTokenCount(text: string, model?: SupportedModel, useCache?: boolean): Promise<TokenCountResult>;
/**
* Get token count with completion and generation details for maximum accuracy
*/
getDetailedTokenCount(text: string, model?: SupportedModel): Promise<TokenCountResult & {
generationId?: string;
nativeTokens?: number;
}>;
/**
* Batch tokenize multiple texts efficiently
*/
batchTokenize(texts: string[], model?: SupportedModel): Promise<TokenCountResult[]>;
/**
* Compare estimation vs actual token count
*/
compareTokenCounts(text: string, model?: SupportedModel): Promise<{
estimated: TokenCountResult;
actual: TokenCountResult;
difference: number;
accuracy: number;
}>;
/**
* Fallback estimation method
*/
private estimateTokens;
/**
* Simple hash function for cache keys
*/
private hashText;
/**
* Clear the token count cache
*/
clearCache(): void;
/**
* Get cache statistics
*/
getCacheStats(): {
size: number;
keys: string[];
};
/**
* Create tokenization service from API key
*/
static fromApiKey(apiKey: string): TokenizationService;
/**
* Create tokenization service from environment
*/
static fromEnv(): TokenizationService;
}
//# sourceMappingURL=tokenization-service.d.ts.map