mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 01:01:11 +03:00
Update langchainjs
This commit is contained in:
@@ -92,7 +92,7 @@ class VectaraExisting_VectorStores implements INode {
|
|||||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||||
const apiKey = getCredentialParam('apiKey', credentialData, nodeData)
|
const apiKey = getCredentialParam('apiKey', credentialData, nodeData)
|
||||||
const customerId = getCredentialParam('customerID', credentialData, nodeData)
|
const customerId = getCredentialParam('customerID', credentialData, nodeData)
|
||||||
const corpusId = getCredentialParam('corpusID', credentialData, nodeData)
|
const corpusId = getCredentialParam('corpusID', credentialData, nodeData).split(',')
|
||||||
|
|
||||||
const vectaraMetadataFilter = nodeData.inputs?.filter as string
|
const vectaraMetadataFilter = nodeData.inputs?.filter as string
|
||||||
const sentencesBefore = nodeData.inputs?.sentencesBefore as number
|
const sentencesBefore = nodeData.inputs?.sentencesBefore as number
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
|
import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
|
||||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||||
import { VectaraStore, VectaraLibArgs, VectaraFilter, VectaraContextConfig } from 'langchain/vectorstores/vectara'
|
import { VectaraStore, VectaraLibArgs, VectaraFilter, VectaraContextConfig, VectaraFile } from 'langchain/vectorstores/vectara'
|
||||||
|
|
||||||
class VectaraUpload_VectorStores implements INode {
|
class VectaraUpload_VectorStores implements INode {
|
||||||
label: string
|
label: string
|
||||||
@@ -99,7 +99,7 @@ class VectaraUpload_VectorStores implements INode {
|
|||||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||||
const apiKey = getCredentialParam('apiKey', credentialData, nodeData)
|
const apiKey = getCredentialParam('apiKey', credentialData, nodeData)
|
||||||
const customerId = getCredentialParam('customerID', credentialData, nodeData)
|
const customerId = getCredentialParam('customerID', credentialData, nodeData)
|
||||||
const corpusId = getCredentialParam('corpusID', credentialData, nodeData)
|
const corpusId = getCredentialParam('corpusID', credentialData, nodeData).split(',')
|
||||||
|
|
||||||
const fileBase64 = nodeData.inputs?.file
|
const fileBase64 = nodeData.inputs?.file
|
||||||
const vectaraMetadataFilter = nodeData.inputs?.filter as string
|
const vectaraMetadataFilter = nodeData.inputs?.filter as string
|
||||||
@@ -133,17 +133,17 @@ class VectaraUpload_VectorStores implements INode {
|
|||||||
files = [fileBase64]
|
files = [fileBase64]
|
||||||
}
|
}
|
||||||
|
|
||||||
const blobs: Blob[] = []
|
const vectaraFiles: VectaraFile[] = []
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const splitDataURI = file.split(',')
|
const splitDataURI = file.split(',')
|
||||||
splitDataURI.pop()
|
splitDataURI.pop()
|
||||||
const bf = Buffer.from(splitDataURI.pop() || '', 'base64')
|
const bf = Buffer.from(splitDataURI.pop() || '', 'base64')
|
||||||
const blob = new Blob([bf])
|
const blob = new Blob([bf])
|
||||||
blobs.push(blob)
|
vectaraFiles.push({ blob: blob, fileName: getFileName(file) })
|
||||||
}
|
}
|
||||||
|
|
||||||
const vectorStore = new VectaraStore(vectaraArgs)
|
const vectorStore = new VectaraStore(vectaraArgs)
|
||||||
const res = await vectorStore.addFiles(blobs)
|
await vectorStore.addFiles(vectaraFiles)
|
||||||
files = []
|
files = []
|
||||||
|
|
||||||
if (output === 'retriever') {
|
if (output === 'retriever') {
|
||||||
@@ -157,4 +157,21 @@ class VectaraUpload_VectorStores implements INode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getFileName = (fileBase64: string) => {
|
||||||
|
let fileNames = []
|
||||||
|
if (fileBase64.startsWith('[') && fileBase64.endsWith(']')) {
|
||||||
|
const files = JSON.parse(fileBase64)
|
||||||
|
for (const file of files) {
|
||||||
|
const splitDataURI = file.split(',')
|
||||||
|
const filename = splitDataURI[splitDataURI.length - 1].split(':')[1]
|
||||||
|
fileNames.push(filename)
|
||||||
|
}
|
||||||
|
return fileNames.join(', ')
|
||||||
|
} else {
|
||||||
|
const splitDataURI = fileBase64.split(',')
|
||||||
|
const filename = splitDataURI[splitDataURI.length - 1].split(':')[1]
|
||||||
|
return filename
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = { nodeClass: VectaraUpload_VectorStores }
|
module.exports = { nodeClass: VectaraUpload_VectorStores }
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class VectaraUpsert_VectorStores implements INode {
|
|||||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||||
const apiKey = getCredentialParam('apiKey', credentialData, nodeData)
|
const apiKey = getCredentialParam('apiKey', credentialData, nodeData)
|
||||||
const customerId = getCredentialParam('customerID', credentialData, nodeData)
|
const customerId = getCredentialParam('customerID', credentialData, nodeData)
|
||||||
const corpusId = getCredentialParam('corpusID', credentialData, nodeData)
|
const corpusId = getCredentialParam('corpusID', credentialData, nodeData).split(',')
|
||||||
|
|
||||||
const docs = nodeData.inputs?.document as Document[]
|
const docs = nodeData.inputs?.document as Document[]
|
||||||
const embeddings = {} as Embeddings
|
const embeddings = {} as Embeddings
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
"google-auth-library": "^9.0.0",
|
"google-auth-library": "^9.0.0",
|
||||||
"graphql": "^16.6.0",
|
"graphql": "^16.6.0",
|
||||||
"html-to-text": "^9.0.5",
|
"html-to-text": "^9.0.5",
|
||||||
"langchain": "^0.0.133",
|
"langchain": "^0.0.147",
|
||||||
"linkifyjs": "^4.1.1",
|
"linkifyjs": "^4.1.1",
|
||||||
"mammoth": "^1.5.1",
|
"mammoth": "^1.5.1",
|
||||||
"moment": "^2.29.3",
|
"moment": "^2.29.3",
|
||||||
|
|||||||
Reference in New Issue
Block a user