การใช้งาน System Messages
Chat mode รองรับบทบาทข้อความ 3 ประเภท:
- System: กำหนด พฤติกรรม ของ assistant
- User: สั่งงาน assistant
- Assistant: ตอบกลับ คำสั่งของ user
ในแบบฝึกหัดนี้ จะเริ่มออกแบบระบบ AI สำหรับช่วยให้ผู้คนเรียนรู้ทักษะใหม่ โดยใช้ system message เพื่อกำหนดพฤติกรรมของโมเดลให้เหมาะสม
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การใช้งาน DeepSeek ใน Python
คำแนะนำการฝึกหัด
- สร้างคำขอโดยใช้ทั้งข้อความแบบ system และ user เพื่อสร้างแผนการเรียนภาษาดัตช์
- ดึงข้อความตอบกลับของ assistant แล้วแสดงผล
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
client = OpenAI(api_key="", base_url="https://api.together.xyz/v1")
# Create a request to the chat model
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro",
max_tokens=500,
messages=[
{"role": ____,
"content": "You are a study planning assistant that creates plans for learning new skills. Only return the structured plan."},
{"____": "____",
"____": "I want to learn to speak Dutch."}
]
)
# Extract the assistant's text response
print(response.choices[0].____.____)