Więcej wiadomości asystenta!
Rozbuduj poprzednie wiadomości o dodatkowe przykłady, przechowywane jako example1, response1, example2, response2, example3 i response3.
Sprawdźmy, czy uda się nakłonić model do zwracania informacji w oczekiwanym formacie!
To ćwiczenie jest częścią kursu
Praca z API OpenAI
Instrukcje do ćwiczenia
- Rozbuduj poprzednie wiadomości o dodatkowe przykłady dotyczące innych krajów, przechowywane jako
example1,response1,example2,response2,example3iresponse3.
Interaktywne ćwiczenie praktyczne
Spróbuj tego ćwiczenia, uzupełniając ten przykładowy kod.
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)