embeddings

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package embeddings provides model clients for vector generation. Applications own text selection, credentials, indexing policy and persistence.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(vector []float64, dimension int) error

Validate rejects empty, non-finite and zero vectors, which cannot participate in cosine similarity. A positive dimension requires an exact length match.

Types

type BatchClient

type BatchClient interface {
	Client
	EmbedBatch(context.Context, []string) ([][]float64, error)
}

BatchClient generates vectors in the same order as its input texts.

type Client

type Client interface {
	Embed(context.Context, string) ([]float64, error)
}

Client generates one vector for one text.

type Ollama

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

Ollama calls the Ollama /api/embed endpoint. It is safe for concurrent use.

func NewOllama

func NewOllama(baseURL, model string, client *http.Client) (*Ollama, error)

NewOllama validates configuration. A nil client selects a 30-second timeout. The supplied client remains caller-owned. Requests disable silent truncation.

func (*Ollama) Embed

func (c *Ollama) Embed(ctx context.Context, text string) ([]float64, error)

Embed returns a vector for text.

func (*Ollama) EmbedBatch

func (c *Ollama) EmbedBatch(ctx context.Context, texts []string) (_ [][]float64, err error)

EmbedBatch returns one valid, equally sized vector per input text. Provider errors expose status only; neither bodies nor request URLs appear in errors.

Jump to

Keyboard shortcuts

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