Command Palette

Search for a command to run...

Hectal
Phase 9: Evaluation and Testing
LLM Engineering · Exercise 5 of 6 PreviousNext
Advanced

Record and replay model calls

Complete the Recorder class. complete(prompt) computes key = tiny_hash(prompt). In "record" mode it calls self.live.complete(prompt), stores the reply in self.tape[key] and returns it. In "replay" mode it returns self.tape[key] and never calls the live model; if the key is not in the tape it raises KeyError.

What Check tests

  1. record calls the live model and returns its reply
  2. the reply is stored under tiny_hash(prompt)
  3. replay returns the saved reply without a live call
  4. replay of an unseen prompt raises KeyError

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

main.py
Sign in to run your code.

Output

Press Run to see what your program prints.