mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 18:08:07 +08:00
feat: add flatten_output configuration to iteration node (#27502)
This commit is contained in:
@ -23,6 +23,7 @@ class IterationNodeData(BaseIterationNodeData):
|
||||
is_parallel: bool = False # open the parallel mode or not
|
||||
parallel_nums: int = 10 # the numbers of parallel
|
||||
error_handle_mode: ErrorHandleMode = ErrorHandleMode.TERMINATED # how to handle the error
|
||||
flatten_output: bool = True # whether to flatten the output array if all elements are lists
|
||||
|
||||
|
||||
class IterationStartNodeData(BaseNodeData):
|
||||
|
||||
@ -98,6 +98,7 @@ class IterationNode(LLMUsageTrackingMixin, Node):
|
||||
"is_parallel": False,
|
||||
"parallel_nums": 10,
|
||||
"error_handle_mode": ErrorHandleMode.TERMINATED,
|
||||
"flatten_output": True,
|
||||
},
|
||||
}
|
||||
|
||||
@ -411,7 +412,14 @@ class IterationNode(LLMUsageTrackingMixin, Node):
|
||||
"""
|
||||
Flatten the outputs list if all elements are lists.
|
||||
This maintains backward compatibility with version 1.8.1 behavior.
|
||||
|
||||
If flatten_output is False, returns outputs as-is (nested structure).
|
||||
If flatten_output is True (default), flattens the list if all elements are lists.
|
||||
"""
|
||||
# If flatten_output is disabled, return outputs as-is
|
||||
if not self._node_data.flatten_output:
|
||||
return outputs
|
||||
|
||||
if not outputs:
|
||||
return outputs
|
||||
|
||||
|
||||
Reference in New Issue
Block a user