Expand description
§Semantic Cache
LRU-evicting similarity cache for prompt/response pairs.
Prompts are embedded into a 64-dimensional TF-IDF-style vector using FNV-1a token hashing, then L2-normalised. Cache lookup returns a stored response if the cosine similarity between the query embedding and any stored embedding is at or above the configured threshold.
Structs§
- Cache
Entry - A single entry stored in the
SemanticCache. - Cache
Stats - Aggregate statistics for a
SemanticCache. - Semantic
Cache - LRU-evicting semantic similarity cache.
Functions§
- cosine_
similarity - Cosine similarity between two equal-length vectors.
- embed_
prompt - Produce a deterministic TF-IDF-style 64-dim embedding for
prompt.