IniziaInizia gratis

Using delimited prompts with f-strings

You are a junior developer at a dynamic startup that generates content with the help of AI. The company believes this technology can revolutionize storytelling, and you are excited to be a part of it. Today, your task is to generate a continuation of a story with a delimited prompt using an f-string.

The OpenAI package, the get_response() function, and the 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

  • Create a prompt asking to complete the variable story (provided to you as a string): use f-string, and delimit the story with triple backticks (```) to pass its content to the prompt.
  • Get the generated response.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

client = OpenAI(api_key="")

# Create a prompt that completes 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