pinecone

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: 12 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingTextKey is returned in SimilaritySearch if a vector
	// from the query is missing the text key.
	ErrMissingTextKey = errors.New("missing text key in vector metadata")
	// ErrEmbedderWrongNumberVectors is returned when if the embedder returns a number
	// of vectors that is not equal to the number of documents given.
	ErrEmbedderWrongNumberVectors = errors.New(
		"number of vectors from embedder does not match number of documents",
	)
	// ErrEmptyResponse is returned if the API gives an empty response.
	ErrEmptyResponse         = errors.New("empty response")
	ErrInvalidScoreThreshold = errors.New(
		"score threshold must be between 0 and 1")
)
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 WithAPIKey

func WithAPIKey(apiKey string) Option

WithAPIKey is an option for setting the api key. If the option is not set the api key is read from the PINECONE_API_KEY environment variable. If the variable is not present, an error will be returned.

func WithEmbedder

func WithEmbedder(e embeddings.Embedder) Option

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

func WithHost

func WithHost(host string) Option

WithHost is an option for setting the host to use. Must be set.

func WithNameSpace

func WithNameSpace(nameSpace string) Option

WithNameSpace is an option for setting the nameSpace to upsert and query the vectors from. Must be set.

func WithTextKey

func WithTextKey(textKey string) Option

WithTextKey is an option for setting the text key in the metadata to the vectors in the index. The text key stores the text of the document the vector represents.

type Store

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

Store is a wrapper around the pinecone rest API and grpc client.

func New

func New(opts ...Option) (Store, error)

New creates a new Store with options. Options for WithAPIKey, WithHost and WithEmbedder must be set.

func (Store) AddDocuments

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

AddDocuments creates vector embeddings from the documents using the embedder and upsert the vectors to the pinecone index 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)

SimilaritySearch creates a vector embedding from the query using the embedder and queries to find the most similar documents.

Jump to

Keyboard shortcuts

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