| 447 | * @returns {boolean} |
| 448 | */ |
| 449 | const checkIfDocLoaderShouldBeIgnored = ( |
| 450 | reactFlowNode: IReactFlowNode, |
| 451 | reactFlowNodes: IReactFlowNode[], |
| 452 | reactFlowEdges: IReactFlowEdge[] |
| 453 | ): boolean => { |
| 454 | let outputId = '' |
| 455 | |
| 456 | if (reactFlowNode.data.outputAnchors.length) { |
| 457 | if (Object.keys(reactFlowNode.data.outputs || {}).length) { |
| 458 | const output = reactFlowNode.data.outputs?.output |
| 459 | const node = reactFlowNode.data.outputAnchors[0].options?.find((anchor) => anchor.name === output) |
| 460 | if (node) outputId = (node as ICommonObject).id |
| 461 | } else { |
| 462 | outputId = (reactFlowNode.data.outputAnchors[0] as ICommonObject).id |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | const targetNodeId = reactFlowEdges.find((edge) => edge.sourceHandle === outputId)?.target |
| 467 | |
| 468 | if (targetNodeId) { |
| 469 | const targetNodeCategory = reactFlowNodes.find((nd) => nd.id === targetNodeId)?.data.category || '' |
| 470 | const targetNodeName = reactFlowNodes.find((nd) => nd.id === targetNodeId)?.data.name || '' |
| 471 | if (targetNodeCategory === 'Vector Stores' && targetNodeName !== 'memoryVectorStore') { |
| 472 | return true |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | return false |
| 477 | } |
| 478 | |
| 479 | type BuildFlowParams = { |
| 480 | startingNodeIds: string[] |