Documentation
¶
Overview ¶
Package nexus is a weave embedder that sends every request through a nexus gateway, so embedding spend lands on the same usage records, keys and budgets as the rest of your model traffic.
It lives in its own module, github.com/xraph/weave/embedder/nexus, so the root weave module never pulls in nexus. Build it with:
emb := nexus.New(ext.Gateway, "text-embedding-3-small", 1536,
nexus.WithProvider("knowledge"))
Every call needs a weave tenant on the context (weave.WithTenant). The spend goes to the nexus tenant on the context when the host set one with nexus's pipeline.WithTenantID, and otherwise to the weave tenant passed through WithTenantMapper (by default, unchanged).
Every request asks for exactly the configured dimensions, so the provider nexus routes to has to be able to shorten vectors for the model. On OpenAI's own endpoint that means text-embedding-3-small or text-embedding-3-large.
Index ¶
Constants ¶
This section is empty.
Variables ¶
ErrGatewayUnavailable is returned while gw() still answers nil, and while the gateway it answered is not initialized yet (wrapping nexus.ErrNotInitialized). Both clear up once nexus has started, so a host can retry.
Functions ¶
func New ¶
func New(gw func() *nexusgw.Gateway, model string, dimensions int, opts ...Option) embedder.Embedder
New returns an embedder that calls gw's engine with model and asks for vectors of exactly dimensions numbers. It does not call gw. The first Embed resolves it and caches the first non-nil gateway, so a host can pass nexus's extension method value (ext.Gateway) before nexus has started.
Types ¶
type Embedder ¶
type Embedder struct {
// contains filtered or unexported fields
}
Embedder embeds texts through a nexus gateway. Build it with New.
func (*Embedder) Describe ¶
func (e *Embedder) Describe() weave.ComponentInfo
Describe reports the nexus embedder, its model and dimensions, and the provider when WithProvider named one.
func (*Embedder) Dimensions ¶
Dimensions returns the configured vector size.
type Option ¶
type Option func(*Embedder)
Option configures the nexus embedder.
func WithBatchSize ¶
WithBatchSize caps the texts per nexus request (default 256). A value below 1 keeps the default.
func WithProvider ¶
WithProvider names the nexus provider every request goes to, by its registered name (EmbeddingRequest.Provider). Without it nexus routes by model, which picks the wrong provider and key when a chat provider also lists the embedding model.
func WithTenantMapper ¶
WithTenantMapper turns the weave tenant into the nexus tenant ID the request is attributed to. The default passes it through unchanged, which suits hosts whose weave tenants are nexus tenant IDs. A mapper that returns "" refuses the call with weave.ErrTenantRequired, and its error comes back wrapped. A nil fn keeps the default.