c-02-rag-citations
RAG with Citations
Offline retrieval that cites sources like an adult, not like a model vibes-printing footnotes.
mid
python
~35 minREADME
# c-02-rag-citations Return an answer plus at least one citation dict with `id` and `snippet` for an offline corpus. Reranking must be deterministic — no random tie breaks. ## Validator From repo root: ```bash npm run challenge -- rag-citations --track langchain ``` Or from this package directory: ```bash cd challenges/langchain/c-02-rag-citations uv run python tests/validate.py ```
Hints
- Token overlap is primitive; deterministic rerank rules are how you avoid flaky tests.
- The validator looks for `doc-widget` and actual substring overlap in `snippet`.
- If two docs tie, break ties with a stable secondary key — priority, then id.
Acceptance
- `npm run challenge -- rag-citations --track langchain` exits 0
- `answer_query` returns `answer` plus `citations` with `id` and `snippet`
- Widget queries surface `doc-widget`; Runnable jargon surfaces `doc-lc`