Skip to main content
Version: DEV

Iteration component

A component that splits text input into text segments and iterates a predefined workflow for each one.


An Interaction component can divide text input into text segments and apply its built-in component workflow to each segment.

Scenario

An Iteration component is essential when a workflow loop is required and the loop count is not fixed but depends on number of segments created from the output of specific agent components.

  • If, for instance, you plan to feed several paragraphs into an LLM for content generation, each with its own focus, and feeding them to the LLM all at once could create confusion or contradictions, then you can use an Iteration component, which encapsulates a Generate component, to repeat the content generation process for each paragraph.
  • Another example: If you wish to use the LLM to translate a lengthy paper into a target language without exceeding its token limit, consider using an Iteration component, which encapsulates a Generate component, to break the paper into smaller pieces and repeat the translation process for each one.

Internal components

IterationItem

Each Iteration component includes an internal IterationItem component. The IterationItem component serves as both the starting point and input node of the workflow within the Iteration component. It manages the loop of the workflow for all text segments created from the input.

NOTE

The IterationItem component is visible only to the components encapsulated by the current Iteration components.

Iterationitem

Build an internal workflow

You are allowed to pull other components into the Iteration component to build an internal workflow, and these "added internal components" are no longer visible to components outside of the current Iteration component.

IMPORTANT

To reference the created text segments from an added internal component, simply add a Reference variable that equals IterationItem within the Input section of that internal component. There is no need to reference the corresponding external component, as the IterationItem component manages the loop of the workflow for all created text segments.

NOTE

An added internal component can reference an external component when necessary.

Configurations

Input

The Iteration component uses input variables to specify its data inputs, namely the texts to be segmented. You are allowed to specify multiple input sources for the Iteration component. Click + Add variable in the Input section to include the desired input variables. There are two types of input variables: Reference and Text.

  • Reference: Uses a component's output or a user input as the data source. You are required to select from the dropdown menu:
    • A component ID under Component Output, or
    • A global variable under Begin input, which is defined in the Begin component.
  • Text: Uses fixed text as the query. You are required to enter static text.

Delimiter

The delimiter to use to split the text input into segments:

  • Comma (Default)
  • Line break
  • Tab
  • Underline
  • Forward slash
  • Dash
  • Semicolon

Examples

Explore our research report generator agent template, where the Iteration component (component ID: Sections) takes subtitles from the Subtitles component and generates sections for them:

  1. Click the Agent tab at the top center of the page to access the Agent page.
  2. Click + Create agent on the top right of the page to open the agent template page.
  3. On the agent template page, hover over the Customer service card and click Use this template.
  4. Name your new agent and click OK to enter the workflow editor.
  5. Click on the Iteration component to display its Configuration window.