Cloud SQL shared connection pool
Setup:
Install @langchain/google-cloud-sql-pg
import { Column, PostgresEngine, PostgresEngineArgs } from "@langchain/google-cloud-sql-pg";
const pgArgs: PostgresEngineArgs = {
user: "db-user",
password: "password"
}
const engine: PostgresEngine = await PostgresEngine.fromInstance(
"project-id",
"region",
"instance-name",
"database-name",
pgArgs
);
class PostgresEngineDispose of connection pool
Create a Cloud SQL table to store chat history.
Create a table for saving of vectors to be used with PostgresVectorStore.
Create a PostgresEngine instance from arguments.
Create a PostgresEngine instance from an Knex instance.