Testing and refining system messages
At Redwood Consulting, the marketing team is promoting the annual Tech Forecast whitepaper on LinkedIn. Posts need to feel conversational yet professional, but your first iteration produced bland, hashtag-free posts. You’ll have to write an improved system message that delivers lively, on-brand content every time.
The anthropic library, client, content_request, and current_system strings are pre-loaded.
Este ejercicio forma parte del curso
Introduction to Claude Models
Instrucciones del ejercicio
- Set the
rolefor the user's content request. - Write an
improved_systemmessage that addresses social media requirements, including to use emojis. - Apply the
improved_systemmessage to the final test.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# Test current system message
test_response = client.messages.create(
model="claude-3-7-sonnet-latest", max_tokens=75, system=current_system,
messages=[{"role": ____, "content": content_request}])
print("Current output:", test_response.content[0].text)
# Create improved system message based on problems identified
improved_system = ____
final_response = client.messages.create(
# Apply the improved system message
model="claude-3-7-sonnet-latest", max_tokens=75, system=____,
messages=[{"role": "user", "content": content_request}])
print("\nImproved output:", final_response.content[0].text)