embed

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package embed provides text-embedding clients for semantic prompt diffing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CosineSimilarity

func CosineSimilarity(a, b []float64) float64

CosineSimilarity returns the cosine similarity of a and b, in [-1, 1]. Returns 0 if either vector is empty or zero-length.

Types

type Client

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

Client embeds text into a vector for semantic comparison.

type VoyageClient

type VoyageClient struct {
	Endpoint string
	APIKey   string
	Model    string
}

VoyageClient calls the Voyage AI embeddings API. https://docs.voyageai.com/reference/embeddings-api

func NewVoyageClient

func NewVoyageClient() *VoyageClient

NewVoyageClient builds a client from VOYAGE_API_KEY / VOYAGE_BASE_URL / VOYAGE_MODEL env vars, defaulting to the voyage-3-lite model.

func (*VoyageClient) Embed

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

Embed returns one vector per input text, in the same order as texts.

Jump to

Keyboard shortcuts

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