Skip to course content
Free generative AI app course

Generative AI Application Development with Python

Module 04 Activity

Scenario

The prompt is the largest determinant of behaviour in the app, and it is currently a string literal.

What you build

Versioned templates with declared variables, input validation before the prompt is built, and rendering tests that need no key.

Steps

  1. Convert every prompt to a template with declared variables and prove one fails on a missing value.
  2. Validate input before the prompt is built: length bounds and at least one content rule.
  3. Put untrusted text in the user turn, delimited, and state in the system message that it is data.
  4. Try a prompt injection against your own app and record what happened.
  5. Version your prompts, keep retired versions readable, and record the version with every response.
  6. Test rendering with hostile inputs including a $ and a {.

Evidence to hand in

Review checklist