(connection, reactFlowInstance)
| 424 | } |
| 425 | |
| 426 | export 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 | |
| 463 | export const isValidConnectionAgentflowV2 = (connection, reactFlowInstance) => { |
| 464 | const source = connection.source |
no outgoing calls
no test coverage detected