Thêm nhiều thông điệp của assistant!
Mở rộng các thông điệp trước đó của bạn để cung cấp thêm ví dụ, được lưu dưới dạng example1, response1, example2, response2, example3 và response3.
Hãy xem liệu chúng ta có thể khiến mô hình này xuất ra thông tin theo đúng định dạng mong muốn không!
Bài tập này là một phần của khóa học
Làm việc với DeepSeek bằng Python
Hướng dẫn bài tập
- Mở rộng các thông điệp trước đó để bao gồm thêm ví dụ về các quốc gia khác, được lưu dưới dạng
example1,response1,example2,response2,example3vàresponse3.
Bài tập tương tác thực hành trực tiếp
Hãy thử làm bài tập này bằng cách hoàn thành đoạn mã mẫu này.
client = OpenAI(api_key="", base_url="https://api.together.xyz/v1")
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V3",
# 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)