Control data flow within a runchat with conditional routing
Flow
default library to parametrically enable or disable parts of your Runchat and prevent them from updating. This is useful if you want your runchat to perform different actions under different conditions.
Switch
node enables or disables outputs based on the switchVal
. When the switch is On
, then the trueVal
output is enabled and all connected downstream nodes will update. When the switch is Off
, then the falseVal
output is enabled and all connected downstream nodes will update. Nodes downstream from the disabled output will not update.
Agent
Nodeswitch
should be on or off. There are several common approaches to this. One flexible approach is to use a prompt. The advantage of using prompts to control the switch is you can reason about subjective circumstances and still control your application flow. In your Agent
node, set the Output Format
to boolean
to ensure that the model only outputs True
or False
. Then frame your prompt as a question: “is this x?”.
Code
node to write a script to output a boolean value. This is typically the case for checking things like:
Router
node allows you to “route” a list of data to a list of output parameter names. You can think of this like a Switch
for lists. Use the Agent
or Code
node to generate a list of parameter names, one for each item in your data list. For instance you might call these “trueVal” and “falseVal” and then you would have very similar functionality to the switch. If you want to disable an output parameter entirely (like the switch node), pass it a null
value.