embeddings

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package embeddings provides a pluggable embedding provider interface. Supported: OpenAI, Voyage AI, and a local stub (returns hash-based pseudo-vectors).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cosine

func Cosine(a, b []float32) float32

Cosine returns the cosine similarity between two vectors.

Types

type Provider

type Provider interface {
	Embed(ctx context.Context, text string) ([]float32, error)
	Dims() int
	Name() string
}

Provider generates vector embeddings for text.

func NewLocal

func NewLocal() Provider

NewLocal returns a local stub provider that generates deterministic pseudo-vectors from SHA-256 hashes. Useful for testing and offline use. NOT semantically meaningful — use OpenAI/Voyage for real semantic search.

func NewOpenAI

func NewOpenAI(apiKey, model string) Provider

NewOpenAI creates an OpenAI embedding provider. model: "text-embedding-3-small" (1536 dims) or "text-embedding-3-large" (3072 dims)

func NewVoyage

func NewVoyage(apiKey, model string) Provider

NewVoyage creates a Voyage AI embedding provider. model: "voyage-code-3" (optimized for code)

Jump to

Keyboard shortcuts

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