embedder

package
v0.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package embedder manages embedding generation and vector storage using chromem-go as an in-process persistent vector database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashFile

func HashFile(path string) (string, error)

HashFile computes the SHA256 hex digest of a file.

Types

type Embedder

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

Embedder manages embedding generation and vector storage.

func New

func New(provider providers.Provider, model, dbDir string, chunkCfg chunker.Config) (*Embedder, error)

New creates an Embedder backed by chromem-go persistent storage.

func (*Embedder) EmbedFiles

func (e *Embedder) EmbedFiles(ctx context.Context, files map[string]string, concurrency int) (*Stats, error)

EmbedFiles embeds files in parallel. files is a map of path -> SHA256 hash.

func (*Embedder) Load

func (e *Embedder) Load(ctx context.Context)

Load preloads the embedding model on the provider (fire-and-forget). Silently no-ops if the provider doesn't support explicit model loading.

func (*Embedder) Query

func (e *Embedder) Query(ctx context.Context, query string, k int) ([]chromem.Result, error)

Query embeds the query string and performs similarity search, returning top-k results.

func (*Embedder) RemoveDeleted

func (e *Embedder) RemoveDeleted(ctx context.Context, files map[string]string, previousPaths []string) (int, error)

RemoveDeleted removes embeddings for files that were previously indexed but are no longer present in the current files map. previousPaths is the set of file paths from the previous indexing run.

func (*Embedder) Unload

func (e *Embedder) Unload(ctx context.Context)

Unload releases the embedding model from provider memory (fire-and-forget). Silently no-ops if the provider doesn't support explicit model unloading.

type Stats

type Stats struct {
	Embedded int
	Skipped  int
	Removed  int
	Total    int
}

Stats tracks embedding operation results.

func (Stats) Display

func (s Stats) Display() string

Display returns a human-readable summary.

Jump to

Keyboard shortcuts

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