НачатьНачать бесплатно

Больше сообщений от ассистента!

Дополните предыдущие сообщения новыми примерами, сохранёнными в переменных example1, response1, example2, response2, example3 и response3.

Посмотрим, сможем ли мы настроить модель так, чтобы она выводила информацию в нужном формате!

Это упражнение является частью курса

Работа с DeepSeek на Python

Посмотреть курс

Инструкции к упражнению

  • Дополните предыдущие сообщения примерами для других стран, хранящимися в переменных 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)
Редактировать и запускать код