協作式問題解決
新的製造工作坊即將上線,Aurora 的報名網站每次載入頁面都變慢到 8–10 秒,這讓潛在參與者卻步。你決定再與 Claude 進行一段多輪對話:先回報速度變慢的情況,接著補充更多細節,讓 Claude 能找出瓶頸所在。
anthropic 函式庫與 client 已預先載入。
本練習屬於課程
Claude 模型入門
練習說明
- 回報最初的問題:
"My website loads slowly, taking 8-10 seconds"。 - 提供更多診斷細節:
"The slowdown happens only on the homepage with the image gallery"。 - 在第二次 API 呼叫中加入 messages 參數。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
messages = []
# Add initial problem report
messages.append({"role": "user", "content": ____})
response1 = client.messages.create(model="claude-sonnet-4-6", max_tokens=150, messages=messages)
# Simulate Claude asking follow-up questions, then provide more details
messages.append({"role": "assistant", "content": response1.content[0].text})
messages.append({"role": "user", "content": ____})
# Get final troubleshooting advice
response2 = client.messages.create(model="claude-sonnet-4-6", max_tokens=200, ____)