mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
Feature/Multer to s3 (#2408)
* add ability to store files from multer to s3 * add check to bypass doc loader
This commit is contained in:
@@ -374,6 +374,44 @@ export const saveUpsertFlowData = (nodeData: INodeData, upsertHistory: Record<st
|
||||
return existingUpsertFlowData
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if doc loader should be bypassed, ONLY if doc loader is connected to a vector store
|
||||
* Reason being we dont want to load the doc loader again whenever we are building the flow, because it was already done during upserting
|
||||
* TODO: Remove this logic when we remove doc loader nodes from the canvas
|
||||
* @param {IReactFlowNode} reactFlowNode
|
||||
* @param {IReactFlowNode[]} reactFlowNodes
|
||||
* @param {IReactFlowEdge[]} reactFlowEdges
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const checkIfDocLoaderShouldBeIgnored = (
|
||||
reactFlowNode: IReactFlowNode,
|
||||
reactFlowNodes: IReactFlowNode[],
|
||||
reactFlowEdges: IReactFlowEdge[]
|
||||
): boolean => {
|
||||
let outputId = ''
|
||||
|
||||
if (reactFlowNode.data.outputAnchors.length) {
|
||||
if (Object.keys(reactFlowNode.data.outputs || {}).length) {
|
||||
const output = reactFlowNode.data.outputs?.output
|
||||
const node = reactFlowNode.data.outputAnchors[0].options?.find((anchor) => anchor.name === output)
|
||||
if (node) outputId = (node as ICommonObject).id
|
||||
} else {
|
||||
outputId = (reactFlowNode.data.outputAnchors[0] as ICommonObject).id
|
||||
}
|
||||
}
|
||||
|
||||
const targetNodeId = reactFlowEdges.find((edge) => edge.sourceHandle === outputId)?.target
|
||||
|
||||
if (targetNodeId) {
|
||||
const targetNodeCategory = reactFlowNodes.find((nd) => nd.id === targetNodeId)?.data.category || ''
|
||||
if (targetNodeCategory === 'Vector Stores') {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Build langchain from start to end
|
||||
* @param {string[]} startingNodeIds
|
||||
@@ -446,7 +484,6 @@ export const buildFlow = async (
|
||||
|
||||
const reactFlowNodeData: INodeData = resolveVariables(flowNodeData, flowNodes, question, chatHistory)
|
||||
|
||||
// TODO: Avoid processing Text Splitter + Doc Loader once Upsert & Load Existing Vector Nodes are deprecated
|
||||
if (isUpsert && stopNodeId && nodeId === stopNodeId) {
|
||||
logger.debug(`[server]: Upserting ${reactFlowNode.data.label} (${reactFlowNode.data.id})`)
|
||||
const indexResult = await newNodeInstance.vectorStoreMethods!['upsert']!.call(newNodeInstance, reactFlowNodeData, {
|
||||
@@ -464,6 +501,12 @@ export const buildFlow = async (
|
||||
if (indexResult) upsertHistory['result'] = indexResult
|
||||
logger.debug(`[server]: Finished upserting ${reactFlowNode.data.label} (${reactFlowNode.data.id})`)
|
||||
break
|
||||
} else if (
|
||||
!isUpsert &&
|
||||
reactFlowNode.data.category === 'Document Loaders' &&
|
||||
checkIfDocLoaderShouldBeIgnored(reactFlowNode, reactFlowNodes, reactFlowEdges)
|
||||
) {
|
||||
initializedNodes.add(nodeId)
|
||||
} else {
|
||||
logger.debug(`[server]: Initializing ${reactFlowNode.data.label} (${reactFlowNode.data.id})`)
|
||||
let outputResult = await newNodeInstance.init(reactFlowNodeData, question, {
|
||||
@@ -935,7 +978,7 @@ export const mapMimeTypeToInputField = (mimeType: string) => {
|
||||
case 'text/yaml':
|
||||
return 'yamlFile'
|
||||
default:
|
||||
return ''
|
||||
return 'txtFile'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user