Documentation
¶
Overview ¶
Package embedder turns text into vectors via an OpenAI-compatible /v1/embeddings endpoint — llama.cpp, Ollama, vLLM, LM Studio or any gateway that speaks the same shape. Everything runs against a URL you control; there is no cloud SDK and no credential handling here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmbedMetrics ¶
type EmbedMetrics struct {
CacheHits int64 `json:"cacheHits"`
EmbedCalls int64 `json:"embedCalls"`
}
EmbedMetrics holds cache and API call counters.
type Embedder ¶
type Embedder struct {
// contains filtered or unexported fields
}
Embedder generates vector embeddings through an OpenAI-compatible gateway, memoizing exact-text lookups so repeated queries cost nothing.
func NewEmbedder ¶
func NewEmbedder(_ context.Context, endpoint, model string, outputDims, maxInputChars int, logger zerolog.Logger) (*Embedder, error)
NewEmbedder creates an Embedder against an OpenAI-compatible endpoint. outputDims reduces the output dimension (0 = model native); it is applied client-side as a Matryoshka truncation, see truncateNormalize. maxInputChars hard-caps input length before the call (0 = defaultMaxInputChars).
func (*Embedder) EmbedBatch ¶
EmbedBatch returns embeddings for multiple texts, preserving input order. It issues up to embedBatchConcurrency requests concurrently and fails fast on the first error, cancelling the rest.
func (*Embedder) EmbedDocument ¶
EmbedDocument returns the embedding vector for a document to be indexed.
func (*Embedder) EmbedQuery ¶
EmbedQuery returns the embedding vector for a search query.
func (*Embedder) Metrics ¶
func (e *Embedder) Metrics() EmbedMetrics
Metrics returns a snapshot of cache hit and API call counters.