Skip to course content
Free generative AI app course

Generative AI Application Development with Python

Module 03 Activity

Scenario

Make one real call and handle its response properly, including the three ways it can be less than it appears.

What you build

A call wrapper that reads the whole response object, checks the finish reason, and logs enough to explain the call later.

Steps

  1. Build a three-role message list and print it. Say where retrieved data should live and why.
  2. Read the whole response object, not just the text. Record finish reason, usage and model.
  3. Deliberately set a low output limit and observe truncation. Confirm it raises nothing.
  4. Stream a response, accumulate the chunks, and measure time to first chunk against time to complete.
  5. Write a log line that explains the call without containing its content.
  6. Include the prompt version and the model version.

Evidence to hand in

Review checklist