embed

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package embed provides Ken's pluggable embedding SPI for semantic search. It ships an OpenAI-compatible HTTP provider and a deterministic offline hash provider (for tests / air-gapped use). Embeddings are OFF unless KEN_EMBED_* is configured; the store computes cosine KNN in Go (brute-force), so no SQLite extension is required.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Embedder

type Embedder interface {
	Embed(ctx context.Context, texts []string) ([][]float32, error)
	Dimension() int
	ID() string // stable model id, stored alongside each vector
}

Embedder turns text into vectors. Implementations must return one vector per input, in order, each of length Dimension().

func FromEnv

func FromEnv() (Embedder, error)

FromEnv builds an embedder from KEN_EMBED_* env vars, or (nil, nil) if none is configured (embeddings disabled).

type HTTPEmbedder

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

func (*HTTPEmbedder) Dimension

func (h *HTTPEmbedder) Dimension() int

func (*HTTPEmbedder) Embed

func (h *HTTPEmbedder) Embed(ctx context.Context, texts []string) ([][]float32, error)

func (*HTTPEmbedder) ID

func (h *HTTPEmbedder) ID() string

type HashEmbedder

type HashEmbedder struct{ Dim int }

func (HashEmbedder) Dimension

func (h HashEmbedder) Dimension() int

func (HashEmbedder) Embed

func (h HashEmbedder) Embed(_ context.Context, texts []string) ([][]float32, error)

func (HashEmbedder) ID

func (h HashEmbedder) ID() string

Jump to

Keyboard shortcuts

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