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
- record calls the live model and returns its reply
- the reply is stored under tiny_hash(prompt)
- replay returns the saved reply without a live call
- 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.