|
| 1 | +The `select` operation chooses between two values based on a simple string |
| 2 | +condition. It enables basic control flow within Gendo pipelines by selecting |
| 3 | +either a `trueValue` or a `falseValue` depending on whether the `condition` |
| 4 | +string exactly matches `"true"` (case-insensitive). This operation is |
| 5 | +compatible with local text-based models, which typically produce plain textual |
| 6 | +answers. |
| 7 | + |
| 8 | +The syntax of the `select` operation is as follows: |
| 9 | + |
| 10 | + select [destination] condition trueValue falseValue |
| 11 | + |
| 12 | +The `destination` identifier is optional. If omitted, the result is bound to |
| 13 | +the special slot `_`. The `condition` is required and must be a |
| 14 | +string—typically the result of a previous model call or logic step. If |
| 15 | +`condition` equals `"true"` (case-insensitive), the `trueValue` is chosen. |
| 16 | +Otherwise, the `falseValue` is chosen. The selected value is then stored in |
| 17 | +`destination` or in `_` if no destination is provided. |
| 18 | + |
| 19 | +An example with an explicit destination: |
| 20 | + |
| 21 | + select outcome "true" "Proceed" "Abort" |
| 22 | + |
| 23 | +In this example, the string `"Proceed"` is assigned to `outcome` because the |
| 24 | +condition matches `"true"`. |
| 25 | + |
| 26 | +Another example using a prior model result as the condition: |
| 27 | + |
| 28 | + prompt isValid "Is the previous input acceptable? Reply 'true' or 'false'." |
| 29 | + select validationMessage isValid "Input is acceptable." "Input is not acceptable." |
| 30 | + |
| 31 | +Here, the pipeline sends a prompt to the model. The response, assumed to be |
| 32 | +`"true"` or `"false"`, is stored in `isValid`. The `select` instruction then |
| 33 | +chooses an appropriate message and binds it to `validationMessage`. |
| 34 | + |
| 35 | +The `select` operation requires all arguments to be present and in order. It |
| 36 | +performs no transformation beyond the selection logic, and it produces exactly |
| 37 | +one value. All bindings follow the single-assignment rule: once a name is used |
| 38 | +as a destination, it cannot be reassigned later in the same pipeline. |
0 commit comments