Skip to course content
Free generative AI app course

Generative AI Application Development with Python

Module 10 Activity

Scenario

Put an interface in front of it, without the interface becoming the weakest part.

What you build

An endpoint with validation on the request model, honest streaming, a timeout the user can understand, and slow work off the request path.

Steps

  1. Build one endpoint with a request model and a response shape. Exercise it with TestClient, no server.
  2. Move all validation onto the request model so it runs before your handler.
  3. Stream a response and state what you would do if validation failed after streaming began.
  4. Set a timeout shorter than the infrastructure in front of you, with a message containing a request id.
  5. Move anything slower than a couple of seconds off the request path: accept, return an id, let the client return.
  6. Confirm the whole thing is exercised without starting a server.

Evidence to hand in

Review checklist