Get startedGet started for free

Few-shot prompting: all the examples!

Now for the finale! Try adding the example Comfortable, but not very pretty = 2 to the prompt. As this example is more moderate, it might help the model with the troublesome second-to-last review.

This exercise is part of the course

Working with the OpenAI API

View Course

Exercise instructions

  • Add the Comfortable, but not very pretty = 2 example to the prompt and re-run the request.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

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)
Edit and Run Code