Documentation
¶
Overview ¶
Package mariadb contains an implementation of the VectorStore interface using MariaDB.
Index ¶
- Constants
- Variables
- type CloseNoErr
- type DB
- type Option
- func WithCollectionTableName(name string) Option
- func WithConnectionURL(connectionURL string) Option
- func WithDB(db DB) Option
- func WithDatabaseMetadata(metadata map[string]any) Option
- func WithDatabaseName(name string) Option
- func WithEmbedder(e embeddings.Embedder) Option
- func WithEmbeddingTableName(name string) Option
- func WithPreDeleteDatabase(preDelete bool) Option
- func WithVectorDimensions(size int) Option
- type Store
- func (s Store) AddDocuments(ctx context.Context, docs []schema.Document, options ...vectorstores.Option) ([]string, error)
- func (s Store) Close() error
- func (s Store) DropTables(ctx context.Context) error
- func (s Store) RemoveDatabase(ctx context.Context, tx *sql.Tx) error
- func (s Store) Search(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 ¶
const ( DefaultDatabaseName = "langchain" DefaultPreDeleteDatabase = false DefaultEmbeddingStoreTableName = "langchain_mariadb_embedding" DefaultCollectionStoreTableName = "langchain_mariadb_collection" )
Variables ¶
var ( ErrEmbedderWrongNumberVectors = errors.New("number of vectors from embedder does not match number of documents") ErrInvalidScoreThreshold = errors.New("score threshold must be between 0 and 1") ErrInvalidFilters = errors.New("invalid filters") ErrUnsupportedOptions = errors.New("unsupported options") )
var ErrInvalidOptions = errors.New("invalid options")
ErrInvalidOptions is returned when the options given are invalid.
Functions ¶
This section is empty.
Types ¶
type CloseNoErr ¶
type CloseNoErr interface {
Close()
}
type DB ¶
type DB interface {
PingContext(ctx context.Context) error
BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
ExecContext(ctx context.Context, sql string, arguments ...any) (sql.Result, error)
QueryContext(ctx context.Context, sql string, arguments ...any) (*sql.Rows, error)
QueryRowContext(ctx context.Context, sql string, arguments ...any) *sql.Row
}
DB represents both a sql.DB and sql.Tx.
type Option ¶
type Option func(p *Store)
Option is a function type that can be used to modify the client.
func WithCollectionTableName ¶
WithCollectionTableName is an option for specifying the collection table name.
func WithConnectionURL ¶
WithConnectionURL is an option for specifying the MariaDB connection URL. Either this or WithConn must be used.
func WithDatabaseMetadata ¶
WithDatabaseMetadata is an option for specifying the database metadata.
func WithDatabaseName ¶
WithDatabaseName is an option for specifying the database name.
func WithEmbedder ¶
func WithEmbedder(e embeddings.Embedder) Option
WithEmbedder is an option for setting the embedder to use. Must be set.
func WithEmbeddingTableName ¶
WithEmbeddingTableName is an option for specifying the embedding table name.
func WithPreDeleteDatabase ¶
WithPreDeleteDatabase is an option for setting if the database should be deleted before creating.
func WithVectorDimensions ¶
WithVectorDimensions is an option for specifying the vector size.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a wrapper around the mariadb client.
func (Store) AddDocuments ¶
func (s Store) AddDocuments( ctx context.Context, docs []schema.Document, options ...vectorstores.Option, ) ([]string, error)
AddDocuments adds documents to the MariaDB database associated with 'Store'. and returns the ids of the added documents.