({
endingNodeIds,
componentNodes,
reactFlowNodes,
incomingInput,
flowConfig,
uploadedFilesContent,
availableVariables,
apiOverrideStatus,
nodeOverrides,
variableOverrides
}: {
endingNodeIds: string[]
componentNodes: IComponentNodes
reactFlowNodes: IReactFlowNode[]
incomingInput: IncomingInput
flowConfig: IFlowConfig
uploadedFilesContent: string
availableVariables: IVariable[]
apiOverrideStatus: boolean
nodeOverrides: INodeOverrides
variableOverrides: IVariableOverride[]
})
| 142 | } |
| 143 | |
| 144 | const initEndingNode = async ({ |
| 145 | endingNodeIds, |
| 146 | componentNodes, |
| 147 | reactFlowNodes, |
| 148 | incomingInput, |
| 149 | flowConfig, |
| 150 | uploadedFilesContent, |
| 151 | availableVariables, |
| 152 | apiOverrideStatus, |
| 153 | nodeOverrides, |
| 154 | variableOverrides |
| 155 | }: { |
| 156 | endingNodeIds: string[] |
| 157 | componentNodes: IComponentNodes |
| 158 | reactFlowNodes: IReactFlowNode[] |
| 159 | incomingInput: IncomingInput |
| 160 | flowConfig: IFlowConfig |
| 161 | uploadedFilesContent: string |
| 162 | availableVariables: IVariable[] |
| 163 | apiOverrideStatus: boolean |
| 164 | nodeOverrides: INodeOverrides |
| 165 | variableOverrides: IVariableOverride[] |
| 166 | }): Promise<{ endingNodeData: INodeData; endingNodeInstance: any }> => { |
| 167 | const question = incomingInput.question |
| 168 | const chatHistory = flowConfig.chatHistory |
| 169 | const sessionId = flowConfig.sessionId |
| 170 | |
| 171 | const nodeToExecute = |
| 172 | endingNodeIds.length === 1 |
| 173 | ? reactFlowNodes.find((node: IReactFlowNode) => endingNodeIds[0] === node.id) |
| 174 | : reactFlowNodes[reactFlowNodes.length - 1] |
| 175 | |
| 176 | if (!nodeToExecute) { |
| 177 | throw new InternalFlowiseError(StatusCodes.NOT_FOUND, `Node not found`) |
| 178 | } |
| 179 | |
| 180 | if (incomingInput.overrideConfig && apiOverrideStatus) { |
| 181 | nodeToExecute.data = replaceInputsWithConfig(nodeToExecute.data, incomingInput.overrideConfig, nodeOverrides, variableOverrides) |
| 182 | } |
| 183 | |
| 184 | const reactFlowNodeData: INodeData = await resolveVariables( |
| 185 | nodeToExecute.data, |
| 186 | reactFlowNodes, |
| 187 | question, |
| 188 | chatHistory, |
| 189 | flowConfig, |
| 190 | uploadedFilesContent, |
| 191 | availableVariables, |
| 192 | variableOverrides |
| 193 | ) |
| 194 | |
| 195 | logger.debug(`[server]: Running ${reactFlowNodeData.label} (${reactFlowNodeData.id})`) |
| 196 | |
| 197 | const nodeInstanceFilePath = componentNodes[reactFlowNodeData.name].filePath as string |
| 198 | const nodeModule = await import(nodeInstanceFilePath) |
| 199 | const nodeInstance = new nodeModule.nodeClass({ sessionId }) |
| 200 | |
| 201 | return { endingNodeData: reactFlowNodeData, endingNodeInstance: nodeInstance } |
no test coverage detected