inmemory

package
v0.1.13-update.2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package inmemory contains an implementation of the inmemory VectorStore

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmbedderWrongNumberVectors = errors.New("number of vectors from embedder does not match number of documents")
	ErrInvalidScoreThreshold      = errors.New("score threshold must be between 0 and 1")
	ErrUnsupportedOptions         = errors.New("unsupported options")
)

Functions

This section is empty.

Types

type Option

type Option func(p *Store)

Option is a function type that can be used to modify the client.

func WithEmbedder

func WithEmbedder(e embeddings.Embedder) Option

WithEmbedder is an option for setting the embedder to use. Must be set.

func WithHNSWOptions

func WithHNSWOptions(m, efConstruction, efSearch int) Option

WithHNSWOptions is an option for specifying the HNSW index parameters. m: he max number of connections per layer (16 by default). efConstruction: the size of the dynamic candidate list for constructing the graph (64 by default). efSearch: the size of the dynamic candidate list for search (64 by default). vectorSize: the size of the vector (128 by default).

func WithSize

func WithSize(limit int) Option

WithSize is an option for setting the initial size of the store (128 by default).

func WithVectorSize

func WithVectorSize(size int) Option

WithVectorSize is an option for setting the size of the vector (128 by default).

type Store

type Store struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Store is a struct that holds the in-memory vector store.

func New

func New(ctx context.Context, opts ...Option) (*Store, error)

New returns a new InMemory store with options.

func (*Store) AddDocuments

func (s *Store) AddDocuments(
	ctx context.Context,
	docs []schema.Document,
	options ...vectorstores.Option,
) ([]string, error)

AddDocuments adds documents to the in-memory store and returns the ids of the added documents.

func (*Store) SimilaritySearch

func (s *Store) SimilaritySearch(
	ctx context.Context,
	query string,
	numDocuments int,
	options ...vectorstores.Option,
) ([]schema.Document, error)

Jump to

Keyboard shortcuts

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