yera.dsl.control

Module containing Yera DSL constructs for control flow using LLMs.

Symbols

class Condition — Represents a boolean condition with instruction.
def condition — Use the active LLM to evaluate a boolean condition.
class Option — Represents a single option in a selection.
def option — Create an Option instance.
def select — Use the active LLM to choose between a set of options.

Condition

Inherits: Struct

Represents a boolean condition with instruction.

Attributes

condition
type: bool

Boolean indicating whether the condition holds.

condition

condition(
    instruction: str,
    on_wire: bool = False,
    **kwargs,
) → bool

Use the active LLM to evaluate a boolean condition.

Parameters

instruction
type: str

Instruction text describing what the condition checks.

on_wire
type: bool = False

Whether the field should be included in LLM context (default: False).

**kwargs
type: object

Additional keyword arguments passed to the model fill method.

Returns

type: bool

Boolean value representing whether the condition holds.

Option

Represents a single option in a selection.

Attributes

label
type: str

The label shown for the option.

description
type: str | None

Optional detailed description of the option.

option

option(
    label: str,
    description: str | None = None,
) → Option

Create an Option instance.

Parameters

label
type: str

The visible label for the option.

description
type: str | None = None

Optional descriptive text.

Returns

type: Option

An Option instance with given label and description.

select

select(
    *options,
    instruction: str | None = None,
    name: str = 'Selection',
    on_wire: bool = False,
    **kwargs,
) → str

Use the active LLM to choose between a set of options.

Parameters

*options
type: str | Option = ()

One or more option labels or Option instances.

instruction
type: str | None = None

Instruction text to describe the purpose of this selection.

name
type: str = 'Selection'

Name for the generated class (default: "Selection").

on_wire
type: bool = False

Whether the field should be included in the LLM context (default: False).

**kwargs
type: object

Additional keyword arguments passed to the model fill method.

Returns

type: str

The selected option

Raises

ValueError

If fewer than two options are provided or labels are not unique.