style(workflow): update condition edge comments for conditional nodes
This commit is contained in:
@@ -125,18 +125,20 @@ class WorkflowExecutor:
|
|||||||
node_instance = NodeFactory.create_node(node, self.workflow_config)
|
node_instance = NodeFactory.create_node(node, self.workflow_config)
|
||||||
|
|
||||||
if node_type in [NodeType.IF_ELSE]:
|
if node_type in [NodeType.IF_ELSE]:
|
||||||
# Build ordered boolean expression strings for each branch.
|
|
||||||
# These expressions will be attached to outgoing edges as
|
|
||||||
# LangGraph conditional routing rules.
|
|
||||||
expressions = node_instance.build_conditional_edge_expressions()
|
expressions = node_instance.build_conditional_edge_expressions()
|
||||||
|
|
||||||
# Collect all outgoing edges from the current node.
|
# Number of branches, usually matches the number of conditional expressions
|
||||||
# The order of edges must match the order of generated expressions.
|
branch_number = len(expressions)
|
||||||
|
|
||||||
|
# Find all edges whose source is the current node
|
||||||
related_edge = [edge for edge in self.edges if edge.get("source") == node_id]
|
related_edge = [edge for edge in self.edges if edge.get("source") == node_id]
|
||||||
|
|
||||||
# Attach each condition expression to the corresponding edge
|
# Iterate over each branch
|
||||||
# based on branch priority
|
for idx in range(branch_number):
|
||||||
for idx in range(len(expressions)):
|
# Generate a condition expression for each edge
|
||||||
|
# Used later to determine which branch to take based on the node's output
|
||||||
|
# Assumes node output `node.<node_id>.output` matches the edge's label
|
||||||
|
# For example, if node.123.output == 'CASE1', take the branch labeled 'CASE1'
|
||||||
related_edge[idx]['condition'] = f"node.{node_id}.output == '{related_edge[idx]['label']}'"
|
related_edge[idx]['condition'] = f"node.{node_id}.output == '{related_edge[idx]['label']}'"
|
||||||
|
|
||||||
if node_instance:
|
if node_instance:
|
||||||
|
|||||||
Reference in New Issue
Block a user