1. Learn
  2. /
  3. Courses
  4. /
  5. Prompt Engineering with the OpenAI API

Connected

Exercise

Self-consistency prompts

Imagine you own a store that sells laptops and mobile phones. You start your day with 50 devices in the store, out of which 60% are mobile phones. Throughout the day, three clients visited the store, each of them bought one mobile phone, and one of them bought additionally a laptop. Also, you added to your collection 10 laptops and 5 mobile phones. How many laptops and mobile phones do you have by the end of the day? This problem is defined in the problem_to_solve string, and you will use a self-consistency prompt to solve it.

The OpenAI package and the get_response() function have been pre-loaded for you.

The get_response() function in this exercise employs the max_tokens parameter to help this exercise run faster.

Instructions

100 XP
  • Create the self_consistency_instruction that allows the model to solve the problem with three experts and combine the results with a majority vote.
  • Create the final prompt by combining the self_consistency_instruction and the problem_to_solve.