weaviate

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

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

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")
	ErrInvalidResponse       = errors.New("invalid response")
	ErrInvalidScoreThreshold = errors.New(
		"score threshold must be between 0 and 1")
	ErrInvalidFilter = errors.New("invalid filter")
)
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 WEAVIATE_API_KEY environment variable.

func WithAdditionalFields

func WithAdditionalFields(additionalFields []string) Option

WithAdditionalFields is an option for setting additional fields query attributes of the weaviate server.

func WithAuthConfig

func WithAuthConfig(authConfig auth.Config) Option

WithAuthConfig is an option for setting the auth config of the weaviate server.

func WithConnectionClient

func WithConnectionClient(connectionClient *http.Client) Option

WithConnectionClient is an option for setting the connection client of the weaviate server.

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 of the weaviate server.

func WithIndexName

func WithIndexName(indexName string) Option

WithIndexName is an option for specifying the index name. Must be set. The index name is the name of the class in weaviate. Multiple words should be concatenated in CamelCase, e.g. ArticleAuthor. https://weaviate.io/developers/weaviate/api/rest/schema#create-a-class

func WithNameSpace

func WithNameSpace(nameSpace string) Option

WithNameSpace is an option for setting the nameSpace to upsert and query the vectors.

func WithNameSpaceKey

func WithNameSpaceKey(nameSpaceKey string) Option

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

func WithQueryAttrs

func WithQueryAttrs(queryAttrs []string) Option

WithQueryAttrs is an option for setting the query attributes of the weaviate server.

func WithScheme

func WithScheme(scheme string) Option

WithScheme is an option for setting the scheme of the weaviate server.

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 weaviate client.

func New

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

New creates a new Store with options. When using weaviate, the properties in the Class of weaviate must have properties with the values set by textKey and nameSpaceKey.

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 upsert the vectors to the weaviate index. and returns the ids of the added documents.

func (Store) MetadataSearch

func (s Store) MetadataSearch(
	ctx context.Context,
	numDocuments int,
	options ...vectorstores.Option,
) ([]schema.Document, error)

MetadataSearch searches weaviate based on metadata rather than based on similarity. Use `vectorstores.WithFilter(*filters.WhereBuilder)` to provide a where condition as an option.

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