embed

package
v0.1.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package embed provides embedder implementations for Dory. Each implementation satisfies the [dory.Embedder] interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ollama

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

Ollama implements the [dory.Embedder] interface using the Ollama local HTTP API.

func NewOllama

func NewOllama(config OllamaConfig) *Ollama

NewOllama creates a new Ollama embedder with the given configuration.

func (*Ollama) Dimensions

func (o *Ollama) Dimensions() int

Dimensions returns the dimensionality of the vectors this embedder produces.

func (*Ollama) Embed

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

Embed returns the vector representation of the given text.

func (*Ollama) EmbedBatch

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

EmbedBatch embeds multiple texts in a single API call.

type OllamaConfig

type OllamaConfig struct {
	// Model is the Ollama model name, e.g. "nomic-embed-text".
	Model string

	// URL is the base URL of the Ollama HTTP API.
	// Defaults to "http://localhost:11434" if empty.
	URL string

	// Dimensions is the dimensionality of the vectors this model produces.
	Dimensions int
}

OllamaConfig holds the configuration for an Ollama embedder.

type OpenAI

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

OpenAI implements the [dory.Embedder] interface using the official OpenAI Go SDK. Reads the API key from the OPENAI_API_KEY environment variable by default.

func NewOpenAI

func NewOpenAI(model string) *OpenAI

NewOpenAI creates a new OpenAI embedder for the given model name.

func (*OpenAI) Dimensions

func (o *OpenAI) Dimensions() int

Dimensions returns the dimensionality of the vectors this embedder produces.

func (*OpenAI) Embed

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

Embed returns the vector representation of the given text.

func (*OpenAI) EmbedBatch

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

EmbedBatch embeds multiple texts in a single API call.

Jump to

Keyboard shortcuts

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