LLM Engineering · Exercise 6 of 6 Previous
Intermediate
Wrap any model in a recorder
FakeModel is given. Write a class Recorder whose constructor takes an inner model. Its complete(messages, max_tokens=100) calls inner.complete(messages, max_tokens) and returns the reply unchanged.
It also appends a dictionary {"messages": len(messages), "max_tokens": max_tokens, "text": reply["text"]} to a list attribute calls.
What Check tests
- The reply is passed through unchanged
- Each call is recorded with the message count, limit and text
max_tokensis forwarded to the wrapped model- Recorders can be stacked
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.