Command Palette

Search for a command to run...

Hectal
Phase 4: Structured Output
LLM Engineering · Exercise 4 of 6 PreviousNext
Intermediate

Drop values the source text does not support

Write keep_only_evidence(data, source). data is a dictionary of extracted fields and source is the original text. Return (kept, removed).

kept is a new dictionary with the same keys. A string value that does not appear in source (compare ignoring upper and lower case) becomes None. Values that are already None, or are not strings, stay as they are. removed is the list of keys whose value was replaced, in the order of data.

What Check tests

  1. Supported values stay
  2. An invented value becomes None and is reported
  3. Case does not matter
  4. None and numbers are left alone
  5. The input dictionary is not changed

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.