switch.mdx


Overview

The Switch component is a critical control element designed to evaluate specified conditions based on outputs from other components and direct the flow of execution accordingly. It enables complex branching logic within workflows or automation pipelines, allowing different paths of execution depending on rule-based evaluations.

Unlike decision-making components that rely on AI (e.g., the Categorize component which uses large language models for classification), the Switch component strictly uses deterministic, rule-based logic to evaluate conditions and determine the next steps in a process.


Detailed Description

Purpose

Key Concepts


Configurations and Usage

1. Cases

2. Conditions

Each condition includes:

3. Specifying Downstream Components


Important Notes


Example Usage

Suppose you have a workflow where you want to branch based on the result of a previous component called GetUserAge.

This setup uses multiple conditions combined with logical operators to route execution according to age brackets.


Interaction with Other System Components


Implementation Details


Mermaid Diagram: Class Structure of Switch Component

classDiagram
    class Switch {
        +cases: List~Case~
        +evaluate(): String
        +addCase(case: Case)
        +removeCase(caseId: String)
    }

    class Case {
        +id: String
        +conditions: List~Condition~
        +logicalOperator: String  "AND" or "OR"
        +evaluate(): Boolean
        +addCondition(condition: Condition)
        +removeCondition(conditionId: String)
    }

    class Condition {
        +componentOutput: String
        +operator: String
        +value: String | Number
        +evaluate(): Boolean
    }

    Switch "1" o-- "*" Case : contains
    Case "1" o-- "*" Condition : contains

Summary

The Switch component is a fundamental building block for rule-based branching in workflows. By defining multiple cases with one or more conditions connected via logical operators, it evaluates component outputs and directs execution flow accordingly. It is designed for deterministic, non-AI based decision-making, complementing other components that may use machine learning or AI. Its configuration and integration into the system enable complex, multi-path workflows with clear, maintainable logic rules.


End of Documentation for switch.mdx