Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultRegistry = NewProviderRegistry()
DefaultRegistry is the global provider registry used by init() auto-registration.
var ErrMissingCredentials = errdefs.Unauthorized(errors.New("embedding: missing required credentials"))
ErrMissingCredentials is returned when a provider cannot be created because required credentials (api_key, endpoint, etc.) are missing.
Functions ¶
func ListProviders ¶
func ListProviders() []string
ListProviders lists providers from DefaultRegistry.
func RegisterProvider ¶
func RegisterProvider(name string, factory ProviderFactory)
RegisterProvider registers a factory in DefaultRegistry.
Types ¶
type DimensionAware ¶
type DimensionAware interface {
Dimensions() int
}
DimensionAware is an optional interface that Embedder implementations may implement to report their output vector dimensions.
type Embedder ¶
type Embedder interface {
Embed(ctx context.Context, text string) ([]float32, error)
EmbedBatch(ctx context.Context, texts []string) ([][]float32, error)
}
Embedder generates vector embeddings from text. Implementations must be safe for concurrent use.
Embed returns a single embedding for the given text. EmbedBatch returns embeddings for multiple texts (order-preserving). Implementations that do not support batching may fall back to sequential single calls.
type ProviderFactory ¶
ProviderFactory creates an Embedder for the given model. config contains connection settings (api_key, base_url, etc.).
type ProviderRegistry ¶
type ProviderRegistry struct {
// contains filtered or unexported fields
}
ProviderRegistry is a thread-safe registry of embedding provider factories.
func NewProviderRegistry ¶
func NewProviderRegistry() *ProviderRegistry
func (*ProviderRegistry) ListProviders ¶
func (r *ProviderRegistry) ListProviders() []string
func (*ProviderRegistry) NewFromConfig ¶
func (r *ProviderRegistry) NewFromConfig(provider, model string, config map[string]any) (Embedder, error)
NewFromConfig creates an Embedder via the registered factory. Returns an error if the provider is not registered.
func (*ProviderRegistry) Register ¶
func (r *ProviderRegistry) Register(name string, factory ProviderFactory)