embedding

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package embedding provides text-to-vector embedding for Cortex.

Embeddings enable semantic search: instead of matching keywords, search by meaning. The service supports multiple backends:

  • ollama: Local Ollama server (default: nomic-embed-text, 768 dims)
  • openai: OpenAI API (text-embedding-3-small, 384 dims)
  • none: Disabled (default)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Provider string // "ollama", "openai", "none"
	APIKey   string // API key (OpenAI only; defaults to env var)
	Model    string // Model name override
	BaseURL  string // Base URL override (Ollama: default http://localhost:11434)
}

Config configures the embedding service.

type Service

type Service interface {
	// Embed returns a vector embedding for the given text.
	Embed(ctx context.Context, text string) ([]float32, error)

	// Dimensions returns the embedding dimension size.
	Dimensions() int

	// Model returns the model identifier.
	Model() string
}

Service generates embeddings from text.

func New

func New(cfg Config) Service

New creates an embedding service from config. Returns nil if provider is "none" or empty.

Jump to

Keyboard shortcuts

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