Tek örnekle istem: yeterli olacak mı?
Gördüğün gibi, ilk prompt'unda iyileştirme payı var. Bir örnek olarak Love these! = 5 eklemeyi ve her incelemeden sonra = koymayı dene; böylece daha tutarlı bir biçimlendirme ve daha doğru sayılar elde edip edemeyeceğini gör.
Bu egzersiz
OpenAI API ile Çalışmak
kursunun bir parçasıdırEgzersiz talimatları
- Prompt'un başına
Love these! = 5örneğini ekle ve sonucun nasıl biçimleneceğini göstermek için prompt'taki her incelemeden sonra=ekle.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
client = OpenAI(api_key="")
# Add the example to the prompt
prompt = """Classify sentiment as 1-5 (negative to positive):
1. ____
2. Unbelievably good! ____
3. Shoes fell apart on the second use. ____
4. The shoes look nice, but they aren't very comfortable. ____
5. Can't wait to show them off! ____"""
response = client.chat.completions.create(model="gpt-4o-mini", messages=[{"role": "user", "content": prompt}], max_completion_tokens=100)
print(response.choices[0].message.content)