Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 13.6 — Build: Ship AskDocs
RAG and Vector Search · Example 1 of 2

AskDocs, shipped: the whole query path

Toy embedder and fake model, so it runs identically in three languages. The structure is the real one: replace embed() and fake_model() with real calls and nothing else moves.

AskDocs assembled: an access filter, keyword and vector search fused with reciprocal rank fusion, an evidence threshold, a numbered-source prompt, a grounding check, a citation check and a refusal, followed by an evaluation report that fails its launch gate first and passes it after the fix.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write visible(docs, role) over a list of (id, access) pairs: public for everyone, staff only for role 'staff'. Print the visible ids for 'public' and for 'staff'.

02

Write exit_code(metrics, limits) that returns 1 if any metric is below its limit and 0 otherwise. Print the result for one passing and one failing set.

Explain it without notes

01

Walk through the order of steps in answer and say why each comes where it does.

02

Why does the access filter run before the search and not after it?

03

Why does the report fail its gate before the grounding check, why does it pass after, and what does the fix cost?

04

What would you change to move this from toy to real?

AskDocs, shipped: the whole query path
Sign in to run this example in your browser.

Expected output

Q (public): What does the monthly pass cost?
   sources: D8, D10
   answer:  The monthly pass costs 25 dollars and includes unlimited rides of up to 45 minutes. [1]
Q (public): I forgot my login, how do I get back in?
   sources: D3, D1
   answer:  To reset your password, open the app, tap Forgot password and follow the link we email you. [1]
Q (public): Do you rent scooters?
   sources: none
   answer:  I could not find that in the handbook.
Q (public): When does the repair crew swap the rack locks?
   sources: D12, D10
   answer:  Always lock the bike to a rack with the built-in chain. [1]
Q (staff): When does the repair crew swap the rack locks?
   sources: D60, D12
   answer:  Staff only: the repair crew swaps the rack locks on the first Monday of each month. [1]