Introduzione ai modelli Claude
Nikhil Rangarajan
Data Scientist


system_msg = "Be helpful." # Debolesystem_msg = "You are a technical writer. Use active voice, under 100 words, actionable advice only." # Fortemessages = [{"role": "user", "content": "How do I improve documentation?"}] response = client.messages.create(model="claude-sonnet-4-6", max_tokens=150, system=system_msg, messages=messages)
$$
$$
$$
# Basati sul ruolo
"You are a customer service rep."
# Basati su vincoli
"Respond in exactly 3 bullet points,
max 50 words."
# Basati sul tono
"Use enthusiastic, encouraging tone."
# Specifici per il compito
"Debug Python code. Always ask for
error messages first."
# Messaggio di sistema problematico
"Be concise and helpful."
# Problema: risposte troppo brevi,
# manca contesto
"Provide helpful responses in 2-3
sentences. Include relevant context
but avoid unnecessary details."
# Test con vari prompt
$$
system_msg = """Code reviewer.
Priority: 1) Security 2) Performance
3) Style
If no issues: "Code looks good"
+ suggest improvement
Example: "Security: No issues.
Performance: Consider caching here."
"""
messages = [{"role": "system",
"content": system_msg},
{"role": "user",
"content": "Review: [code]"}]
Introduzione ai modelli Claude