เพิ่ม assistant messages อีกมากขึ้น!
ขยาย messages ที่มีอยู่เดิมเพื่อเพิ่มตัวอย่างเพิ่มเติม โดยเก็บไว้ในตัวแปร example1, response1, example2, response2, example3 และ response3
มาดูกันว่าโมเดลจะแสดงผลลัพธ์ในรูปแบบที่ต้องการได้หรือไม่!
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การใช้งาน DeepSeek ใน Python
คำแนะนำการฝึกหัด
- ขยาย messages เดิมให้ครอบคลุมตัวอย่างประเทศอื่น ๆ เพิ่มเติม โดยเก็บข้อมูลไว้ในตัวแปร
example1,response1,example2,response2,example3และresponse3
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
client = OpenAI(api_key="", base_url="https://api.together.xyz/v1")
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro",
# Add in the extra examples and responses
messages=[
{"role": "system", "content": "You are a helpful Geography tutor that generates concise, one-sentence summaries for different countries."},
{"role": "user", "content": "Give me a quick summary of Portugal."},
{"role": "assistant", "content": "Portugal is a country in Europe that borders Spain. The capital city is Lisboa."},
{"role": "user", "content": ____},
{"role": "assistant", "content": ____},
{"role": "user", "content": ____},
{"role": "assistant", "content": ____},
{"role": "user", "content": ____},
{"role": "assistant", "content": ____},
{"role": "user", "content": "Give me a quick summary of Greece."}
]
)
print(response.choices[0].message.content)