Google Cloud SQL for PostgreSQL vector store integration.

Setup: Install@langchain/google-cloud-sql-pg

npm install @langchain/google-cloud-sql-pg
Use with Table Name < /strong>
import { PostgresEngine, PostgresLoader } from "@langchain/google-cloud-sql-pg";

const documentLoaderArgs: PostgresLoaderOptions = {
tableName: "test_table_custom",
contentColumns: [ "fruit_name", "variety"],
metadataColumns: ["fruit_id", "quantity_in_stock", "price_per_unit", "organic"],
format: "text"
};

const documentLoaderInstance = await PostgresLoader.initialize(PEInstance, documentLoaderArgs);

const documents = await documentLoaderInstance.load();

Use with Query < /strong>
import { PostgresEngine, PostgresLoader } from "@langchain/google-cloud-sql-pg";

const documentLoaderArgs: PostgresLoaderOptions = {
query: "SELECT * FROM my_table WHERE organic = true;",
contentColumns: [ "fruit_name", "variety"],
metadataColumns: ["fruit_id", "quantity_in_stock", "price_per_unit", "organic"],
format: "text"
};

const documentLoaderInstance = await PostgresLoader.initialize(PEInstance, documentLoaderArgs);

for await (const doc of documentLoaderInstance.lazyLoad()) {
console.log(doc);
break; // break based on required condition
}

Hierarchy (view full)

Constructors

Properties

contentColumns?: string[]
format?:
    | "text"
    | "json"
    | "yaml"
    | "csv"
formatter?: ((row: Row, contentColumns: string[]) => string)
metadataColumns?: string[]
metadataJsonColumn?: null | string
query?: string
schemaName?: string
tableName?: string

Methods

  • Parameters

    • Optionalsplitter: BaseDocumentTransformer<DocumentInterface<Record<string, any>>[], DocumentInterface<Record<string, any>>[]>

    Returns Promise<Document<Record<string, any>>[]>

    A Promise that resolves with an array of Document instances, each split according to the provided TextSplitter.

    Use this.load() and splitter.splitDocuments() individually. Loads the documents and splits them using a specified text splitter.