vectorstores

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package vectorstores contains the implementation of VectorStore, an interface for saving and querying documents as vector embeddings.

The main components of this package are:

- VectorStore interface: a common interface for saving and querying vector embeddings of documents. - Options: a set of options for similarity search and document addition. - Retriever: a retriever for vector stores that implements the schema.Retriever interface.

The package provides a flexible way to handle different types of vector stores by using the VectorStore interface as an abstraction. It supports customization of the search and storage operation via the Options mechanism.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Options)

Option is a function that configures an Options.

func WithEmbedder

func WithEmbedder(embedder embeddings.Embedder) Option

WithEmbedder returns an Option for setting the embedder that could be used when adding documents or doing similarity search (instead the embedder from the Store context) this is useful when we are using multiple LLMs with single vectorstore.

func WithFilters

func WithFilters(filters any) Option

Vector searches can be limited bsaed on metadata filters. Searches with metadata filters retrieve exactly the number of nearest-neighbors results that match the filters. In most cases the search latency will be lower than unfiltered searches See https://docs.pinecone.io/docs/metadata-filtering

func WithNameSpace

func WithNameSpace(nameSpace string) Option

WithNameSpace returns an Option for setting the name space.

func WithScoreThreshold

func WithScoreThreshold(scoreThreshold float64) Option

type Options

type Options struct {
	NameSpace      string
	ScoreThreshold float64
	Filters        any
	Embedder       embeddings.Embedder
}

Options is a set of options for similarity search and add documents.

type Retriever

type Retriever struct {
	CallbacksHandler callbacks.Handler
	// contains filtered or unexported fields
}

Retriever is a retriever for vector stores.

func ToRetriever

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

ToRetriever takes a vector store and returns a retriever using the vector store to retrieve documents.

func (Retriever) GetRelevantDocuments

func (r Retriever) GetRelevantDocuments(ctx context.Context, query string) ([]schema.Document, error)

GetRelevantDocuments returns documents using the vector store.

type VectorStore

type VectorStore interface {
	AddDocuments(context.Context, []schema.Document, ...Option) error
	SimilaritySearch(ctx context.Context, query string, numDocuments int, options ...Option) ([]schema.Document, error) //nolint:lll
}

VectorStore is the interface for saving and querying documents in the form of vector embeddings.

Directories

Path Synopsis
Package pinecone contains an implementation of the vectorStore interface using pinecone.
Package pinecone contains an implementation of the vectorStore interface using pinecone.
Package weaviate contains an implementation of the vectorStore interface using weaviate.
Package weaviate contains an implementation of the vectorStore interface using weaviate.

Jump to

Keyboard shortcuts

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