vector

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package vector provides interfaces and implementations for vector storage and embedding.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a document is not found in the vector store.
	ErrNotFound = errors.New("document not found")

	// ErrEmbedding is returned when embedding generation fails.
	ErrEmbedding = errors.New("embedding failed")

	// ErrConnection is returned when the vector store connection fails.
	ErrConnection = errors.New("vector store connection failed")
)

Functions

This section is empty.

Types

type Document

type Document struct {
	// ID is a unique identifier for the document (typically the node hash).
	ID string

	// Hash is the merkle node hash this document corresponds to.
	Hash string

	// Embedding is the vector representation of the document content.
	Embedding []float32
}

Document represents a stored item with its embedding and metadata.

type Driver

type Driver interface {
	// Add stores documents with their embeddings.
	// If a document with the same ID already exists, implementers should update
	// the document.
	Add(ctx context.Context, docs []Document) error

	// Query finds the topK most similar documents to the given embedding.
	Query(ctx context.Context, embedding []float32, topK int) ([]QueryResult, error)

	// Get retrieves documents by their IDs.
	Get(ctx context.Context, ids []string) ([]Document, error)

	// Delete removes documents by their IDs.
	Delete(ctx context.Context, ids []string) error

	// Close releases any resources held by the driver.
	Close() error
}

Driver handles storage and retrieval of vector embeddings.

type QueryResult

type QueryResult struct {
	Document

	// Score represents the similarity score (higher = more similar).
	Score float32
}

QueryResult represents a search result with similarity score.

Directories

Path Synopsis
Package chroma provides a Chroma vector database driver implementation.
Package chroma provides a Chroma vector database driver implementation.
Package pgvector provides a PostgreSQL-backed vector driver using the pgvector extension.
Package pgvector provides a PostgreSQL-backed vector driver using the pgvector extension.
Package sqlitevec provides a SQLite-backed vector driver using sqlite-vec.
Package sqlitevec provides a SQLite-backed vector driver using sqlite-vec.

Jump to

Keyboard shortcuts

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