Documentation
¶
Index ¶
- Constants
- type APIError
- type Client
- type Embedder
- func (p *Embedder) BatchEmbed(ctx context.Context, parts []string, usage *components.LLMUsage) ([]embedder.Embedding, error)
- func (p *Embedder) DotProduct(ctx context.Context, target, query *embedder.Embedding) (float64, error)
- func (p *Embedder) Embed(ctx context.Context, text string, embedding *embedder.Embedding, ...) error
- func (p *Embedder) SetClient(clt *Client)
- type EmbeddingRequest
- type Option
- type Options
- type StringList
Constants ¶
const BaseURL = "https://api-inference.huggingface.co/pipeline/feature-extraction/"
const (
DefaultEmbedderModel = "sentence-transformers/all-MiniLM-L6-v2"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
Errors StringList `json:"error,omitempty"`
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is Voyage HTTP API client.
func NewClient ¶
NewClient creates a new HTTP API client and returns it. By default it reads the Voyage API key from HUGGING_FACE_API_KEY env var and uses the default Go http.Client for making API requests. You can override the default options via the client methods.
func (*Client) CreateEmbeddings ¶
type Embedder ¶
func (*Embedder) BatchEmbed ¶
func (*Embedder) DotProduct ¶
func (p *Embedder) DotProduct(ctx context.Context, target, query *embedder.Embedding) (float64, error)
DotProduct calculates the dot product of the embedding vector with another embedding vector. Both vectors must have the same length; otherwise, an ErrVectorLengthMismatch is returned. The method returns the calculated dot product as a float32 value.
type EmbeddingRequest ¶
type Option ¶
type Option func(*Options)
Option is functional option.
func WithHTTPClient ¶
WithHTTPClient sets the HTTP client.
type StringList ¶
type StringList []string
func (StringList) MarshalJSON ¶
func (s StringList) MarshalJSON() ([]byte, error)
MarshalJSON serializes as a single string if only one element exists, otherwise as a list
func (*StringList) UnmarshalJSON ¶
func (s *StringList) UnmarshalJSON(data []byte) error
UnmarshalJSON handles both single string and list of strings