Embedder
Turns text into a vector. kmemo ships no embedding implementation on purpose: you bring your own (OpenAI, Cohere, Voyage, a local ONNX model, whatever your stack already pays for), and kmemo stays free of provider SDKs.
Implementations must be deterministic and stable: the same text must map to the same vector for the lifetime of a cache, and every vector must have the same dimension. Switching embedding model invalidates every entry that came before it — use a fresh store, or a different scope, when you do.
Implementations are called from coroutines and must be safe to call concurrently.
val embedder = Embedder { text -> openAi.embeddings(model = "text-embedding-3-small", input = text).vector() }Inheritors
Functions
Embeds a single text. Vectors need not be normalized; kmemo normalizes on the way in.
Wraps this embedder in a RetryingEmbedder that retries transient failures with jittered backoff.