...

/

Using PostgreSQL as a Vector Store with LangChain

Using PostgreSQL as a Vector Store with LangChain

Build a langchaingo application with PostgreSQL as a vector store.

In this lesson, we will see how to use langchaingo vector store component to improve the integration process. Instead of dealing with PostgreSQL-specific logic, we can simply use the pgvector implementation available in langchaingo.

We will continue to use the movie recommendation example and walk through how to implement a service that provides movie recommendations based on user-provided search criteria. This is split into these steps, which will be executed in order:

  1. Load the movie data into the table.

  2. Use the movie recommendation service.

Note: We don't need an additional step to enable pgvector extension and table creation in the database since the langchaingo pgvector implementation can do that automatically during the initialization phase.

Press + to interact
Key steps in the application
Key steps in the application

Below is the high-level architecture of the solution.

  • The movie data (including name and description) is converted into vector embeddings and loaded into PostgreSQL database.

  • When a user queries for movie recommendations, the application executes a similarity search in the PostgreSQL database.

Press + to interact
High-level architecture
High-level architecture

Set up managed PostgreSQL service

Note: If you already configured the PostgreSQL service from the previous lessons, please skip this section.

Aiven is a fully managed cloud database platform that provides various open-source database services, including PostgreSQL. It offers an easy way to set up and manage a PostgreSQL database with ...