LLM Engineering · Exercise 1 of 6Next
Beginner
Build a JSON Schema from a field list
Write build_schema(fields). fields is a list of (name, kind, required) tuples. kind is either a type name such as "string" or "integer", or a list of allowed strings, which becomes {"type": "string", "enum": [...]}.
Return a dictionary with the keys type ("object"), properties, required (the names of required fields, in order) and additionalProperties (False).
What Check tests
- Plain types and the required list
- A list of values becomes an enum of strings
- No required fields gives an empty list
- Extra keys are forbidden
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.