IniziaInizia gratis

Building specific and precise prompts

In the previous exercise, you generated text that completes a given story. Your team was happy with your achievement, however, they want you to follow specific guidelines when it comes to length and style. Your task now is to craft a more specific prompt that controls these aspects of the generated story.

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

Questo esercizio fa parte del corso

Prompt Engineering with the OpenAI API

Visualizza il corso

Istruzioni dell'esercizio

  • Craft a prompt that completes the given story with only two paragraphs in the style of Shakespeare; use f-string, and delimit the story with triple backticks (```).

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

client = OpenAI(api_key="")

# Create a request to complete the story
prompt = ____

# Get the generated response
response = ____

print("\n Original story: \n", story)
print("\n Generated story: \n", response)
Modifica ed esegui il codice