hf

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateEmbeddingRequest

type CreateEmbeddingRequest struct {
	Inputs  []string               `json:"inputs"`
	Options map[string]interface{} `json:"options"`
}

func (*CreateEmbeddingRequest) JSON

func (c *CreateEmbeddingRequest) JSON() (string, error)

type CreateEmbeddingResponse

type CreateEmbeddingResponse struct {
	Embeddings [][]float32 `json:"embeddings"`
}

type HuggingFaceClient

type HuggingFaceClient struct {
	BaseURL        string
	APIKey         string
	Model          string
	Client         *http.Client
	DefaultHeaders map[string]string
	IsHFEIEndpoint bool
}

func NewHuggingFaceClient

func NewHuggingFaceClient(apiKey string, model string) *HuggingFaceClient

func NewHuggingFaceClientFromOptions

func NewHuggingFaceClientFromOptions(opts ...Option) (*HuggingFaceClient, error)

func (*HuggingFaceClient) CreateEmbedding

type HuggingFaceEmbeddingFunction

type HuggingFaceEmbeddingFunction struct {
	// contains filtered or unexported fields
}

func NewHuggingFaceEmbeddingFunction

func NewHuggingFaceEmbeddingFunction(apiKey string, model string) *HuggingFaceEmbeddingFunction

func NewHuggingFaceEmbeddingFunctionFromOptions

func NewHuggingFaceEmbeddingFunctionFromOptions(opts ...Option) (*HuggingFaceEmbeddingFunction, error)

func NewHuggingFaceEmbeddingInferenceFunction

func NewHuggingFaceEmbeddingInferenceFunction(baseURL string, opts ...Option) (*HuggingFaceEmbeddingFunction, error)

func (*HuggingFaceEmbeddingFunction) EmbedDocuments

func (e *HuggingFaceEmbeddingFunction) EmbedDocuments(ctx context.Context, documents []string) ([]embeddings.Embedding, error)

func (*HuggingFaceEmbeddingFunction) EmbedQuery

type Option

type Option func(p *HuggingFaceClient) error

func WithAPIKey

func WithAPIKey(apiKey string) Option

func WithBaseURL

func WithBaseURL(baseURL string) Option

func WithDefaultHeaders

func WithDefaultHeaders(headers map[string]string) Option

func WithEnvAPIKey

func WithEnvAPIKey() Option

func WithIsHFEIEndpoint added in v0.2.3

func WithIsHFEIEndpoint() Option

func WithModel

func WithModel(model string) Option

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL