Больше сообщений от ассистента!
Расширьте предыдущие сообщения, добавив дополнительные примеры, сохранённые в переменных example1, response1, example2, response2, example3 и response3.
Посмотрим, сможем ли мы добиться от модели вывода информации в нужном формате!
Это упражнение является частью курса
Работа с OpenAI API
Инструкции к упражнению
- Расширьте предыдущие сообщения, добавив дополнительные примеры для других стран, сохранённые в переменных
example1,response1,example2,response2,example3иresponse3.
Интерактивное практическое упражнение
Попробуйте выполнить это упражнение, дополнив этот пример кода.
client = OpenAI(api_key="")
response = client.chat.completions.create(
model="gpt-4o-mini",
# Add in the extra examples and responses
messages=[
{"role": "system", "content": "You are a helpful Geography tutor that generates concise 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)