From 3bd2d63a1983e8145e2abb46dbf2653fae338250 Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Wed, 2 Apr 2025 23:17:14 +0530 Subject: [PATCH] [fix 4206]: fix the empty array return for getBaseClasses when using typeorm driver and not the PGVectorStore (#4225) fix the empty array return for getBaseClasses when using typeorm driver and not the PGVectorStore Co-authored-by: Aman Agarwal --- .../nodes/vectorstores/Postgres/Postgres.ts | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/components/nodes/vectorstores/Postgres/Postgres.ts b/packages/components/nodes/vectorstores/Postgres/Postgres.ts index 7cc96d61..ad0f82bb 100644 --- a/packages/components/nodes/vectorstores/Postgres/Postgres.ts +++ b/packages/components/nodes/vectorstores/Postgres/Postgres.ts @@ -12,6 +12,26 @@ import { getContentColumnName, getDatabase, getHost, getPort, getTableName } fro const serverCredentialsExists = !!process.env.POSTGRES_VECTORSTORE_USER && !!process.env.POSTGRES_VECTORSTORE_PASSWORD +// added temporarily to fix the base class return for VectorStore when postgres node is using TypeORM +function getVectorStoreBaseClasses() { + // Try getting base classes through the utility function + const baseClasses = getBaseClasses(VectorStore) + + // If we got results, return them + if (baseClasses && baseClasses.length > 0) { + return baseClasses + } + + // If VectorStore is recognized as a class but getBaseClasses returned nothing, + // return the known inheritance chain + if (VectorStore instanceof Function) { + return ['VectorStore'] + } + + // Fallback to minimum required class + return ['VectorStore'] +} + class Postgres_VectorStores implements INode { label: string name: string @@ -195,7 +215,11 @@ class Postgres_VectorStores implements INode { { label: 'Postgres Vector Store', name: 'vectorStore', - baseClasses: [this.type, ...getBaseClasses(VectorStore)] + baseClasses: [ + this.type, + // ...getBaseClasses(VectorStore), // disabled temporarily for using TypeORM + ...getVectorStoreBaseClasses() // added temporarily for using TypeORM + ] } ] }