Examples

Hierarchical classification

Open in playground →
  • Enum
  • when

Task

Put a product in a department, then in a category inside that department.

Challenges

  • department chooses from 3 departments. Each department has its own field with its categories, and "when": {"department": ...} runs only the one that matches, so the other two are skipped.
  • A French press goes to home_kitchen, then coffee_tea. A backpacking tent, "Two-person backpacking tent, 4 lb, waterproof rainfly.", came back sports_outdoors and camping, and the other two departments were skipped.

Laying out…

Time 0.21 s · Cost $0.000011

Generation(
    result={
        'department': 'home_kitchen',
        'home_kitchen': 'coffee_tea',
    },
    thinking={},
    usage=Usage(input_tokens=218, thinking_tokens=0),
    skipped=[
        'electronics',
        'sports_outdoors',
    ],
)

Build it into a task: Hierarchical classification in one call, in the cookbook.