yr.app
app(
fn: Callable | None = None,
name: str | None = None,
description: str | None = None,
llm: LLMContext | None = None,
sys_prompt: str | None = None,
) → AppFunctionWrapper | Callable[[Callable], AppFunctionWrapper]Decorator that turns a Python function into a Yera app.
Usable bare (@app) or with keyword arguments
(@app(name=..., llm=..., sys_prompt=...)). The wrapped
function's signature is validated against Yera's supported type system
at decoration time; arguments and return values are coerced at call
time.
Parameters
The function being decorated when used bare. Left as None
when the decorator is invoked with arguments.
Display name for the app. Defaults to the function's
__name__.
Optional human-readable description recorded in the app metadata.
Optional LLMContext
entered for the duration of each run. Falls back to the active
profile's default llm if omitted.
Optional system prompt emitted once the llm context is entered.
Returns
An AppFunctionWrapper callable that runs the function under the Yera event-stream runtime when invoked. When called with arguments (fn is None), returns a decorator that produces the wrapper.
Examples
Use the bare decorator when the function name is sufficient:
import yera as yr
@yr.app
def greeting(name: str) -> str:
return f"Hello, {name}!"
Configure presentation and model behavior when the app needs more control:
import yera as yr
@yr.app(
name="Capital guide",
description="Answer questions about national capitals.",
llm=yr.llm["openai.gpt-4o"](),
sys_prompt="Answer clearly and include one interesting fact.",
)
def capital_guide(country: str) -> str:
return yr.response(f"What is the capital of {country}?")