import { VectorStore } from './VectorStore'; import { EmbeddingService } from './EmbeddingService'; /** * Result of a cache lookup operation. */ export interface CacheResult { hit: boolean; result?: T; similarity?: number; taskId?: string; latencyMs: number; } /** * SemanticCache implements the "short-circuit" logic for semantic caching. * It checks if a similar task has been resolved before and returns cached results. */ export declare class SemanticCache { private vectorStore; private embeddingService; private threshold; private cacheHits; private cacheMisses; constructor(vectorStore: VectorStore, embeddingService: EmbeddingService, threshold?: number); /** * Check if a similar task exists in the cache. * Returns cached result if similarity exceeds threshold. * * @param taskDescription - Description of the task to check * @returns CacheResult with hit status and cached data if found */ check(taskDescription: string): Promise>; /** * Store a task result in the cache for future lookups. * * @param taskId - Unique identifier for the task * @param taskDescription - Description of the task * @param result - Result to cache * @param metadata - Additional metadata to store */ store(taskId: string, taskDescription: string, result: T, metadata?: Record): Promise; /** * Calculate cosine similarity between two task descriptions. * Useful for debugging and testing. * * @param taskA - First task description * @param taskB - Second task description * @returns Similarity score between 0 and 1 */ calculateSimilarity(taskA: string, taskB: string): Promise; /** * Get cache performance metrics. */ getMetrics(): { hits: number; misses: number; total: number; hitRate: number; }; /** * Reset cache metrics. */ resetMetrics(): void; /** * Update the similarity threshold. * * @param threshold - New threshold value (0-1) */ setThreshold(threshold: number): void; /** * Get the current similarity threshold. */ getThreshold(): number; /** * Get the total number of cached tasks. */ getCacheSize(): Promise; /** * Clear all cached tasks. */ clear(): Promise; } //# sourceMappingURL=SemanticCache.d.ts.map