vectorstores

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 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 WithDeduplicater

func WithDeduplicater(fn func(ctx context.Context, doc schema.Document) bool) Option

WithDeduplicater returns an Option for setting the deduplicater that could be used when adding documents. This is useful to prevent wasting time on creating an embedding when one already exists.

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

WithFilters searches can be limited based 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 float32) Option

type Options

type Options struct {
	NameSpace      string
	ScoreThreshold float32
	Filters        any
	Embedder       embeddings.Embedder
	Deduplicater   func(context.Context, schema.Document) bool
}

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(ctx context.Context, docs []schema.Document, options ...Option) ([]string, 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 azureaisearch contains an implementation of the VectorStore interface that connects to Azure AI search.
Package azureaisearch contains an implementation of the VectorStore interface that connects to Azure AI search.
Package chroma contains an implementation of the VectorStore interface that connects to an external Chroma database.
Package chroma contains an implementation of the VectorStore interface that connects to an external Chroma database.
Package opensearch contains an implementation of the VectorStore interface that connects to Opensearch.
Package opensearch contains an implementation of the VectorStore interface that connects to Opensearch.
Package pgvector contains an implementation of the VectorStore interface using pgvector.
Package pgvector contains an implementation of the VectorStore interface using pgvector.
Package pinecone contains an implementation of the VectorStore interface using pinecone.
Package pinecone contains an implementation of the VectorStore interface using pinecone.
Package qdrant contains an implementation of the VectorStore interface using Qdrant.
Package qdrant contains an implementation of the VectorStore interface using Qdrant.
Package redisvector contains an implementation of the VectorStore interface using redisvector.
Package redisvector contains an implementation of the VectorStore interface using redisvector.
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