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

Function isValidConnection

packages/ui/src/utils/genericHelper.js:426–461  ·  view source on GitHub ↗
(connection, reactFlowInstance)

Source from the content-addressed store, hash-verified

424}
425
426export const isValidConnection = (connection, reactFlowInstance) => {
427 const sourceHandle = connection.sourceHandle
428 const targetHandle = connection.targetHandle
429 const target = connection.target
430
431 //sourceHandle: "llmChain_0-output-llmChain-BaseChain"
432 //targetHandle: "mrlkAgentLLM_0-input-model-BaseLanguageModel"
433
434 let sourceTypes = sourceHandle.split('-')[sourceHandle.split('-').length - 1].split('|')
435 sourceTypes = sourceTypes.map((s) => s.trim())
436 let targetTypes = targetHandle.split('-')[targetHandle.split('-').length - 1].split('|')
437 targetTypes = targetTypes.map((t) => t.trim())
438
439 if (targetTypes.some((t) => sourceTypes.includes(t))) {
440 let targetNode = reactFlowInstance.getNode(target)
441
442 if (!targetNode) {
443 if (!reactFlowInstance.getEdges().find((e) => e.targetHandle === targetHandle)) {
444 return true
445 }
446 } else {
447 const targetNodeInputAnchor =
448 targetNode.data.inputAnchors.find((ancr) => ancr.id === targetHandle) ||
449 targetNode.data.inputParams.find((ancr) => ancr.id === targetHandle)
450 if (
451 (targetNodeInputAnchor &&
452 !targetNodeInputAnchor?.list &&
453 !reactFlowInstance.getEdges().find((e) => e.targetHandle === targetHandle)) ||
454 targetNodeInputAnchor?.list
455 ) {
456 return true
457 }
458 }
459 }
460 return false
461}
462
463export const isValidConnectionAgentflowV2 = (connection, reactFlowInstance) => {
464 const source = connection.source

Callers 2

NodeInputHandlerFunction · 0.90
NodeOutputHandlerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected