Help us shape the future of Go! Take the 2026 Go Developer Survey

localvec

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 17 Imported by: 3

Documentation

Overview

Package localvec is a local vector database for development and testing. The database is stored in a file in the local file system. Production code should use a real vector database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Index added in v0.6.0

func Index(ctx context.Context, docs []*ai.Document, ds *DocStore) error

Helper function to get started with indexing

func Init

func Init() error

Init initializes the plugin.

func IsDefinedRetriever added in v0.1.0

func IsDefinedRetriever(g *genkit.Genkit, name string) bool

IsDefinedRetriever reports whether the named Retriever is defined by this plugin.

func Retriever

func Retriever(g *genkit.Genkit, name string) ai.Retriever

Retriever returns the retriever with the given name. The name must match the [Config.Name] value passed to Init.

Types

type Config

type Config struct {
	// Where to store the data. Defaults to os.TempDir.
	Dir             string
	Embedder        ai.Embedder
	EmbedderOptions any
}

type DbValue added in v0.6.0

type DbValue struct {
	Doc       *ai.Document `json:"doc"`
	Embedding []float32    `json:"embedding"`
}

DbValue is the type of a document stored in the database.

type DocStore added in v0.6.0

type DocStore struct {
	Filename        string
	Embedder        ai.Embedder
	EmbedderOptions any
	Data            map[string]DbValue
}

DocStore implements a local vector database. This is based on js/plugins/dev-local-vectorstore/src/index.ts.

func DefineRetriever added in v0.6.0

func DefineRetriever(g *genkit.Genkit, name string, cfg Config, opts *ai.RetrieverOptions) (*DocStore, ai.Retriever, error)

DefineRetriever defines a Retriever and docStore which is also used by the retriever. The name uniquely identifies the Retriever in the registry.

type RetrieverOptions

type RetrieverOptions struct {
	K int `json:"k,omitempty"` // number of entries to return
}

RetrieverOptions may be passed in the Options field of ai.RetrieverRequest to pass options to the retriever. The Options field should be either nil or a value of type *RetrieverOptions.

Jump to

Keyboard shortcuts

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