Chapter 5intermediate
Formatting Output & Speaking for Claude
Claude can format its output in a wide variety of ways. You just need to ask for it to do so!
One of these ways is by using XML tags to separate out the response from any other superfluous text. You've already learned that you can use XML tags to make your prompt clearer and more parseable to Claude. It turns out, you can also ask Claude to use XML tags to make its output clearer and more easily understandable to humans.
Examples
Prompt Template
Please write a haiku about {{ANIMAL}}. Put it in <haiku> tags.
Variables
Substituted Prompt
Please write a haiku about Rabbit. Put it in <haiku> tags.
Response
Response will be generated by the LLMPrompt Template
Please write a haiku about {{ANIMAL}}. Put it in <haiku> tags.
Assistant Prefill
<haiku>
Variables
Substituted Prompt
Please write a haiku about Cat. Put it in <haiku> tags.
Response
Response will be generated by the LLMPrompt Template
Please write a haiku about {{ANIMAL}}. Use JSON format with the keys as "first_line", "second_line", and "third_line".
Assistant Prefill
{Variables
Substituted Prompt
Please write a haiku about Cat. Use JSON format with the keys as "first_line", "second_line", and "third_line".Response
Response will be generated by the LLMPrompt Template
Hey Claude. Here is an email: <email>{{EMAIL}}</email>. Make this email more {{ADJECTIVE}}. Write the new version in <{{ADJECTIVE}}_email> XML tags.
Assistant Prefill
<{{ADJECTIVE}}_email>Variables
Substituted Prompt
Hey Claude. Here is an email: <email>Hi Zack, just pinging you for a quick update on that prompt you were supposed to write.</email>. Make this email more {{ADJECTIVE}}. Write the new version in <{{ADJECTIVE}}_email> XML tags.
Response
Response will be generated by the LLMPlayground
EditableTry modifying these prompts and sending them to your configured LLM provider.
Try it yourself
{{ANIMAL}}=Rabbit
Try it yourself
{{ANIMAL}}=Cat
Try it yourself
{{ANIMAL}}=Cat
Try it yourself
{{EMAIL}}=Hi Zack, just pinging you for a quick update on that prompt you were supposed to write.