Examples

Sort an email, then ask what that kind needs

Open in playground →
  • when
  • Enum
  • Typed numbers
  • Text

Task

Tell what kind of email this is, then ask only what that kind needs: the amount due for an invoice, the date for a meeting request, the role for a job application.

Challenges

  • kind is an enum of three. Each follow-up has a when on one of them, so exactly one runs: amount_due (a number) for an invoice, meeting_date (a string) for a meeting request, role (an enum) for a job application.
  • This email is an invoice, so amount_due comes back as the number 1240, and meeting_date and role are skipped: no requests are sent for them, and skipped lists them.
  • The tests run in code on the typed kind. The fields a when names are dependencies, so none of the follow-ups lists depends_on.

Laying out…

Time 0.24 s · Cost $0.0000097

Generation(
    result={
        'kind': 'invoice',
        'amount_due': 1240,
    },
    thinking={},
    usage=Usage(input_tokens=195, thinking_tokens=0),
    skipped=[
        'meeting_date',
        'role',
    ],
)