Reference
If

Use If (opens in a new tab) to return one of two options based on a condition. This example summarizes using bullets if the input is longer than 800 characters.

Python
TypeScript

from substrate import Substrate, ComputeText, If, sb
idea = ComputeText(prompt="Give me a unique startup idea")
bullets = ComputeText(
prompt=sb.concat("Summarize in bullets: ", idea.future.text),
)
full = ComputeText(
prompt=sb.concat("Summarize: ", idea.future.text),
)
summary = If(
condition=sb.jq(idea.future.text, "length > 800"),
value_if_true=bullets.future.text,
value_if_false=full.future.text,
)

Similar to an if else statement, the second option is not required. If only one option is provided and the condition is not met, If returns a null result.