Documentation
¶
Overview ¶
Package huggingface implements providers.EmbeddingProvider against Hugging Face's feature-extraction API: the serverless Inference Providers router (https://router.huggingface.co/hf-inference) and dedicated Inference Endpoints, which serve the same request and response shape.
Index ¶
Constants ¶
const ( // DefaultBaseURL is the serverless router's hf-inference provider. DefaultBaseURL = "https://router.huggingface.co/hf-inference" // DefaultModel is a small, widely used sentence-embedding model. DefaultModel = "sentence-transformers/all-MiniLM-L6-v2" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmbeddingOption ¶
type EmbeddingOption func(*EmbeddingProvider)
EmbeddingOption configures the EmbeddingProvider.
func WithAPIKey ¶
func WithAPIKey(key string) EmbeddingOption
WithAPIKey sets the Hugging Face token explicitly.
func WithDedicatedEndpoint ¶
func WithDedicatedEndpoint() EmbeddingOption
WithDedicatedEndpoint marks BaseURL as a dedicated Inference Endpoint.
func WithWiring ¶
func WithWiring(w providers.EmbeddingWiring) EmbeddingOption
WithWiring applies the transport-derived settings the factory resolved. A declared dimensions is reported and checked, but not sent: the feature-extraction API has no parameter for it.
type EmbeddingProvider ¶
type EmbeddingProvider struct {
*providers.BaseEmbeddingProvider
// contains filtered or unexported fields
}
EmbeddingProvider embeds text with a Hugging Face feature-extraction model.
func NewEmbeddingProvider ¶
func NewEmbeddingProvider(opts ...EmbeddingOption) (*EmbeddingProvider, error)
NewEmbeddingProvider creates a Hugging Face embedding provider. The model's vector size is the declared dimensions if any, otherwise the length of the first vector returned — Hugging Face hosts too many models for a lookup table to be anything but a guess.
func (*EmbeddingProvider) Embed ¶
func (p *EmbeddingProvider) Embed( ctx context.Context, req providers.EmbeddingRequest, ) (providers.EmbeddingResponse, error)
Embed generates embeddings for the given texts.