Command Palette

Search for a command to run...

Hectal
Phase 12: Building a Production LLM Service
LLM Engineering · Exercise 4 of 6 PreviousNext
Advanced

Search only the caller's documents

DOCS is a list of (tenant, text). Write search(tenant, word) that returns the list of texts that belong to tenant and contain word as a whole word (compare lower-case words from text.split()), in the original order.

Do not write a function that searches all tenants: the point is that there is no way to search without naming one. If tenant is empty or None, raise ValueError.

What Check tests

  1. Returns the tenant's matching documents in order
  2. Never returns another tenant's document
  3. Matches whole words, ignoring case
  4. A missing tenant is an error

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.