Skip to main content
An implementation of LangChain vectorstore abstraction using gel as the backend.
Gel is an open-source PostgreSQL data layer optimized for fast development to production cycle. It comes with a high-level strictly typed graph-like data model, composable hierarchical query language, full SQL support, migrations, Auth and AI modules. The code lives in an integration package called langchain-gel.

Setup

First install relevant packages:

Initialization

In order to use Gel as a backend for your VectorStore, you’re going to need a working Gel instance. Fortunately, it doesn’t have to involve Docker containers or anything complicated, unless you want to! To set up a local instance, run:
If you are using Gel Cloud (and you should!), add one more argument to that command:
For a comprehensive list of ways to run Gel, take a look at Running Gel section of the reference docs.

Set up the schema

Gel schema is an explicit high-level description of your application’s data model. Aside from enabling you to define exactly how your data is going to be laid out, it drives Gel’s many powerful features such as links, access policies, functions, triggers, constraints, indexes, and more. The LangChain’s VectorStore expects the following layout for the schema:
In order to apply schema changes to the database, run a migration using Gel’s migration mechanism:
From this point onward, GelVectorStore can be used as a drop-in replacement for any other vectorstore available in LangChain.

Instantiation

Manage vector store

Add items to vector store

Note that adding documents by ID will over-write any existing documents that match that ID.

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.

Filtering support

The vectorstore supports a set of filters that can be applied against the metadata fields of the documents.

Query directly

Performing a simple similarity search can be done as follows:
If you provide a dict with multiple fields, but no operators, the top level will be interpreted as a logical AND filter
If you want to execute a similarity search and receive the corresponding scores you can run:

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:

API reference

For detailed documentation of all GelVectorStore features and configurations head to the GitHub docs.