MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / prepareConditionalEdges

Function prepareConditionalEdges

packages/server/src/utils/buildAgentGraph.ts:772–804  ·  view source on GitHub ↗
(nodeId: string, nodeInstance: ISeqAgentNode)

Source from the content-addressed store, hash-verified

770 * }
771 */
772 const prepareConditionalEdges = (nodeId: string, nodeInstance: ISeqAgentNode) => {
773 const conditionEdges = reactFlowEdges.filter((edge) => edge.target === nodeId && edge.source.includes('seqCondition')) ?? []
774
775 for (const conditionEdge of conditionEdges) {
776 const conditionNodeId = conditionEdge.source
777 const conditionNodeOutputAnchorId = conditionEdge.sourceHandle
778
779 const conditionNode = reactFlowNodes.find((node) => node.id === conditionNodeId)
780 const outputAnchors = conditionNode?.data.outputAnchors
781
782 if (!outputAnchors || !outputAnchors.length || !outputAnchors[0].options) continue
783
784 const conditionOutputAnchorLabel =
785 outputAnchors[0].options.find((option: any) => option.id === conditionNodeOutputAnchorId)?.label ?? ''
786
787 if (!conditionOutputAnchorLabel) continue
788
789 if (Object.prototype.hasOwnProperty.call(conditionalEdges, conditionNodeId)) {
790 conditionalEdges[conditionNodeId] = {
791 ...conditionalEdges[conditionNodeId],
792 nodes: {
793 ...conditionalEdges[conditionNodeId].nodes,
794 [conditionOutputAnchorLabel]: nodeInstance.name
795 }
796 }
797 } else {
798 conditionalEdges[conditionNodeId] = {
799 nodes: { [conditionOutputAnchorLabel]: nodeInstance.name },
800 func: conditionNode.data.instance.node
801 }
802 }
803 }
804 }
805
806 /*
807 * Prepare Conditional Tool Edges. This is just for LLMNode -> ToolNode

Callers 1

compileSeqAgentsGraphFunction · 0.85

Calls 1

callMethod · 0.45

Tested by

no test coverage detected