การใช้งาน DeepSeek ใน Python
James Chapman
AI Curriculum Lead, DataCamp
![]()
![]()
รถไฟวิ่ง 60 ไมล์ ใน 1.5 ชั่วโมง หากวิ่งด้วยความเร็วเท่าเดิม จะวิ่งได้ไกลแค่ไหน ใน 4 ชั่วโมง และจะถึงจุดหมายเมื่อใดหากออกเดินทางเวลา 2:15 PM?

รถไฟวิ่ง 60 ไมล์ ใน 1.5 ชั่วโมง หากวิ่งด้วยความเร็วเท่าเดิม จะวิ่งได้ไกลแค่ไหน ใน 4 ชั่วโมง และจะถึงจุดหมายเมื่อใดหากออกเดินทางเวลา 2:15 PM?
คำนวณความเร็ว (60 ÷ 1.5 = 40 mph)
คูณด้วย 4 ชั่วโมงเพื่อ หาระยะทาง (40 × 4 = 160 ไมล์)
บวก 4 ชั่วโมงเข้ากับเวลาออกเดินทาง (2:15 PM + 4 ชั่วโมง = 6:15 PM)
คำตอบ: "160 ไมล์ ถึงเวลา 6:15 PM"

response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro",
messages=[{"role": "user", "content": train_problem}]
)
print(response.choices[0].message.content)
print(response.choices[0].message.content)
**Step 1 - Find the train's speed**
Speed = 60 / 1.5 = **40 mph**
**Step 2 - Distance in 4 hours**
Distance = 40 × 4 = **160 miles**
**Step 3 - Arrival time**
2:15 PM + 4 hours = **6:15 PM**
**Final Answer:** 160 miles, arriving at 6:15 PM
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro",
extra_body={"thinking": {"type": "disabled"}},
messages=[{"role": "user", "content": prompt}]
)
"enabled" ส่งค่า "disabled" เพื่อปิดใช้งานresponse = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro",
reasoning_effort="max",
messages=[{"role": "user", "content": train_problem}]
)
print(response.choices[0].message.content)
"high" → ตั้งเป็น "max" สำหรับโจทย์ที่ยากขึ้นการใช้งาน DeepSeek ใน Python