Documentation
¶
Overview ¶
Package embedding provides abstractions for text embedding providers and vector utility functions for computing distances and aggregations.
For concrete provider implementations, see the vendor modules:
- github.com/kbukum/gokit/llm/providers/openai (OpenAI-compatible)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmbedInput ¶
type EmbedInput interface {
// contains filtered or unexported methods
}
EmbedInput is the sealed interface for embedding inputs.
type EmbedRequest ¶
type EmbedRequest struct {
Model ai.Model `json:"model"`
Inputs []EmbedInput `json:"inputs"`
Options map[string]any `json:"options,omitempty"`
}
EmbedRequest carries embedding inputs and provider-specific options.
type EmbedResponse ¶
type EmbedResponse struct {
Embedding Embedding `json:"embedding"`
Embeddings []Embedding `json:"embeddings,omitempty"`
Model ai.Model `json:"model"`
Usage ai.Usage `json:"usage,omitempty"`
}
EmbedResponse carries normalized embeddings, model echo, and usage.
type Embedding ¶
type Embedding struct {
Vector []float32 `json:"vector"`
Dimensions int `json:"dimensions"`
Index int `json:"index"`
}
Embedding is a normalized vector with its request index.
type Provider ¶
type Provider interface {
provider.RequestResponse[EmbedRequest, EmbedResponse]
EmbedBatch(ctx context.Context, reqs []EmbedRequest) ([]EmbedResponse, error)
}
Provider generates vector embeddings for text and multimodal inputs.
Per locked decision D7 (NATIVE EMBED), Provider natively embeds provider.RequestResponse so any embedding provider drops into dag / pipeline / chain / worker consumers without a bridge. The single-request method IS Execute (the canonical RR method); EmbedBatch is the batched extension.
Required methods (by transitive embedding):
- Name() string // provider.Provider
- IsAvailable(ctx context.Context) bool // provider.Provider
- Execute(ctx, EmbedRequest) (EmbedResponse, error) // RequestResponse
- EmbedBatch(ctx, []EmbedRequest) ([]EmbedResponse, error)