Help us shape the future of Go! Take the 2026 Go Developer Survey

embeddings

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider interface {
	// Name returns the provider name (e.g., "openai", "ollama").
	Name() string
	// Dimensions returns the embedding dimensionality this provider produces.
	Dimensions() int
	// Embed returns one embedding per input string.
	Embed(ctx context.Context, inputs []string) ([][]float32, error)
}

Provider defines a simple embeddings provider interface. Implementations should be concurrency-safe.

func NewFromEnv

func NewFromEnv() Provider

NewFromEnv constructs a provider based on environment variables. EMBEDDINGS_PROVIDER: "openai", "ollama", "gemini", "vertexai", "localai", or empty for disabled.

func WrapToDims

func WrapToDims(base Provider, targetDims int, mode string) Provider

WrapToDims returns a Provider that adapts output vectors to targetDims using the given mode. If base already matches targetDims, base is returned unchanged.

type StaticProvider

type StaticProvider struct {
	N int
}

NewStaticProvider returns a deterministic provider for tests

func (*StaticProvider) Dimensions

func (s *StaticProvider) Dimensions() int

func (*StaticProvider) Embed

func (s *StaticProvider) Embed(ctx context.Context, inputs []string) ([][]float32, error)

func (*StaticProvider) Name

func (s *StaticProvider) Name() string

Jump to

Keyboard shortcuts

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