और ज़्यादा 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)