Intermediate
Delete everywhere, then audit
stores is a dict with three entries: "chunks" and "vectors" map chunk ids such as "D5#1" to values, and "cache" maps a question to a pair (answer, [chunk ids]).
Write delete_doc(stores, doc_id) that removes every chunk, vector and cache entry that belongs to the document: ids start with doc_id + "#", and a cache entry belongs to it when any of its chunk ids does. Write audit(stores, doc_id) that returns the names of the stores (in the order chunks, vectors, cache) that still hold something from the document.
What Check tests
- The audit finds all three stores before deleting
- After deleting, the audit finds nothing
- Other documents are untouched
- The cache entry that cites D5 is gone
- A document that is not stored is a no-op
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.