フューショットプロンプティング
いよいよ最後のステップです!さらにComfortable, but not very pretty = 2という例をプロンプトに追加してみましょう。この例は中間的な評価を示しているため、正確ではなさそうだった下から2番目のレビューに対して、適切に対応できるようになるかもしれません。
この演習はコースの一部です
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)