Skip to content

Commit 2aeef50

Browse files
amanthegreatoneaman-syook
authored andcommitted
[fix 4206]: fix the empty array return for getBaseClasses when using typeorm driver and not the PGVectorStore (FlowiseAI#4225)
fix the empty array return for getBaseClasses when using typeorm driver and not the PGVectorStore Co-authored-by: Aman Agarwal <[email protected]>
1 parent 1b09a46 commit 2aeef50

File tree

1 file changed

+25
-1
lines changed
  • packages/components/nodes/vectorstores/Postgres

1 file changed

+25
-1
lines changed

packages/components/nodes/vectorstores/Postgres/Postgres.ts

+25-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,26 @@ import { getContentColumnName, getDatabase, getHost, getPort, getTableName } fro
1212

1313
const serverCredentialsExists = !!process.env.POSTGRES_VECTORSTORE_USER && !!process.env.POSTGRES_VECTORSTORE_PASSWORD
1414

15+
// added temporarily to fix the base class return for VectorStore when postgres node is using TypeORM
16+
function getVectorStoreBaseClasses() {
17+
// Try getting base classes through the utility function
18+
const baseClasses = getBaseClasses(VectorStore)
19+
20+
// If we got results, return them
21+
if (baseClasses && baseClasses.length > 0) {
22+
return baseClasses
23+
}
24+
25+
// If VectorStore is recognized as a class but getBaseClasses returned nothing,
26+
// return the known inheritance chain
27+
if (VectorStore instanceof Function) {
28+
return ['VectorStore']
29+
}
30+
31+
// Fallback to minimum required class
32+
return ['VectorStore']
33+
}
34+
1535
class Postgres_VectorStores implements INode {
1636
label: string
1737
name: string
@@ -195,7 +215,11 @@ class Postgres_VectorStores implements INode {
195215
{
196216
label: 'Postgres Vector Store',
197217
name: 'vectorStore',
198-
baseClasses: [this.type, ...getBaseClasses(VectorStore)]
218+
baseClasses: [
219+
this.type,
220+
// ...getBaseClasses(VectorStore), // disabled temporarily for using TypeORM
221+
...getVectorStoreBaseClasses() // added temporarily for using TypeORM
222+
]
199223
}
200224
]
201225
}

0 commit comments

Comments
 (0)