pinecone

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 19 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 APIError

type APIError struct {
	Task    string
	Message string
}

APIError is an error type returned if the status code from the rest api is not 200.

func (APIError) Error

func (e APIError) Error() string

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 WithEnvironment

func WithEnvironment(environment string) Option

WithEnvironment is an option for specifying the environment. Must be set.

func WithIndexName

func WithIndexName(name string) Option

WithIndexName is an option for specifying the index name. Must be set.

func WithNameSpace

func WithNameSpace(nameSpace string) Option

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

func WithProjectName

func WithProjectName(name string) Option

WithProjectName is an option for specifying the project name. Must be set. The project name associated with the api key can be obtained using the whoami operation.

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(ctx context.Context, opts ...Option) (Store, error)

New creates a new Store with options. Options for index name, environment, project name and embedder must be set.

func (Store) AddDocuments

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

AddDocuments creates vector embeddings from the documents using the embedder and upsert the vectors to the pinecone index.

func (Store) Close

func (s Store) Close() error

Close closes the grpc connection.

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