ComeçarComece gratuitamente

Prompts com autoconsistência

Imagine que você tem uma loja que vende laptops e celulares. Você começa o dia com 50 aparelhos na loja, dos quais 60% são celulares. Durante o dia, três clientes visitaram a loja. Cada um deles comprou um celular, e um deles também comprou um laptop. Além disso, você acrescentou ao conjunto 10 laptops e 5 celulares. Quantos laptops e celulares você tem no final do dia? Esse problema está definido na string problem_to_solve, e você deve usar um prompt com autoconsistência para resolvê-lo.

O pacote OpenAI e a função get_response() foram pré-carregados para você.

A função get_response() utiliza o parâmetro max_tokens para ajudar a executar este exercício com mais rapidez.

Este exercício faz parte do curso

ChatGPT Prompt Engineering para desenvolvedores

Ver Curso

Instruções de exercício

  • Crie self_consistency_instruction, permitindo que o modelo resolva o problema com três especialistas e combine os resultados tomando uma decisão por maioria de votos.
  • Crie o prompt final combinando self_consistency_instruction e problem_to_solve.

Exercício interativo prático

Experimente este exercício preenchendo este código de exemplo.

client = OpenAI(api_key="")

# Create the self_consistency instruction
self_consistency_instruction = ____

# Create the problem to solve
problem_to_solve = "If 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?"

# Create the final prompt
prompt = ____

response = get_response(prompt)
print(response)
Editar e executar código