import type { CompletionRequest } from '../types/messages.js'; import type { NexusResponse } from '../types/response.js'; import { type EmbeddingProvider } from '../hallucination/retrieval.js'; /** Options for the semantic response cache. */ export interface SemanticCacheOptions { /** Turns it on. Off by default, and then every lookup misses. */ enabled?: boolean; /** Cosine similarity at which a cached answer is reused, from 0 to 1. Defaults to 0.88. */ similarityThreshold?: number; /** Entries kept before the oldest is dropped. Defaults to 500. */ maxEntries?: number; /** Lifetime of an entry, in seconds. Defaults to 5 minutes. */ ttlSeconds?: number; /** Embeds requests. Defaults to hashed term vectors, which need no provider. */ embed?: EmbeddingProvider; } /** * Reuses a cached response for a request that means nearly the same as an earlier one, not only one * that is identical. */ export declare class SemanticCache { private options; private entries; private embed; constructor(options?: SemanticCacheOptions); /** * The cached response for the most similar earlier request above the threshold, or `undefined`. */ get(request: CompletionRequest): Promise; /** Caches a response under its request's embedding. */ set(key: string, request: CompletionRequest, response: NexusResponse): Promise; /** Removes every entry. */ clear(): void; }