embedding

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 8 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 embedding defines the Embedder interface and implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Embedder

type Embedder interface {
	// Embed returns the embedding vector for a single text input.
	Embed(ctx context.Context, text string) ([]float32, error)

	// EmbedBatch returns embedding vectors for multiple texts.
	EmbedBatch(ctx context.Context, texts []string) ([][]float32, error)

	// Dimension returns the dimensionality of the embedding vectors.
	Dimension() int
}

Embedder converts text into dense vector representations.

type OpenAI

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

OpenAI implements the Embedder interface using OpenAI's embedding API.

func NewOpenAI

func NewOpenAI(cfg OpenAIConfig) *OpenAI

NewOpenAI creates a new OpenAI embedder.

func (*OpenAI) Dimension

func (o *OpenAI) Dimension() int

Dimension returns the dimensionality of the embedding vectors.

func (*OpenAI) Embed

func (o *OpenAI) Embed(ctx context.Context, text string) ([]float32, error)

Embed returns the embedding vector for a single text input.

func (*OpenAI) EmbedBatch

func (o *OpenAI) EmbedBatch(ctx context.Context, texts []string) ([][]float32, error)

EmbedBatch returns embedding vectors for multiple texts. The OpenAI API supports batch embedding natively.

type OpenAIConfig

type OpenAIConfig struct {
	APIKey    string
	Model     string // default: text-embedding-3-small
	BaseURL   string // default: https://api.openai.com/v1
	Dimension int    // default: 1536
}

OpenAIConfig configures the OpenAI embedder.

type Voyage

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

Voyage implements the Embedder interface using Voyage AI's embedding API. Voyage AI provides high-quality embeddings optimized for retrieval tasks.

func NewVoyage

func NewVoyage(cfg VoyageConfig) *Voyage

NewVoyage creates a new Voyage AI embedder.

func (*Voyage) Dimension

func (v *Voyage) Dimension() int

Dimension returns the dimensionality of the embedding vectors.

func (*Voyage) Embed

func (v *Voyage) Embed(ctx context.Context, text string) ([]float32, error)

Embed returns the embedding vector for a single text input.

func (*Voyage) EmbedBatch

func (v *Voyage) EmbedBatch(ctx context.Context, texts []string) ([][]float32, error)

EmbedBatch returns embedding vectors for multiple texts.

type VoyageConfig

type VoyageConfig struct {
	APIKey    string
	Model     string // default: voyage-3
	BaseURL   string // default: https://api.voyageai.com/v1
	Dimension int    // default: 1024
}

VoyageConfig configures the Voyage embedder.

Jump to

Keyboard shortcuts

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