Ще більше повідомлень від assistant!
Розширте ваші попередні повідомлення, щоб додати додаткові приклади, збережені як 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)