yera.dsl.control
Module containing Yera DSL constructs for control flow using LLMs.
Symbols
Condition
StructRepresents a boolean condition with instruction.
Fields
Whether the condition holds or not
condition
condition(
instruction: str,
on_wire: bool = False,
**kwargs,
) → boolUse the active LLM to evaluate a boolean condition.
Parameters
Instruction text describing what the condition checks.
Whether the field should be included in LLM context (default: False).
Additional keyword arguments passed to the model fill method.
Returns
Boolean value representing whether the condition holds.
Examples
Check a fact established in the conversation without retaining the generated decision:
import yera as yr
is_weekend_trip = yr.condition(
"Is the requested journey shorter than three days?",
on_wire=False,
temperature=0,
)
Option
Represents a single option in a selection.
Fields
The label shown for the option.
Optional detailed description of the option.
Methods
Option.__init__
__init__(
label: str,
description: str | None = None,
) → Noneoption
option(
label: str,
description: str | None = None,
) → OptionCreate an Option instance.
Parameters
The visible label for the option.
Optional descriptive text.
Returns
An Option instance with given label and description.
Examples
Describe possible destinations for a day trip:
import yera as yr
museum = yr.option(
"Museum",
"Spend the afternoon viewing art.",
)
park = yr.option(
"Park",
"Walk outdoors if the weather is fine.",
)
select
select(
*options,
instruction: str | None = None,
name: str = 'Selection',
on_wire: bool = False,
**kwargs,
) → strUse the active LLM to choose between a set of options.
Parameters
One or more option labels or Option instances.
Instruction text to describe the purpose of this selection.
Name for the generated class (default: "Selection").
Whether the field should be included in the LLM context (default: False).
Additional keyword arguments passed to the model fill method.
Returns
The selected option
Raises
If fewer than two options are provided or labels are not unique.
Examples
Ask the model to classify a message without retaining the decision in the conversation:
import yera as yr
route = yr.select(
yr.option("question", "The user wants information."),
yr.option("chat", "The user is making conversation."),
instruction="Classify the latest message.",
on_wire=False,
)