Overview
Integration details
Class | Package | PY support | Version |
---|---|---|---|
LibSQLVectorStore | @langchain/community | ❌ |
Setup
To use libSQL vector stores, you’ll need to create a Turso account or set up a local SQLite database, and install the@langchain/community
integration package.
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.
You can use local SQLite when working with the libSQL vector store, or use a hosted Turso Database.
npm
Local libSQL
Create a new local SQLite file and connect to the shell:Hosted Turso
Visit sqlite.new to create a new database, give it a name, and create a database auth token. Make sure to copy the database auth token, and the database URL, it should look something like:Setup the table and index
Execute the following SQL command to create a new table or add the embedding column to an existing table. Make sure to modify the following parts of the SQL:TABLE_NAME
is the name of the table you want to create.content
is used to store theDocument.pageContent
values.metadata
is used to store theDocument.metadata
object.EMBEDDING_COLUMN
is used to store the vector values, use the dimensions size used by the model you plan to use (1536 for OpenAI).
EMBEDDING_COLUMN
column - the index name is important!:
TABLE_NAME
and EMBEDDING_COLUMN
with the values you used in the previous step.
Instantiation
To initialize a newLibSQL
vector store, you need to provide the database URL and Auth Token when working remotely, or by passing the filename for a local SQLite.
Manage vector store
Add items to vector store
Delete items from vector store
Query vector store
Once you have inserted the documents, you can query the vector store.Query directly
Performing a simple similarity search can be done as follows:API reference
For detailed documentation of allLibSQLVectorStore
features and configurations head to the API reference.
Related
- Vector store conceptual guide
- Vector store how-to guides