embedding

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package embedding provides functions to use OpenAI's Embeddings API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service interface {
	One(input string) (Vector, error)
	Array(inputs ...string) ([]Vector, error)

	// Dimensions returns the number of dimensions used for embeddings.
	Dimensions() int

	// SetDimensions sets the number of dimensions used for embeddings.
	SetDimensions(int)
}

Service is the service for the Embeddings API.

type Vector

type Vector []float64

Vector is a calculated embedding.

func (Vector) AngleDiff

func (v Vector) AngleDiff(v2 Vector) float64

AngleDiff calculates the cosine similarity between two vectors. 1 means that vectors are parallel, 0 - orthogonal, -1 - antiparallel.

func (Vector) Distance

func (v Vector) Distance(v2 Vector) float64

Distance calculates the Euclidean distance between two vectors.

Jump to

Keyboard shortcuts

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