Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Objectives: LO-3.1, LO-3.2, LO-3.3
Prerequisites: the Module 3 reading and Lab 2
Time: about 2.5 hours

In this lab you rewrite three vague prompts for the bicycle repair shop and score them with the prompt rubric. Then you move the shop’s routing policy into a request’s system prompt, write a checker for the routing format, and run it over 30 responses.

The tickets come from data/tickets.json. A person wrote the 30 responses in data/format-responses.json for this course, so they are illustrative, not model output. No cell sends anything over the network or calls a model.

Use a fresh kernel and run the cells from top to bottom. Fill each answer cell, then run its check, which prints passed or fails with a message that says what is wrong. The checks fail on purpose until their exercises are complete.

Setup

Score a first draft

Use the prompt rubric, which scores five criteria from 0 to 2. “Sort this” earns 1 for task and 0 for the other criteria. Read the three tickets below, and decide which text in each prompt is stable policy and which is the request itself.

Exercise L3.1 (LO-3.1, ★★, about 25 minutes)

Rewrite three prompts. Replace “Sort this,” “Help them,” and “Extract the info” with complete prompts for routing T01, answering T14, and extracting the requested profile change in T19. Return a list of three strings in that order. Score the drafts and revisions out of 10 on paper, with evidence for each score.

Exercise L3.2 (LO-3.2, ★★, about 25 minutes)

Move policy out of the ticket. Write route_request(ticket), which returns a request dictionary in the Messages API’s shape (Module 2) with the keys model, max_tokens, system, and messages. Use a single user turn containing the ticket exactly. The system prompt must name all three queues and specify the output. Leave room in max_tokens for thinking, as Module 2 explains. Explain the separation in your notes.

Exercise L3.3 (LO-3.3, ★★, about 25 minutes)

Parse the output contract. Write parse_label(text). Return the queue from a string that is exactly Label: repair, Label: billing, or Label: account. Return None for all other strings. Match the whole string, so that even a trailing newline is rejected.

Exercise L3.4 (LO-3.3, ★★, about 25 minutes)

Audit 30 responses. Write audit(rows), which returns a dictionary with the counts "valid" and "invalid". Call parse_label once per row. Explain in your notes why the resulting percentage describes the sample’s formatting alone.

Summary

You wrote task-specific instructions, split stable policy from per-request data, and checked a hand-written set of responses for format. A format count says nothing about whether each label was right; that needs reference labels, which Module 7 grades.