embedding

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 16 Imported by: 0 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

Index

Constants

View Source
const (
	ProviderOllama              = "ollama"
	DefaultOllamaRequestTimeout = 2 * time.Minute
)
View Source
const (
	RepresentationDenseF32 = "dense_f32"
	NormalizationL2        = "l2"
	NormalizationNone      = "none"
)

Variables

This section is empty.

Functions

func BlockedError

func BlockedError(err error) error

func DecodeDenseF32

func DecodeDenseF32(encoded []byte, dimensions int) ([]float32, error)

func EncodeDenseF32

func EncodeDenseF32(vector []float32) []byte

func FatalConfigError

func FatalConfigError(err error) error

func IsBlocked

func IsBlocked(err error) bool

func IsFatalConfig

func IsFatalConfig(err error) bool

func IsRetryable

func IsRetryable(err error) bool

func RetryableError

func RetryableError(err error) error

func ValidateDenseF32

func ValidateDenseF32(vector []float32, dimensions int, normalization string) error

func ValidateEncodedVector

func ValidateEncodedVector(encoded []byte, dimensions int, representation, normalization string) error

func ValidateRequest

func ValidateRequest(req Request) error

func ValidateResponse

func ValidateResponse(expected Info, req Request, response Response) error

Types

type Failure

type Failure struct {
	Kind FailureKind
	Err  error
}

func (*Failure) Error

func (e *Failure) Error() string

func (*Failure) Unwrap

func (e *Failure) Unwrap() error

type FailureKind

type FailureKind string
const (
	FailureRetryable   FailureKind = "retryable"
	FailureBlocked     FailureKind = "blocked"
	FailureFatalConfig FailureKind = "fatal_config"
)

type Info

type Info struct {
	Provider   string
	Model      string
	Dimensions int
}

func (Info) Validate

func (i Info) Validate() error

type Ollama

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

func NewOllama

func NewOllama(opts OllamaOptions) (*Ollama, error)

func (*Ollama) Embed

func (o *Ollama) Embed(ctx context.Context, req Request) (Response, error)

func (*Ollama) Info

func (o *Ollama) Info() Info

type OllamaOptions

type OllamaOptions struct {
	BaseURL    string
	Model      string
	Dimensions int
	Timeout    time.Duration
}

type Profile

type Profile struct {
	Provider          string
	Model             string
	ProjectionVersion string
	ChunkerVersion    string
	Representation    string
	Normalization     string
	Dimensions        int
}

func (Profile) ID

func (p Profile) ID() (string, error)

func (Profile) Validate

func (p Profile) Validate() error

type Provider

type Provider interface {
	Info() Info
	Embed(context.Context, Request) (Response, error)
}

type Purpose

type Purpose string
const (
	PurposeDocument Purpose = "document"
	PurposeQuery    Purpose = "query"
)

type Request

type Request struct {
	Texts   []string
	Purpose Purpose
}

type Response

type Response struct {
	Vectors    [][]float32
	Provider   string
	Model      string
	Dimensions int
}

Jump to

Keyboard shortcuts

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