-
Notifications
You must be signed in to change notification settings - Fork 230
feat(store-postgres): Add PostgresStore for LangGraph.js #1242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@@ -2,7 +2,7 @@ version: "3.8" | |||
|
|||
services: | |||
postgres: | |||
image: postgres:latest | |||
image: pgvector/pgvector:pg16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured that this won't have any effect on other integration tests relying on this docker-compose file, and it will enable store-postgres to be tested against vector search. I've also added docker-compose.test.yml
file in /libs/store-postgres
@@ -0,0 +1,87 @@ | |||
/* eslint-disable no-process-env */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've decided to group and split integration tests by tested module/functionality, as originally the file had over 1,5 k lines of code and would be harder to maintain
@@ -0,0 +1,392 @@ | |||
import pg from "pg"; | |||
import { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These types/objects are currently included in @langchain/langgraph-checkpoint
library, so I've added it as a dependency. I was kind of torn apart between copying them, or creating separate module for @langchain/langgraph-store
(similarily to @langchain/langgraph-checkpoint
). Lmk which approach would you like me to go with (or include the changes yourself 🙂)
Implement PostgreSQL Store with Vector Search Capabilities
Overview
This PR implements a PostgreSQL-based store for LangGraph.js inspired by #887 and Python implementation. The implementation includes comprehensive vector similarity search, hybrid search (combining vector and text search), and TTL management for automatic data expiration.
Key Features
Implementation Details
database-core.js
: Core connection and transaction managementdatabase-setup.js
: Schema initialization and migrationcrud-operations.js
: Basic CRUD operationssearch-operations.js
: Advanced search capabilitiesvector-operations.js
: Vector embedding and similarity calculationsttl-manager.js
: Expiration and cleanup managementquery-builder.js
: SQL query construction