vectorstores

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCollectionNotFound = errors.New("collection not found")
)

Functions

func ToRetriever

func ToRetriever(vectorStore VectorStore, numDocs int, options ...Option) schema.Retriever

ToRetriever creates a retriever from a vector store.

Types

type DocumentWithScore

type DocumentWithScore struct {
	Document schema.Document
	Score    float32
}

type Option

type Option func(*Options)

func WithEmbedder

func WithEmbedder(embedder embeddings.Embedder) Option

func WithFilter

func WithFilter(key string, value any) Option

func WithFilters

func WithFilters(filters map[string]any) Option

func WithNameSpace

func WithNameSpace(namespace string) Option

func WithScoreThreshold

func WithScoreThreshold(threshold float32) Option

type Options

type Options struct {
	Embedder       embeddings.Embedder
	NameSpace      string
	ScoreThreshold float32
	Filters        map[string]any
}

func ParseOptions

func ParseOptions(options ...Option) Options

type Retriever

type Retriever interface {
	GetRelevantDocuments(ctx context.Context, query string) ([]schema.Document, error)
}

Retriever is the interface for fetching relevant documents for a query.

type VectorStore

type VectorStore interface {
	AddDocuments(ctx context.Context, docs []schema.Document, options ...Option) ([]string, error)
	SimilaritySearch(ctx context.Context, query string, numDocuments int, options ...Option) ([]schema.Document, error)
	SimilaritySearchWithScores(ctx context.Context, query string, numDocuments int, options ...Option) ([]DocumentWithScore, error)
	ListCollections(ctx context.Context) ([]string, error)
	DeleteCollection(ctx context.Context, collectionName string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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