Documentation ¶
Overview ¶
Package weaviate contains an implementation of the VectorStore interface using weaviate.
Index ¶
- Variables
- type Option
- func WithAPIKey(apiKey string) Option
- func WithAdditionalFields(additionalFields []string) Option
- func WithAuthConfig(authConfig auth.Config) Option
- func WithConnectionClient(connectionClient *http.Client) Option
- func WithEmbedder(e embeddings.Embedder) Option
- func WithHost(host string) Option
- func WithIndexName(indexName string) Option
- func WithNameSpace(nameSpace string) Option
- func WithNameSpaceKey(nameSpaceKey string) Option
- func WithQueryAttrs(queryAttrs []string) Option
- func WithScheme(scheme string) Option
- func WithTextKey(textKey string) Option
- type Store
- func (s Store) AddDocuments(ctx context.Context, docs []schema.Document, options ...vectorstores.Option) ([]string, error)
- func (s Store) MetadataSearch(ctx context.Context, numDocuments int, options ...vectorstores.Option) ([]schema.Document, error)
- func (s Store) SimilaritySearch(ctx context.Context, query string, numDocuments int, ...) ([]schema.Document, error)
Constants ¶
This section is empty.
Variables ¶
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") )
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 ¶
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 ¶
WithAdditionalFields is an option for setting additional fields query attributes of the weaviate server.
func WithAuthConfig ¶
WithAuthConfig is an option for setting the auth config of the weaviate server.
func WithConnectionClient ¶
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 WithIndexName ¶
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 ¶
WithNameSpace is an option for setting the nameSpace to upsert and query the vectors.
func WithNameSpaceKey ¶
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 ¶
WithQueryAttrs is an option for setting the query attributes of the weaviate server.
func WithScheme ¶
WithScheme is an option for setting the scheme of the weaviate server.
func WithTextKey ¶
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 ¶
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.