Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Prompt Engineering with the OpenAI API

Cursus bekijken

Oefeninstructies

  • 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 (```).

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

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)
Code bewerken en uitvoeren