Step 1: Split one prompt into facts and a draft
Brightline Books sends a weekly newsletter with a short blurb for each new title. The blurbs come from
a shop record and three customer reviews, and last month one blurb called a debut novel "award-winning".
It had never won anything. You will build the workflow that writes the blurbs, one step at a time, in
workflow.yaml. There is no code to write.
Click Run first. The current workflow is one step: a large model reads everything and writes the blurb. Look at the scorecard. Every blurb is too long, most shout with exclamation marks, and the fact check finds praise that no reader gave.
One prompt doing everything is hard to check, because you cannot see what the model believed before it started writing. Split the job so that one step decides the facts and another step writes from them.
Do this in workflow.yaml:
- Replace the
blurbstep with a step calledfacts:model: small,output: json. Its prompt uses{record}and{reviews}and asks for JSON only, with keys you name, for exampletitle,author,genre,price,premiseandreader_views. Tell it to copy facts and add none. - Add a step called
draftafter it:output: text. Its prompt asks for a newsletter blurb and includes{facts}, and not{record}or{reviews}. A writer that sees only the checked facts cannot copy anything else. - Click Run, then run
python3 run_workflow.py --book 6in the terminal to watch one book go through both steps.
The check runs your workflow on the 8 practice books. The facts step must return JSON on at least 7, and at least 6 blurbs must name the title and the author. The length and hype rules come in the next step.
workflow.yaml, the file you edit22 lines
# workflow.yaml: how the newsletter blurb for one book gets written.
# Each step sends one prompt to a model and saves the reply under the step's name.
# {record} and {reviews} the book's shop record and three customer reviews
# {facts} the whole output of an earlier step called facts
# {review.ok} one field of an earlier step's JSON output
# model: small Llama 3.1 8B, cheap model: large Llama 3.3 70B, about 6x the price
# when: review.ok == false run the step only when that field has that value
# The blurb is the output of the last text step that ran.
steps:
# TODO (Step 1): split this one step into two: facts (small model, JSON) and draft (text,
# written from {facts} only). Delete this step when you have both.
- name: blurb
model: large
output: text
prompt: |
Write a newsletter blurb for our bookshop about this book, using the record and the reviews.
Record:
{record}
Reviews:
{reviews}books.jsonlreview_tests.jsonlrun_workflow.pyworkflow.py