Skip to content
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

fix(Postgres PGVector Store Node): Do not initialize client to avoid idle connections #12318

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ class ExtendedPGVectorStore extends PGVectorStore {
const { dimensions, ...rest } = args;
const postgresqlVectorStore = new this(embeddings, rest);

await postgresqlVectorStore._initializeClient();
// Workaround to fix https://github.com/langchain-ai/langchainjs/issues/5029#issuecomment-2468147921
// await postgresqlVectorStore._initializeClient();
await postgresqlVectorStore.ensureTableInDatabase(dimensions);
if (postgresqlVectorStore.collectionTableName) {
await postgresqlVectorStore.ensureCollectionTableInDatabase();
Expand Down Expand Up @@ -307,6 +308,7 @@ export class VectorStorePGVector extends createVectorStoreNode({
metadataColumnName: 'metadata',
}) as ColumnOptions;

await PGVectorStore.fromDocuments(documents, embeddings, config);
const vectorStore = await PGVectorStore.fromDocuments(documents, embeddings, config);
await vectorStore.end();
},
}) {}