Descripción del componente
Cómo funciona el componente Iterador
The Iterator component is designed to execute a sub-flow or an external flow repeatedly for each item in a given list. This enables batch processing, looping, or parallel execution of AI tasks over multiple inputs, which is essential when handling workflows that involve lists or collections of data.
What the Component Does
The Iterator automates repetitive execution within your AI workflow. It takes a list of inputs, and for each item in this list, it runs a specified AI flow (which could be any process or model you have defined). This is particularly useful for scenarios like:
- Processing multiple documents, images, or messages in sequence
- Applying the same transformation or analysis to a batch of data
- Collecting or aggregating results from repeated executions
The component exposes the following configurable fields:
Field Name | Type | Required | Description |
---|
Flow Execution (flow ) | FlowExecution | Yes | The sub-flow or external flow to execute for each item in the input list. |
Input List (flow_inputs ) | Data, Message | Yes | The list of inputs to loop over (each item will trigger a flow execution). |
Include Previous Iteration Output (include_prev_output ) | Bool (Advanced) | No | Passes the previous iteration’s output as {prev_iter_res} to the next iteration. Only works with single-threaded (concurrency = 1) execution. |
Max Concurrency (max_concurrency ) | Int (1-20, Advanced) | No | Sets the maximum number of flow executions to run in parallel. Default is 1 (sequential). |
Separator (separator ) | String (Advanced) | No | Optional separator string to use between each flow execution’s output. |
Outputs
The main output of the Iterator is:
- Message (
text_output
): A message containing the aggregated results of running the flow on each input item. The output type is consistent with the output of the executed flow.
How It Works
- You provide a list of items (e.g., messages, data entries).
- You choose or define a flow to execute for each item.
- The Iterator executes the flow for each list item, either sequentially or in parallel (as set by Max Concurrency).
- It collects the outputs and returns them as a single Message output, optionally separated by a custom string.
If Include Previous Iteration Output is enabled (and concurrency is set to 1), each iteration can access the result of the preceding iteration, enabling chained or stateful processing.
Why Use the Iterator Component?
- Scalability: Efficiently process large batches of inputs without manual looping.
- Parallelism: Speed up workflows by running executions concurrently.
- Reusability: Apply the same sub-flow logic to any list of data.
- Flexibility: Customize iteration behavior with advanced options like output chaining and output formatting.
Example Use Cases
- Applying sentiment analysis to a list of user comments.
- Running document summarization on a batch of uploaded files.
- Translating a collection of messages using a translation flow.
Summary Table
Purpose | Inputs | Outputs | Advanced Options |
---|
Batch execution of flows | List of items, Flow to execute | Aggregated Message | Output chaining, concurrency, separator |
The Iterator is a powerful tool for automating repetitive tasks in AI workflows, making it an essential building block for scalable and maintainable process automation.