@thunc.function def urgency(ticket: str) -> int: """Rate how urgent this ticket is, from 1 (can wait) to 5 (blocked).""" ... urgency("I was charged twice!") # -> 4 # a checked int
The instructions the model follows.
The inputs, sent separately from the instructions as data.
What you get back, parsed and checked.
ThuncError.ensure=lambda n: 1 <= n <= 5, retried the same way.When the prompt comes from a variable, a config file or a loop, call thunc.call with it. You still get typed, checked results.
prompt = f"Translate into {lang}." text = thunc.call(prompt, {"note": note}) score = thunc.call( rubric, {"answer": answer}, returns=int, )
New in 0.2.1: optional durable execution, with recorded model turns, recoverable tool effects, reconnectable runs and explicit resolution of uncertain commands. Local calls keep their dependency-free runtime.
Durable mode requires a Temporal service, a worker and persistent workspace storage.
Install it with pip install "thunc[temporal]".