embedding

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package embedding provides text embedding capabilities.

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 L2-normalized embedding vector for a single text string.
	Embed(text string) ([]float32, error)

	// EmbedBatch returns L2-normalized embedding vectors for multiple texts.
	EmbedBatch(texts []string) ([][]float32, error)

	// Close releases resources held by the embedder.
	Close() error
}

Embedder provides text embedding capabilities.

type RemoteEmbedder added in v0.14.0

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

RemoteEmbedder implements Embedder by calling the proxy's /embed endpoint.

func NewRemote added in v0.14.0

func NewRemote(log logrus.FieldLogger, proxyURL string, tokenFn func() string) *RemoteEmbedder

NewRemote creates a new RemoteEmbedder that calls the proxy's /embed endpoint. tokenFn is called on each request to get the current auth token.

func (*RemoteEmbedder) Close added in v0.14.0

func (e *RemoteEmbedder) Close() error

Close is a no-op for the remote embedder.

func (*RemoteEmbedder) Embed added in v0.14.0

func (e *RemoteEmbedder) Embed(text string) ([]float32, error)

Embed returns the L2-normalized embedding vector for a single text string.

func (*RemoteEmbedder) EmbedBatch added in v0.14.0

func (e *RemoteEmbedder) EmbedBatch(texts []string) ([][]float32, error)

EmbedBatch returns L2-normalized embedding vectors for multiple texts. For batches larger than 1, it first checks the proxy cache with just hashes, then only sends text for uncached items.

Jump to

Keyboard shortcuts

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