/** * Agentic QE v3 - LRU Cache for LLM Responses * ADR-011: LLM Provider System for Quality Engineering * * Provides efficient caching of LLM responses to reduce costs and latency * for repeated queries. Uses LRU (Least Recently Used) eviction policy. */ import { CacheEntry, LLMCacheConfig, LLMCacheStats, LLMResponse, EmbeddingResponse, CompletionResponse } from './interfaces'; /** * Default cache configuration */ export declare const DEFAULT_CACHE_CONFIG: LLMCacheConfig; /** * Type for cacheable response types */ export type CacheableResponse = LLMResponse | EmbeddingResponse | CompletionResponse; /** * LRU Cache implementation for LLM responses */ export declare class LLMCache { private cache; private accessOrder; private readonly config; private hits; private misses; private evictions; constructor(config?: Partial); /** * Generate a cache key from request parameters */ static generateKey(type: 'generation' | 'embedding' | 'completion', input: string, options?: { model?: string; temperature?: number; maxTokens?: number; systemPrompt?: string; }): string; /** * Get a cached value */ get(key: string): T | undefined; /** * Store a value in the cache */ set(key: string, value: T, ttlMs?: number): void; /** * Check if a key exists and is not expired */ has(key: string): boolean; /** * Delete a cached value */ delete(key: string): boolean; /** * Clear all cached values */ clear(): void; /** * Get cache statistics */ getStats(): LLMCacheStats; /** * Get all cached keys */ keys(): string[]; /** * Get entries for export/persistence */ entries(): Array<[string, CacheEntry]>; /** * Import entries from persistence */ import(entries: Array<[string, CacheEntry]>): void; /** * Prune expired entries */ pruneExpired(): number; /** * Update the LRU access order */ private updateAccessOrder; /** * Evict the least recently used entry */ private evictLRU; /** * Estimate the size of a cached value in bytes */ private estimateSize; } /** * Specialized cache for LLM responses with request-specific key generation */ export declare class LLMResponseCache { private generationCache; private embeddingCache; private completionCache; private readonly config; constructor(config?: Partial); /** * Get a cached generation response */ getGeneration(input: string, options?: { model?: string; temperature?: number; maxTokens?: number; systemPrompt?: string; }): LLMResponse | undefined; /** * Cache a generation response */ setGeneration(input: string, response: LLMResponse, options?: { model?: string; temperature?: number; maxTokens?: number; systemPrompt?: string; }, ttlMs?: number): void; /** * Get a cached embedding response */ getEmbedding(text: string, options?: { model?: string; }): EmbeddingResponse | undefined; /** * Cache an embedding response */ setEmbedding(text: string, response: EmbeddingResponse, options?: { model?: string; }, ttlMs?: number): void; /** * Get a cached completion response */ getCompletion(prompt: string, options?: { model?: string; temperature?: number; maxTokens?: number; }): CompletionResponse | undefined; /** * Cache a completion response */ setCompletion(prompt: string, response: CompletionResponse, options?: { model?: string; temperature?: number; maxTokens?: number; }, ttlMs?: number): void; /** * Get combined cache statistics */ getStats(): { generation: LLMCacheStats; embedding: LLMCacheStats; completion: LLMCacheStats; total: LLMCacheStats; }; /** * Clear all caches */ clear(): void; /** * Prune expired entries from all caches */ pruneExpired(): number; } //# sourceMappingURL=cache.d.ts.map