少量示例提示:一次放上所有範例!
壓軸來了!請把範例 Comfortable, but not very pretty = 2 加到提示中。由於這個範例的語氣較為中性,可能有助於模型處理那個麻煩的倒數第二則評論。
本練習屬於課程
Working with the OpenAI API
練習說明
- 將範例
Comfortable, but not very pretty = 2加到提示中,並重新執行請求。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
client = OpenAI(api_key="")
# Add the final example
prompt = """Classify sentiment as 1-5 (negative to positive):
1. ____
2. Love these! = 5
3. Unbelievably good! =
4. Shoes fell apart on the second use. =
5. The shoes look nice, but they aren't very comfortable. =
6. 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)