mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
feat: add driverInfo to mongodb component (#2779)
* feat: add driverInfo to mongodb component NODE-6240 * chore: add a getVersion utility function
This commit is contained in:
@@ -4,7 +4,7 @@ import { MongoDBAtlasVectorSearch } from '@langchain/mongodb'
|
||||
import { Embeddings } from '@langchain/core/embeddings'
|
||||
import { Document } from '@langchain/core/documents'
|
||||
import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams, IndexingResult } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam, getVersion } from '../../../src/utils'
|
||||
import { addMMRInputParams, resolveVectorStoreOrRetriever } from '../VectorStoreUtils'
|
||||
|
||||
class MongoDBAtlas_VectorStores implements INode {
|
||||
@@ -191,15 +191,17 @@ let mongoClientSingleton: MongoClient
|
||||
let mongoUrl: string
|
||||
|
||||
const getMongoClient = async (newMongoUrl: string) => {
|
||||
const driverInfo = { name: 'Flowise', version: (await getVersion()).version }
|
||||
|
||||
if (!mongoClientSingleton) {
|
||||
// if client does not exist
|
||||
mongoClientSingleton = new MongoClient(newMongoUrl)
|
||||
mongoClientSingleton = new MongoClient(newMongoUrl, { driverInfo })
|
||||
mongoUrl = newMongoUrl
|
||||
return mongoClientSingleton
|
||||
} else if (mongoClientSingleton && newMongoUrl !== mongoUrl) {
|
||||
// if client exists but url changed
|
||||
mongoClientSingleton.close()
|
||||
mongoClientSingleton = new MongoClient(newMongoUrl)
|
||||
mongoClientSingleton = new MongoClient(newMongoUrl, { driverInfo })
|
||||
mongoUrl = newMongoUrl
|
||||
return mongoClientSingleton
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user