更多 assistant 訊息!
在你先前的訊息基礎上擴充,提供更多範例,並將它們存成 example1、response1、example2、response2、example3 和 response3。
來看看能不能讓這個模型依照指定格式輸出資訊!
本練習屬於課程
Working with the 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)