Documentation
¶
Overview ¶
Package embedding defines the Embedder interface and implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachingEmbedder ¶ added in v0.2.0
type CachingEmbedder struct {
// contains filtered or unexported fields
}
CachingEmbedder wraps an Embedder with an EmbedCache. All Embed and EmbedBatch calls check the cache before hitting the underlying embedder API, reducing cost for repeated texts.
func NewCachingEmbedder ¶ added in v0.2.0
func NewCachingEmbedder(inner Embedder, cache memory.EmbedCache, modelKey string) *CachingEmbedder
NewCachingEmbedder returns a CachingEmbedder wrapping inner. modelKey should encode the model name and version (e.g. "voyage-3/v1"); changing it invalidates all existing cache entries for this instance.
func (*CachingEmbedder) Dimension ¶ added in v0.2.0
func (c *CachingEmbedder) Dimension() int
func (*CachingEmbedder) EmbedBatch ¶ added in v0.2.0
type Embedder ¶
type Embedder interface {
// Embed returns the embedding vector for a single text input.
Embed(ctx context.Context, text string) ([]float32, error)
// EmbedBatch returns embedding vectors for multiple texts.
EmbedBatch(ctx context.Context, texts []string) ([][]float32, error)
// Dimension returns the dimensionality of the embedding vectors.
Dimension() int
}
Embedder converts text into dense vector representations.
type OpenAI ¶
type OpenAI struct {
// contains filtered or unexported fields
}
OpenAI implements the Embedder interface using OpenAI's embedding API.
type OpenAIConfig ¶
type OpenAIConfig struct {
APIKey string
Model string // default: text-embedding-3-small
BaseURL string // default: https://api.openai.com/v1
Dimension int // default: 1536
}
OpenAIConfig configures the OpenAI embedder.
type Voyage ¶
type Voyage struct {
// contains filtered or unexported fields
}
Voyage implements the Embedder interface using Voyage AI's embedding API. Voyage AI provides high-quality embeddings optimized for retrieval tasks.
func NewVoyage ¶
func NewVoyage(cfg VoyageConfig) *Voyage
NewVoyage creates a new Voyage AI embedder.
type VoyageConfig ¶
type VoyageConfig struct {
APIKey string
Model string // default: voyage-3
BaseURL string // default: https://api.voyageai.com/v1
Dimension int // default: 1024
}
VoyageConfig configures the Voyage embedder.