The Smallest Rewrite That Works
one hardcoded tone
Part of: Tone Rewriter
Now the smallest end-to-end thing: one tone, hardcoded, that returns rewritten text. Get one path working before you make it flexible. Call, then read the reply You've built the request. Sending it returns a response object, and the rewritten text sits one level down inside it. With the Anthropic SDK the text lives at resp.content[0].text: The .strip() matters more than it looks. Models often pad replies with a leading space or a trailing newline. If you're going to display or store the result, trim it now so those stray characters don't pile up. The reply is not always clean One reality shapes the rest of this project: the model doesn't always return only the rewrite. Sometimes it wraps the text in a preamble like "Here is the rewritten text:" or drops quotes around it. Your parsing step has to reach past that and grab the actual rewrite. A hardcoded first version can trust a clean reply, and you'll harden this properly in lesson 7. Why start this small One tone, one function, one clean return. That's a checkpoint you can run and believe. Every later feature (more tones, presets, validation) hangs off this working core. If you can't rewrite into one tone reliably, adding five tone
Challenge: Unwrap the Model's Reply