Skip to content

[fix 4206]: fix the empty array return for getBaseClasses when using typeorm driver and not the PGVectorStore #4225

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

Merged
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
26 changes: 25 additions & 1 deletion packages/components/nodes/vectorstores/Postgres/Postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
]
}
]
}
Expand Down