Session 2. Call a model through the adapter — Tue 15 Sep

Quick quiz (ungraded)

Q1: What makes a class an LLMClient?

  • Nothing inherits from it. LLMClient is a Protocol; inheritance is not how it is satisfied.

  • Correct. Structural typing: the method is the contract, so a four-line fake is as valid a client as a vendor adapter.

  • get_client maps configuration to a client. A class it has never heard of still satisfies the protocol.

Q2: You change BOOTCAMP_PROVIDER from unset to ollama. What is allowed to change?

  • Correct. Those are the model's. Permissions, grading, redaction, retry budgets and failure behaviour are yours and must not move.

  • A permission that depends on the model is not a permission. The lane must not widen it.

  • You will see different failures. What a failure does is your code's decision, and it stays the same.

Q3: The anthropic lane is configured and ANTHROPIC_API_KEY is empty. What happens?

  • Nothing leaves the machine. get_client raises before the SDK is even constructed.

  • Correct. It fails closed at configuration time, and a message that echoed the key would put a secret in a notebook output.

  • The notebook preflight falls back and says so on its lane line. get_client itself raises; a silent downgrade would hide the missing key.

Q4: Your call to a provider exceeds its deadline. What should answer_with_timeout return?

  • The caller then handles two shapes and usually handles neither. ch02-e4 fails an escaped TimeoutError.

  • Correct. One shape either way, no citations for a call that never happened, and the flag downstream code routes on.

  • That is the one dishonest ending: a plausible answer produced by something other than the model you asked.

Q5: The preflight prints ⚠️ lane = ollama, falling back to fake. What is LIVE?

  • Correct. The probe could not reach the server or the model, so the notebook keeps running on the fake and says so.

  • The lane check probes before it promises, so you get a client that works rather than one that fails later.

  • The preflight never raises. A notebook that stops on a missing optional lane would block the required one.