yera.dsl.functions
Prompting, input, output, layout, and lifecycle functions.
The building blocks an app function uses to interact with the LLM, present output, and collect input from the user.
Prompting
chat: send a prompt and get a text responsesys_prompt: append a line to the active system prompt
Input widgets
text_input: free-form textbuttons: pick one of a set of optionsdate_picker: pick a dateslider: pick a number in a range
Output blocks
markdown: render markdown contenttable: render tabular dataaction: mark a unit of work in progressspinner: show a spinner while work runs
Layout
columns: lay blocks out in side-by-side columnscontainer: group blocks into a single visual unitform: group input blocks and submit them together
Lifecycle
Symbols
action
action(
message: str,
) → ActionStreamMark a unit of app work in progress.
Use as a context manager: the action is shown as active while the
block runs and marked complete on exit. The update method on
the returned stream can change the message mid-flight.
Parameters
Initial description of the work in progress.
Returns
An ActionStream context manager.
bar_chart
bar_chart(
data: object,
x: str | None = None,
y: str | Sequence[str] | None = None,
colour: str | Sequence[str] | None = None,
horizontal: bool = False,
stack: bool = True,
) → NoneRender a bar chart.
Parameters
Chart data; typically a pandas DataFrame.
Column name to use for the x-axis.
Column name (or names) to plot on the y-axis.
Column name (or names) used to colour the bars.
Orient bars horizontally rather than vertically.
Stack multiple series rather than grouping side-by-side.
buttons
buttons(
options: list[str],
label: str | None = None,
) → strPresent the user with a set of buttons and return their selection.
Parameters
Labels for the buttons to display.
Optional prompt shown above the buttons.
Returns
The label of the button the user clicked.
chat
chat(
stop_str: str = '/quit',
) → Generator[str]Yield user prompts until one starts with stop_str.
Repeatedly prompts the user for text input, yielding each prompt.
When the user submits a prompt starting with stop_str, the run
quits and iteration stops.
Parameters
Prefix that, when matched, ends the chat loop. Default = "/quit"
columns
columns(
n: int,
border: bool = False,
) → LayoutHandleLay child blocks out in n side-by-side columns.
Use as a context manager. Blocks emitted inside the with body
are distributed across the columns in order.
Parameters
Number of columns.
Whether to draw a border around the layout.
Returns
A LayoutHandle context manager.
container
container(
border: bool = False,
) → LayoutHandleGroup child blocks into a single container.
Use as a context manager. Blocks emitted inside the with body
are grouped together as a visual unit.
Parameters
Whether to draw a border around the container.
Returns
A LayoutHandle context manager.
date_picker
date_picker(
label: str,
default_date: date | str | None = None,
) → datePresent the user with a date picker.
Parameters
Prompt shown alongside the picker.
Optional initial date, as a date or ISO-format
string.
Returns
The date the user chose.
exit
exit(
exit_code: int,
reason: str,
return_value: object,
error_cause: ErrorCause | None = None,
) → NoneEnd the current app run.
Parameters
Process-style exit code; 0 for success, non-zero
for failure.
Human-readable summary of why the run ended.
Value to return to the caller, or None.
Optional structured cause metadata for failure exits.
See ErrorCause.
form
form(
border: bool = False,
) → LayoutHandleGroup input blocks into a form, submitted together.
Use as a context manager. Input blocks (text_input, buttons,
date_picker, slider) emitted inside the with body are
presented together and submitted as a single batch when the user
completes the form.
Parameters
Whether to draw a border around the form.
Returns
A LayoutHandle context manager.
line_chart
line_chart(
data: object,
x: str | None = None,
y: str | Sequence[str] | None = None,
colour: str | Sequence[str] | None = None,
) → NoneRender a line chart.
Parameters
Chart data; typically a pandas DataFrame.
Column name to use for the x-axis.
Column name (or names) to plot on the y-axis.
Column name (or names) used to colour the lines.
markdown
markdown(
content: str | None = None,
) → MarkdownStreamRender a markdown block.
Can be called directly to emit a single block, or used as a stream handle to append further chunks over time.
Parameters
If provided, immediately emits this markdown content.
Returns
A MarkdownStream handle whose append and new_line methods add further chunks to the same block.
quit
quit() → NoneEnd the current app run as a user-initiated quit.
Distinct from exit: signals that the
user chose to stop rather than the app completing or failing.
response
response(
prompt: str,
**kwargs,
) → strSend a prompt to the active LLM and return its text response.
Tokens will simultaneously be pushed onto the event stream for display in your UI or printed to stdout.
Parameters
The user-message prompt to send.
Additional options forwarded to the underlying LLM (e.g. provider-specific generation parameters).
Returns
The LLM's text response.
slider
slider(
min_value: float,
max_value: float,
label: str,
default_value: float | None = None,
) → floatPresent the user with a slider over a numeric range.
Parameters
Lower bound of the slider.
Upper bound of the slider.
Prompt shown alongside the slider.
Optional initial position. Defaults to
min_value if not provided.
Returns
The value the user selected.
spinner
spinner(
message: str,
) → SpinnerStreamShow a spinner with a message while a block of work runs.
Use as a context manager: the spinner shows while the block runs
and is removed on exit. The update method on the returned stream
can change the message mid-flight.
Parameters
Initial message shown alongside the spinner.
Returns
A SpinnerStream context manager.
sys_prompt
sys_prompt(
prompt: str,
) → NoneAppend a line to the active LLM context's system prompt.
Parameters
Text to add to the system prompt for subsequent
chat and struct calls in the current LLM context.
table
table(
data: object = None,
border: bool | Literal['horizontal'] = True,
) → TableStreamRender a table.
Parameters
Table data. Accepts pandas DataFrames, dicts of column
lists, lists of dicts, lists of lists, or any iterable that
can be converted to rows. Pass None for an empty table.
True for full borders, False for none, or
"horizontal" for horizontal lines only.
Returns
A TableStream handle whose add_rows method appends rows to the same table.
text_input
text_input(
message: str | None = None,
) → strPrompt the user for free-form text input.
Parameters
Optional label shown alongside the input field.
Returns
The text the user submitted.