Write a fake AI client for tests
The class Assistant calls client.complete(prompt) on any client you give it. In tests you do not want to call a real model, so write the class FakeLLM.
FakeLLM(replies) receives a dictionary that maps a prompt to a reply. Its method complete(prompt) returns the reply for that prompt, or the text "I don't know" if the prompt is not in the dictionary. It also records every prompt it receives, in order, in a list called calls. Two different fakes must not share the same calls list. (The dictionary keys are the full prompt texts, exactly as Assistant builds them.)
The last line of the starter uses your fake with Assistant; it should print 4.
What Check tests
completereturns the canned reply for a known promptcompletereturns "I don't know" for an unknown promptcallsrecords every prompt in order- Two fakes do not share their
callslist Assistantworks with the fake and the program prints4
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Output
Press Run to see what your program prints.