mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 17:01:00 +03:00
[Prostgres Vector Store] Add PGVector Driver option + Fix null character issue w/ TypeORM Driver (#3367)
* Add PGVector Driver option + Fix null character issue w/ TypeORM Driver * Handle file upload case with PGVector * Cleanup * Fix data filtering for chatflow uploaded files * Add distanceStrategy parameter * Fix query to improve chatflow uploaded files filtering * Ensure PGVector release connections * Await client connected * Make Postgres credentials optionnal when set on env variables * Document env variables in nodes directories * Prevent reuse client * Fix empty metadataFilter * Update CONTRIBUTING.md * Update Postgres.ts --------- Co-authored-by: Henry Heng <henryheng@flowiseai.com>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { VectorStore } from '@langchain/core/vectorstores'
|
||||
import { getCredentialData, getCredentialParam, ICommonObject, INodeData } from '../../../../src'
|
||||
import { Document } from '@langchain/core/documents'
|
||||
import { Embeddings } from '@langchain/core/embeddings'
|
||||
import { getDatabase, getHost, getPort, getTableName } from '../utils'
|
||||
|
||||
export abstract class VectorStoreDriver {
|
||||
constructor(protected nodeData: INodeData, protected options: ICommonObject) {}
|
||||
|
||||
abstract instanciate(metaDataFilters?: any): Promise<VectorStore>
|
||||
|
||||
abstract fromDocuments(documents: Document[]): Promise<VectorStore>
|
||||
|
||||
protected async adaptInstance(instance: VectorStore, _metaDataFilters?: any): Promise<VectorStore> {
|
||||
return instance
|
||||
}
|
||||
|
||||
getHost() {
|
||||
return getHost(this.nodeData) as string
|
||||
}
|
||||
|
||||
getPort() {
|
||||
return getPort(this.nodeData) as number
|
||||
}
|
||||
|
||||
getDatabase() {
|
||||
return getDatabase(this.nodeData) as string
|
||||
}
|
||||
|
||||
getTableName() {
|
||||
return getTableName(this.nodeData)
|
||||
}
|
||||
|
||||
getEmbeddings() {
|
||||
return this.nodeData.inputs?.embeddings as Embeddings
|
||||
}
|
||||
|
||||
async getCredentials() {
|
||||
const credentialData = await getCredentialData(this.nodeData.credential ?? '', this.options)
|
||||
const user = getCredentialParam('user', credentialData, this.nodeData, process.env.POSTGRES_VECTORSTORE_USER)
|
||||
const password = getCredentialParam('password', credentialData, this.nodeData, process.env.POSTGRES_VECTORSTORE_PASSWORD)
|
||||
|
||||
return {
|
||||
user,
|
||||
password
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user