Skip to main content
Logic components provide functionalities for routing, conditional processing, and flow management.

Use a logic component in a flow

This flow creates a summarizing “for each” loop with the Loop component. The component iterates over a list of Data objects until it’s completed, and then the Done loop aggregates the results. The File component loads text files from your local machine, and then the Parser component parses them into a list of structured Data objects. The Loop component passes each Data object to a Prompt to be summarized. When the Loop component runs out of Data, the Done loop activates, which counts the number of pages and summarizes their tone with another Prompt. This is represented in LLM Controls by connecting the Parser component’s Data List output to the Loop component’s Data loop input. Loop 1 Pn

Conditional router (If-Else component)

This component routes messages by comparing two strings. It evaluates a condition by comparing two text inputs using the specified operator and routes the message to true_result or false_result. The operator looks for single strings based on your defined operator behavior, but it can also search for multiple words by regex matching. To use the Conditional router component to check incoming messages with regex matching, do the following:
  1. Connect the If-Else component’s Text Input port to a Chat Input component.
  2. In the If-Else component, enter the following values.
  • In the Match Text field, enter .*(urgent|warning|caution).*. The component looks for these values. The regex match is case sensitive, so to look for all permutations of warning, enter warning|Warning|WARNING.
  • In the Operator field, enter regex. The component looks for the strings urgent, warning, and caution. For more operators, see Operator behavior.
  • In the Message field, enter New Message Detected. This field is optional. The message is sent to both the True and False ports. The component is now set up to send a New Message Detected message out of its True port if it matches any of the strings. If no strings are detected, it sends a message out of the False port.
  1. Create two identical flows to process the messages. Connect an Open AI component, a Prompt, and a Chat Output component together.
  2. Connect one chain to the If-Else component’s True port, and one chain to the False port.
The flow looks like this: Logic Components Ifelse Pn
  1. Add your OpenAI API key to both OpenAI components.
  2. In both Prompt components, enter the behavior you want each route to take.
  3. Open the Playground.
  4. Send the flow some messages. Your messages route differently based on the if-else component’s evaluation.
InputsOutputs

Operator Behavior

The If-else component includes a comparison operator to compare the values in input_text and match_text. All options respect the case_sensitive setting except regex.
  • Equals: Exact match comparison.
  • Not equals: Inverse of exact match.
  • contains: Checks if match_text is found within input_text.
  • starts with: Checks if input_text begins with match_text.
  • Ends with: Checks if input_text ends with match_text.
  • Regex: Performs regular expression matching. It is always case sensitive and ignores the case_sensitive setting.

Listen

This component listens for a notification and retrieves its associated state.
InputsOutputs

Loop

tipFor another Loop component example, see the Research Translation Loop template.
This component iterates over a list of Data objects, outputting one item at a time and aggregating results from loop inputs. In this example, the Loop component iterates over a CSV file through the Item port until there are no rows left to process. Then, the Loop component performs the actions connected to the Done port, which in this case is loading the structured data into Chroma DB. Think of it this way: the Item port forms the “main” loop that repeats until a “complete” condition is reached.
  1. The Loop component accepts Data from the Load CSV component and outputs the data from the Item port.
  2. Each CSV row is converted to a Message and processed into structured data with the StructureOpenAId Output component. The dotted line connected from the Structured Output component’s Looping port tells you where the loop begins again.
  3. The Loop component repeatedly extracts rows by Text Key until there are no more rows to extract.
Once all items are processed, the action connected to the Done port is performed. In this example, the data is loaded into Chroma DB. Logic Component Loop Pn
InputsOutputs

Notify

This component generates a notification for the Listen component to use.
InputsOutputs

Pass

This component forwards the input message, unchanged.
InputsOutputs

Run flow

This component allows you to run any flow stored in your LLM Controls database without opening the flow editor. The Run Flow component can also be used as a tool when connected to an Agent. The name and description metadata that the Agent uses to register the tool are created automatically. When you select a flow, the component fetches the flow’s graph structure and uses it to generate the inputs and outputs for the Run Flow component. To use the Run Flow component as a tool, do the following:
  1. Add the Run Flow component to the Simple Agent flow.
  2. In the Flow Name menu, select the sub-flow you want to run. The appearance of the Run Flow component changes to reflect the inputs and outputs of the selected flow.
  3. On the Run Flow component, enable Tool Mode.
  4. Connect the Run Flow component to the Toolset input of the Agent. Your flow should now look like this: Simple Agent(1) Pn
  5. Run the flow. The Agent uses the Run Flow component as a tool to run the selected sub-flow.
InputsOutputs