weaviate

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefineIndexerAndRetriever

func DefineIndexerAndRetriever(ctx context.Context, cfg ClassConfig) (ai.Indexer, ai.Retriever, error)

DefineIndexerAndRetriever defines an ai.Indexer and ai.Retriever that use the same class. The name uniquely identifies the Indexer and Retriever in the registry.

func Indexer

func Indexer(class string) ai.Indexer

Indexer returns the indexer for the given class.

func Init

func Init(ctx context.Context, cfg *ClientConfig) (*weaviate.Client, error)

Init initializes the Weaviate plugin. The cfg argument may be nil to use the defaults. This returns the *weaviate.Client in case it is useful, but many users will be able to use just DefineIndexerAndRetriever.

func Retriever

func Retriever(class string) ai.Retriever

Retriever returns the retriever for the given class.

Types

type ClassConfig

type ClassConfig struct {
	// The weaviate class name. May not be the empty string.
	Class string

	// The Embedder and options to use to embed documents.
	// Embedder may not be nil.
	Embedder        ai.Embedder
	EmbedderOptions any
}

ClassConfig holds configuration options for an indexer/retriever pair. Weaviate stores data in collections, and each collection has a class name. Use a separate genkit Indexer/Retriever for each different class.

type ClientConfig

type ClientConfig struct {
	// The hostname:port to use to contact the Weaviate database.
	// If not set, the default is read from the WEAVIATE_URL environment variable.
	Addr string
	// The scheme to use to contact the Weaviate database.
	// Typically http or https.
	// If not set, the default is https.
	Scheme string
	// The API key to use with the Weaviate database.
	// If not set, the default is read from the WEAVIATE_API_KEY environment variable.
	APIKey string
}

ClientConfig passes configuration options to the plugin.

type RetrieverOptions

type RetrieverOptions struct {
	// Maximum number of values to retrieve.
	Count int `json:"count,omitempty"`
	// Keys to retrieve from document metadata.
	// There doesn't seem to be a way to ask for all of the metadata.
	MetadataKeys []string
}

RetrieverOptions may be passed in the Options field ai.RetrieverRequest to pass options to Weaviate. 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