pinecone

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package pinecone implements a genkit plugin for the Pinecone vector database. This defines an indexer and a retriever.

Accessing Pinecone requires an API key, passed via Config. If the API key is the empty string, the plugin will use the PINECONE_API_KEY environment variable.

All Pinecone data is stored in what Pinecone calls an index. The Pinecone plugin supports a single index, passed via Config.

Indexes can be partitioned into namespaces. Operations that use indexes pass a namespace argument, via IndexerOptions or RetrieverOptions. If the namespace is not specified the code uses the default namespace.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefineIndexer

func DefineIndexer(ctx context.Context, cfg Config) (ai.Indexer, error)

DefineIndexer defines an Indexer with the given configuration.

func DefineRetriever

func DefineRetriever(ctx context.Context, cfg Config) (ai.Retriever, error)

DefineRetriever defines a Retriever with the given configuration.

func Indexer

func Indexer(name string) ai.Indexer

Indexer returns the indexer with the given index name.

func Init

func Init(ctx context.Context, apiKey string) (err error)

Init initializes the Pinecone plugin. If apiKey is the empty string, it is read from the PINECONE_API_KEY environment variable.

func IsDefinedIndexer added in v0.1.0

func IsDefinedIndexer(name string) bool

IsDefinedIndexer reports whether the named Indexer is defined by this plugin.

func IsDefinedRetriever added in v0.1.0

func IsDefinedRetriever(name string) bool

IsDefinedRetriever reports whether the named Retriever is defined by this plugin.

func Retriever

func Retriever(name string) ai.Retriever

Retriever returns the retriever with the given index name.

Types

type Config

type Config struct {
	// The index ID to use.
	IndexID string
	// Embedder to use. Required.
	Embedder        ai.Embedder
	EmbedderOptions any
	// The metadata key to use to store document text
	// in Pinecone; the default is "_content".
	TextKey string
}

Config provides configuration options for DefineIndexer and DefineRetriever.

type IndexerOptions

type IndexerOptions struct {
	Namespace string `json:"namespace,omitempty"` // Pinecone namespace to use
}

IndexerOptions may be passed in the Options field of ai.IndexerRequest to pass options to Pinecone. The Options field should be either nil or a value of type *IndexerOptions.

type RetrieverOptions

type RetrieverOptions struct {
	Namespace string `json:"namespace,omitempty"` // Pinecone namespace to use
	Count     int    `json:"count,omitempty"`     // maximum number of values to retrieve
}

RetrieverOptions may be passed in the Options field of ai.RetrieverRequest to pass options to Pinecone. The Options field should be either nil or a value of type *RetrieverOptions.

Jump to

Keyboard shortcuts

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