pgvector

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 11 Imported by: 12

Documentation

Overview

Package pgvector contains an implementation of the VectorStore interface using pgvector.

Index

Constants

View Source
const (
	DefaultCollectionName           = "langchain"
	DefaultPreDeleteCollection      = false
	DefaultEmbeddingStoreTableName  = "langchain_pg_embedding"
	DefaultCollectionStoreTableName = "langchain_pg_collection"
)

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")
	ErrInvalidFilters             = errors.New("invalid filters")
	ErrUnsupportedOptions         = errors.New("unsupported options")
)
View Source
var ErrInvalidOptions = errors.New("invalid options")

ErrInvalidOptions is returned when the options given are invalid.

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 WithCollectionName

func WithCollectionName(name string) Option

WithCollectionName is an option for specifying the collection name.

func WithCollectionTableName

func WithCollectionTableName(name string) Option

WithCollectionTableName is an option for specifying the collection table name.

func WithConnectionURL

func WithConnectionURL(connectionURL string) Option

WithConnectionURL is an option for specifying the Postgres connection URL. Must be set.

func WithEmbedder

func WithEmbedder(e embeddings.Embedder) Option

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

func WithEmbeddingTableName

func WithEmbeddingTableName(name string) Option

WithEmbeddingTableName is an option for specifying the embedding table name.

func WithPreDeleteCollection

func WithPreDeleteCollection(preDelete bool) Option

WithPreDeleteCollection is an option for setting if the collection should be deleted before creating.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a wrapper around the pgvector client.

func New

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

New creates a new Store with options.

func (Store) AddDocuments

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

func (Store) Close

func (s Store) Close(ctx context.Context) error

Close closes the connection.

func (Store) DropTables

func (s Store) DropTables(ctx context.Context) error

func (Store) RemoveCollection

func (s Store) RemoveCollection(ctx context.Context) error

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