MulaiMulai sekarang secara gratis

Reasoning with chain-of-thought prompts

Chain-of-thought prompting is helpful to explain the reasoning behind the answer that the model is giving, especially in complex tasks such as generating the solution for a mathematical problem or a riddle. In this exercise, you will craft a chain-of-thought prompt to let the language model guess the age of your friend's father based on some information you will provide.

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

Latihan ini adalah bagian dari kursus

Prompt Engineering with the OpenAI API

Lihat Kursus

Petunjuk latihan

  • Create a chain-of-thought prompt to determine your friend's father's age in 10 years, given that he is currently twice your friend's age, and your friend is 20.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

client = OpenAI(api_key="")

# Create the chain-of-thought prompt
prompt = ____

response = get_response(prompt)
print(response)
Edit dan Jalankan Kode