MariaDB store
features and configurations head to the API reference.
Overview
Integration details
Class | Package | PY support | Version |
---|---|---|---|
MariaDBStore | @langchain/community | ✅ |
Setup
To use MariaDBVector vector stores, you’ll need to set up a MariaDB 11.7 version or later with themariadb
connector as a peer dependency.
This guide will also use OpenAI embeddings, which require you to install the @langchain/openai
integration package. You can also use other supported embeddings models if you wish.
We’ll also use the uuid
package to generate ids in the required format.
Setting up an instance
Create a file with the below content named docker-compose.yml:Credentials
To connect to you MariaDB instance, you’ll need corresponding credentials. For a full list of supported options, see themariadb
docs.
If you are using OpenAI embeddings for this guide, you’ll need to set your OpenAI key as well:
Instantiation
To instantiate the vector store, call the.initialize()
static method. This will automatically check for the presence of a table, given by tableName
in the passed config
. If it is not there, it will create it with the required columns.
Manage vector store
Add items to vector store
Delete items from vector store
Query vector store
Once your vector store has been created and the relevant documents have been added you will most likely wish to query it during the running of your chain or agent.Query directly
Performing a simple similarity search can be done as follows:Query by turning into retriever
You can also transform the vector store into a retriever for easier usage in your chains.Usage for retrieval-augmented generation
For guides on how to use this vector store for retrieval-augmented generation (RAG), see the following sections:Advanced: reusing connections
You can reuse connections by creating a pool, then creating newMariaDBStore
instances directly via the constructor.
Note that you should call .initialize()
to set up your database at least once to set up your tables properly before using the constructor.
Closing connections
Make sure you close the connection when you are finished to avoid excessive resource consumption:API reference
For detailed documentation of allMariaDBStore
features and configurations head to the API reference.