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.
This exercise is part of the course
Prompt Engineering with the OpenAI API
Exercise instructions
- Create a prompt asking to complete the variable
story
(provided to you as a string): use f-string, and delimit thestory
with triple backticks (```) to pass its content to the prompt. - Get the generated response.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
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)