embeddings

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package embeddings provides a thin wrapper around OpenAI-compatible /v1/embeddings endpoints for generating vector embeddings.

It reuses the go-openai client library and supports any OpenAI-compatible provider (OpenAI, Ollama, GitHub Copilot, etc.).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client generates vector embeddings via an OpenAI-compatible API.

func New

func New(cfg Config) *Client

New creates a new embeddings Client from cfg.

func (*Client) Embed

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

Embed returns the embedding vector for a single text input.

func (*Client) EmbedBatch

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

EmbedBatch returns embedding vectors for multiple texts in a single API call.

type Config

type Config struct {
	// Provider is the provider name (e.g. "ollama", "openai").
	// Used to look up base URL defaults when BaseURL is empty.
	Provider string

	// Model is the embedding model ID (e.g. "text-embedding-3-small",
	// "nomic-embed-text").
	Model string

	// BaseURL overrides the provider's default endpoint.
	BaseURL string

	// APIKey for authentication (empty = "no-key" for local providers).
	APIKey string

	// Dimensions optionally requests truncated embeddings (0 = model default).
	Dimensions int
}

Config holds connection settings for the embeddings provider.

Jump to

Keyboard shortcuts

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