ลองส่ง prompt แรกให้ Claude!
เพื่อให้เห็นภาพว่าคอร์สนี้จะพาไปถึงจุดไหน โค้ด Python สำหรับส่งคำขอไปยัง Anthropic API ได้เตรียมไว้ให้แล้ว
ป้อนคำถามหรือคำสั่งใด ๆ ลงใน argument ชื่อ prompt แล้วดูว่า Claude ตอบสนองอย่างไร!
หากยังนึกไม่ออกว่าจะถามอะไร ลองใช้ตัวอย่างเหล่านี้ได้เลย:
- What capabilities make Claude well-suited for enterprise applications?
- Give me two examples of how I could use Claude in a Python app.
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Claude Models เบื้องต้น
คำแนะนำการฝึกหัด
- ป้อน prompt ของคุณ แทนที่
"INSERT YOUR PROMPT HERE"แล้วทดลองปรับแต่ง จากนั้นส่งคำตอบเมื่อพร้อม!
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
from anthropic import Anthropic
client = Anthropic(api_key="datacamp-token", base_url=url)
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=100,
# Enter your prompt
messages=[{"role": "user", "content": "INSERT YOUR PROMPT HERE"}]
)
print(response.content[0].text)