Grounded answers over clinical literature — every citation verified against its source before it reaches the screen.
Quick Start · Architecture · The Pipeline · What Broke & Why · Evaluation · API
Clinicians and researchers burn hours hunting through thousands of pages of literature for an evidence-based answer.
| Approach | Why it fails here |
|---|---|
| 🔍 Keyword search | Cannot match meaning — misses the relevant study that used different words |
| 🧠 Vector search alone | Misses exact terms: drug names, protocol codes, record identifiers |
| 💬 Generic AI assistant | Answers fluently but without citations or verification |
In healthcare, a confident but subtly wrong answer isn't a UX annoyance. It's a patient-safety problem.
Retrieval-Augmented Generation over trusted documents only — the user's own corpus, nothing else.
1. Retrieve the strongest evidence from the corpus
2. VERIFY every citation against its source chunk
3. Return a grounded answer + provenance + confidence score
4. REFUSE when the evidence doesn't support an answer
|
📌 Citations are verified, not decorative |
A judge model checks each inline |
|
🚫 Refusal is a feature |
Below the confidence threshold the system says "I don't have enough information", lists the closest sources, and stops. Refusal accuracy is a first-class metric — currently 1.000. |
|
📄 Provenance to page and section |
A clinician must be able to open the exact page of the exact guideline. Every chunk carries page / section / structural locator all the way into the UI. |
|
🔢 Facts by exact match, not similarity |
Embeddings cannot tell |
|
🔒 Zero outside knowledge |
Generation is constrained to retrieved context, so every answer is attributable to a document the user supplied. |
Prerequisites — Python 3.13 (uv-managed venv), Node 20+, Docker (optional), and an
OPENAI_API_KEYin.env.
# 1️⃣ optional infrastructure — semantic cache + production stores
docker compose up -d # redis :6380 · postgres/pgvector :5433
# 2️⃣ backend (terminal 1)
uv run uvicorn app.main:app --reload
# if uv is blocked by machine policy:
# .\.venv\Scripts\uvicorn.exe app.main:app --reload
# 3️⃣ frontend (terminal 2)
cd frontend && npm run dev| 💬 Chat UI | http://localhost:3000 |
| 📘 API docs | http://localhost:8000/docs |
Ingest documents — drag files onto the chat composer 📎, or:
curl -X POST localhost:8000/v1/ingest \
-H "Content-Type: application/json" \
-d '{"source_dir": "data/corpus", "reset": true}'🛠 Useful commands
uv run pytest -m "not slow" # 93 fast tests — no models, no network
uv run pytest # everything, incl. model/API tests
uv run ruff check . # lint
uv run python scripts/run_eval.py # the regression gate💡 Runs with zero infrastructure. SQLite + ChromaDB out of the box. Docker only when you want the semantic cache and production stores.
A modular monolith with clean seams — so the planned service split is mechanical rather than a rewrite.
flowchart TD
FE["🖥️ frontend/ · Next.js 15 · React 19 · Tailwind v4<br/>chat UI — SSE streaming — citations — localStorage history"]
RT["🔌 app/routers/<br/>ask · ingest · cache · feedback · title · health"]
PL["⚙️ app/modules/pipeline.py<br/><i>the one place the flow is defined</i>"]
ING["📥 ingestion/<br/>load → chunk → embed → index"]
RET["🔎 retrieval/<br/>dense + sparse → fuse → rerank → confidence"]
GEN["✍️ generation/<br/>grounded answer with inline [n]"]
QUA["🛡️ quality/<br/>extract → verify → score → answer or refuse"]
CAC["⚡ cache/<br/>semantic cache (Redis)"]
AUT["🔁 autoeval/<br/>capture weak → draft → human review"]
EVL["📊 eval/<br/>golden set + regression gate"]
CLI["🔗 app/clients/ — the ONLY place that talks to an engine<br/>embeddings · vector · relational · cache · llm · reranker"]
FE -->|HTTP + Server-Sent Events| RT
RT --> PL
PL --> ING & RET & GEN & QUA & CAC & AUT & EVL
ING & RET & GEN & QUA & CAC & AUT & EVL --> CLI
Nothing outside
app/clients/may import or touch a storage engine's own API.That single rule is what turned the Postgres/pgvector migration into a config change instead of a rewrite — and it's what the service split depends on.
| Role | Model | Where it runs |
|---|---|---|
| 🗣 Generation | gpt-4o-mini |
OpenAI — final grounded answer |
| 🧭 Embeddings | text-embedding-3-small (1536-dim) |
OpenAI |
| 🎯 Reranking | cross-encoder/ms-marco-MiniLM-L-6-v2 |
Local, CPU |
| ⚖️ Judge | gpt-4o-mini |
Citation verification + eval grading |
| 🏷 Titling | gpt-4o-mini |
~30 tokens per new chat |
flowchart LR
A["📄 file"] --> B["loader dispatch<br/>by suffix"]
B --> C["Document{blocks[]}<br/><i>page · section · locator<br/>content_type · fields</i>"]
C --> D["chunker<br/><i>recursive | fixed<br/>semantic | structured</i>"]
D --> E["embed<br/>(batched)"]
E --> F["vector store<br/>upsert by<br/>deterministic id"]
F --> G["BM25 index<br/>rebuilt"]
G --> H["audit row<br/>↳ bumps corpus<br/>version"]
🔑 Key property — idempotent re-ingest. Deterministic chunk ids + delete-before-add mean re-uploading a document replaces its chunks. No duplicates, no orphans.
flowchart TD
Q["❓ question"] --> ID["🔢 identifier scoping<br/><i>names a real record id? → scope by exact metadata match</i>"]
ID --> EM["🧭 embed once<br/><i>reused for cache lookup and, on a miss, storage</i>"]
EM --> CA{"⚡ semantic cache"}
CA -->|"HIT<br/>cosine ≥ threshold<br/>AND same params hash<br/>AND current corpus version"| RESP
CA -->|MISS| RE["🔎 retrieve<br/>dense KNN + BM25 → RRF → cross-encoder rerank → confidence"]
RE --> GE["✍️ generate<br/><i>structured: answer · citations_used<br/>has_sufficient_context · self_confidence</i>"]
GE --> QU["🛡️ quality<br/>extract [n] → judge each vs. source → composite confidence"]
QU --> GATE{"confidence ≥<br/>idk_threshold?"}
GATE -->|yes| ST["💾 store in cache"]
GATE -->|"no"| IDK["🙅 honest refusal<br/>+ closest sources"]
IDK --> CAP["📮 capture as<br/>auto-eval candidate"]
ST --> RESP["📦 answer + citations<br/><i>source · page · section · locator · verdict</i><br/>+ confidence + breakdown"]
CAP --> RESP
composite = 0.40 × retrieval confidence
+ 0.40 × citation accuracy (judge verdicts)
+ 0.20 × model self-confidence
Why blend three signals? On an out-of-corpus question the model self-rated 0.9 while retrieval and citation accuracy were both 0.0. Any single signal can be fooled. The blend caught it and refused.
| Phase | What shipped | |
|---|---|---|
| 0 Scaffold | Modular-monolith layout, typed config, structured logging, health/ready endpoints, smoke tests. | ✅ |
| 1 Thin slice | Markdown loader → header-aware chunker → local embeddings → ChromaDB → grounded generation with inline [n]. File upload + idempotent re-ingest. | ✅ |
| 2 Hybrid retrieval | Dense + BM25 fused with Reciprocal Rank Fusion, reranked by a local cross-encoder, scored into one confidence. Three chunking strategies, config-selectable so they can be benchmarked. Why: keyword search misses paraphrases; vector search misses drug names and IDs. Fusion gets both. | ✅ |
| 3 ⭐ Quality layer | The heart of the system. generate → extract [n] → judge each citation → composite confidence → IDK gate at 0.45. Below it, the answer is replaced with an honest refusal that still lists the closest sources. | ✅ |
| 4 Eval harness | 20 human-authored cases (simple / multi-hop / ambiguous / no-answer) over a 154-document corpus. Deterministic metrics + judge-graded metrics against the human reference, so grading isn't circular. Proven: the gate caught a deliberate model downgrade — 0.969 → 0.918. | ✅ |
| 5 Semantic cache | Redis Stack with RediSearch vector KNN. A hit needs three things at once: cosine ≥ threshold, identical params hash, current corpus version. Measured: cold 26s → exact repeat 190ms → paraphrase hit → post-ingest miss. Redis down? The pipeline just runs. | ✅ |
| 6 Auto-eval loop | Weak answers (low confidence, refusals, 👎) are captured to a queue. A separate step drafts a reference answer twice and auto-approves only when both runs agree. A human always approves before anything reaches the eval set — and approved drafts land in a separate file so the hand-written golden set stays trustworthy. | ✅ |
| 7 9-format ingestion | Block-based IR: every chunk descends from exactly one Block and inherits its page, section, locator and content type — provenance survives every chunking strategy. OCR runs only on images and scanned PDF pages (detected by text density); OCR failure never breaks an ingest. | ✅ |
| 8 Frontend + API polish | ChatGPT-style UI with real token-by-token SSE streaming, citations with page/section, conversation history, thumbs feedback wired into the auto-eval loop, strictly black-and-white theme. Backend: /v1/ask/stream, CORS, /v1/documents, /v1/system, /v1/title. | ✅ |
| 9A Postgres / pgvector | Storage engines became pluggable — stores.vector: chroma | pgvector, stores.relational: sqlite | postgres. A VectorStore protocol sits in front of both; Chroma's API no longer leaks anywhere. pgvector uses one table (vector + jsonb), HNSW index, GIN on metadata. Migration copies vectors without re-embedding.Gated: eval re-run at 0.927 — no regression. | ✅ |
| 9B Service split | Planned split into ingestion (pymupdf, easyocr) · retrieval (torch) · api. The seams already exist; the work is Dockerfiles, HTTP clients mirroring today's function signatures, and compose wiring. The win: the API container stops carrying ~2 GB of torch. | 🚧 |
Every one of these was reproduced and quantified before it was fixed. Several turned out to have a different cause than the symptom suggested.
🐛 8.1 — Structured records were always refused
The cross-encoder reranker is trained on prose. Measured scores on a perfectly relevant chunk:
| Chunk type | Reranker score |
|---|---|
| CSV row | −7.18 |
| PDF prose | −0.09 |
sigmoid(−8) ≈ 0.0003, which the quality gate reads as "no evidence". Result: every question about a CSV/JSON/XML file was refused, regardless of the data.
Fix → confidence for record-type chunks comes from the dense cosine instead. Ranking still uses the reranker.
🐛 8.2 — Grounded answers were being thrown away
Summary-style answers declare their sources in the structured field but write no inline [n] in the prose. Citation accuracy scored 0, the composite fell under the gate, and a correct answer was replaced by a refusal — while the response still listed 5 sources underneath it.
Fix → when no inline markers exist, verify the declared sources instead.
Measured on a real CSV question: 0.18 (refused) → 0.727 (answered).
🐛 8.3 — Different patient IDs returned the same answer
Measured query similarity with text-embedding-3-small:
| Pair | Cosine |
|---|---|
PAT-20260004 vs PAT-20260042 |
0.9982 |
PAT-20260042 vs PAT-20260043 |
0.9987 |
Both far above the 0.90 cache threshold — so the cache served the first patient's answer for every subsequent one. Nearest-neighbour search can't separate them either.
Fix → identifier-aware exact lookup, resolved before the cache key is built, so two ids can never share a cache entry.
🐛 8.4 — A 10k-line JSON export answered nothing useful
Splitting only at the top level left {"patients":[...]} as one 54 KB block, which token-slicing then cut mid-record: 120 patients became 39 chunks, none holding a whole record, all carrying the same locator.
Fix → structure-aware descent: 120 blocks, 120 distinct locators, one record per chunk, each carrying its scalar fields as searchable metadata.
🐛 8.5 — Uploaded CSVs were unreadable to the embedder
Spreadsheet exports merge header cells and Excel writes a BOM, so chunks read:
Id | Identifier: MRN | : http://... | : true
Fix → blank columns inherit their group with a positional suffix (Identifier 2), empty cells are skipped, files decoded as utf-8-sig.
🐛 8.6 — "Cannot reach the API" that was not a network problem
An unhandled exception in FastAPI is handled outside the CORS middleware — so the 500 carried no Access-Control-Allow-Origin header, the browser refused to read it, and the client reported the API as unreachable. The real cause was an embedding-dimension mismatch.
Fix → return 409 with an actionable message through the normal response path.
🐛 8.7 — Embedding model scale changes what a threshold means
bge-base (local) |
text-embedding-3-small |
|
|---|---|---|
| Paraphrase | 0.89 – 0.94 | 0.61 – 0.84 |
| Unrelated | ~0.47 | ~0.006 |
A cache threshold of 0.90 was correct for bge and is nearly dead for OpenAI. Measured recommendation: 0.80 (5/9 correct hits, 0/8 wrong answers).
uv run python scripts/run_eval.py # single run
uv run python scripts/run_eval.py --benchmark # compare all 3 chunkersLatest run — recursive chunker, 20 cases, text-embedding-3-small:
| Metric | Score | |
|---|---|---|
| Overall | 0.927 | 🟢 |
Refusal accuracy (idk) |
1.000 | 🟢 |
| Faithfulness | 0.990 | 🟢 |
| Correctness | 0.970 | 🟢 |
| Completeness | 0.940 | 🟢 |
| Retrieval recall | 0.925 | 🟢 |
| Citation accuracy | 0.713 | 🟡 |
| By question type | Score |
|---|---|
no_answer |
1.000 🟢 |
simple |
0.959 🟢 |
multi_hop |
0.872 🟢 |
ambiguous |
0.780 🟡 |
idk_accuracy 1.000— the system refused every question it should have refused. For this domain, that is the single most important number on the page.faithfulness 0.990— answers stayed inside their sources.citation_accuracy 0.713— the weakest metric and the obvious next target. It counts partial credit for citations the judge ratespartial.ambiguous 0.780— expected. Those cases are deliberately under-specified.
💬 Ask
| Method | Endpoint | Description |
|---|---|---|
POST |
/v1/ask |
Grounded answer (JSON) |
POST |
/v1/ask/stream |
Same pipeline as SSE: meta → delta* → final |
POST |
/v1/title |
Name a chat from its first question |
⚠️ Thefinalframe is authoritative. It carries the verified citations, the confidence, and any gate replacement. The streamed draft is not the answer.
Request options that matter
| Field | Effect |
|---|---|
filters.source |
One filename or a list — this is how an attached file scopes a question |
filters.file_type |
pdf · docx · csv · json · … |
mode |
hybrid · dense — per-request override |
📥 Ingest & documents
| Method | Endpoint | Description |
|---|---|---|
POST |
/v1/ingest |
Ingest a directory — {source_dir, reset} |
POST |
/v1/ingest/upload |
Multipart upload (the UI path) |
GET |
/v1/documents |
What's searchable, with chunk counts |
DELETE |
/v1/documents/{source} |
Remove a doc, rebuild BM25, invalidate the cache |
GET |
/v1/system |
Model wiring + corpus size |
⚡ Cache · 👍 Feedback · 🔁 Auto-eval · ❤️ Health
| Method | Endpoint | Description |
|---|---|---|
GET |
/v1/cache/stats |
Hits, misses, hit rate |
POST |
/v1/cache/flush |
Drop cached answers |
POST |
/v1/feedback |
up · down · retracted |
GET |
/v1/eval/candidates |
The auto-eval review queue |
POST |
/v1/eval/candidates/process |
Draft reference answers |
POST |
/v1/eval/candidates/{id}/approve | /reject |
Human gate |
GET |
/health |
Liveness |
GET |
/ready |
Dependency checks (vectors, sqlite) |
Next.js 15 (App Router) · React 19 · TypeScript strict · Tailwind v4 — ~3,100 lines.
Strictly black and white: status is conveyed by icon and contrast level, never by hue — which is also the accessible pattern.
- ⚡ Answers stream token by token; the terminal frame replaces the streamed draft with the verified answer, and says so when the quality gate swapped in a refusal.
- 📎 Attaching a file scopes the question to it. The composer footer states the scope — "Answering from DIABETES.pdf" — so the narrowing is never invisible.
- 🗂 Attachments render as cards above the question. The paperclip opens the file picker directly and ingestion starts on selection — no confirm step.
- 🏷 Conversations are named by a model from the first question — "How do I install FastAPI on Windows?" → "FastAPI Setup on Windows" — created lazily, stored in
localStoragebecause the backend is stateless. - 📚 Sources are collapsible and show filename, page, and the judge's verdict.
- 👍👎 Thumbs toggle; retracting a thumbs-down withdraws the auto-eval candidate it created.
Expand the full tree
app/
├── main.py FastAPI app factory, CORS, lifespan, router wiring
├── config.py ALL typed settings — .env (secrets) + config/system.yaml
│ (behaviour). No magic numbers in code.
├── logging_config.py structured JSON logging
│
├── clients/ ⚠️ the only code that knows about engines
│ ├── llm.py OpenAI + instructor (structured output) + judge
│ ├── embeddings.py OpenAIEmbedder | LocalEmbedder — same interface
│ ├── reranker.py local cross-encoder
│ ├── vectorstore.py facade: get_vector_store() by config
│ ├── vector/base.py VectorStore protocol, VectorHit, dimension guard
│ ├── vector/chroma.py ChromaDB backend (zero infrastructure)
│ ├── vector/pgvector.py Postgres + pgvector backend (production)
│ ├── relational.py sqlite | postgres dialect adapter
│ ├── db.py audit / eval / candidate / feedback queries
│ └── cache.py Redis Stack (RediSearch KNN) semantic cache
│
├── models/schemas.py every request/response contract (Pydantic)
│
├── modules/
│ ├── pipeline.py ask() and ask_stream() — the orchestrator
│ ├── ingestion/
│ │ ├── loader.py directory walk + format allowlist
│ │ ├── loaders/base.py Block / Document IR, @register decorator
│ │ ├── loaders/*.py md · txt · html · pdf · docx · image · csv · json · xml
│ │ ├── ocr.py engine-agnostic OCR (easyocr | tesseract)
│ │ ├── chunker.py recursive | fixed | semantic | structured
│ │ ├── indexer.py embed + write metadata + dimension guard
│ │ └── service.py orchestration, document listing, deletion
│ ├── retrieval/
│ │ ├── dense.py vector KNN
│ │ ├── sparse.py BM25 (rebuilt from the store, pickled)
│ │ ├── fusion.py Reciprocal Rank Fusion
│ │ ├── hybrid.py the full dense + sparse + rerank flow
│ │ ├── confidence.py score → 0..1, content-type aware
│ │ ├── filters.py metadata filters → engine-specific queries
│ │ ├── identifiers.py exact record lookup for id questions
│ │ └── retriever.py mode dispatch (hybrid | dense)
│ ├── generation/
│ │ ├── prompt.py system prompts + context rendering
│ │ ├── generator.py answer, streamed answer, chat title
│ │ └── schemas.py GeneratedAnswer / GeneratedTitle contracts
│ ├── quality/
│ │ ├── extractor.py pull [n] markers, pair them with claims
│ │ ├── verifier.py batched LLM judge → per-citation verdict
│ │ ├── confidence.py composite score maths
│ │ └── service.py assess() → report + answerable decision
│ ├── cache/service.py lookup / store / params hash
│ ├── autoeval/ capture → draft → human approve
│ └── eval/ golden set, metrics, runner, report
│
├── routers/ ask · ingest · cache · feedback · title · health
└── utils/tokens.py token counting and splitting (tiktoken)
frontend/
├── app/ Next.js App Router entry, global CSS (theme tokens)
├── components/ app-shell · chat-view · composer · message · sources
│ sidebar · history-view · document-chips · markdown · ui/
├── hooks/ use-chat (conversations + SSE) · use-documents · use-theme
└── lib/ api client · types mirroring backend schemas
localStorage persistence · formatting helpers
config/system.yaml the behaviour of the whole system
scripts/ fetch_corpus · run_eval · cache_loadtest · migrate_to_postgres
eval/golden_set.jsonl 20 human-written evaluation cases
tests/ 93 fast + 15 slow
docker-compose.yml redis-stack (6380) · pgvector/pg17 (5433)
Everything that changes behaviour lives in config/system.yaml. Secrets live in .env (OPENAI_API_KEY, optionally POSTGRES_DSN) and are never committed.
Expand the knobs
| Group | Keys |
|---|---|
models.* |
embedding (provider, name, dimensions, batch_size) · generation · judge · title |
stores.* |
vector: chroma|pgvector · relational: sqlite|postgres · postgres (dsn, table, HNSW params, pool sizes) |
retrieval.* |
mode · default_top_k · dense/sparse/rerank_candidates · rrf_k · dense_weight · sparse_weight · structured_confidence_from_dense (→ 8.1) · identifier_match_confidence (→ 8.3) |
ingestion.formats.* |
enabled · pdf.scanned_text_density_threshold · ocr (engine, languages, dpi) · csv.rows_per_chunk · json (max_record_tokens, max_depth, extract_fields, id_keys) · chunking |
quality.* |
verify_citations · idk_threshold · confidence_weights |
cache.* |
enabled · redis_url · threshold · ttl_seconds |
autoeval.* |
flag_confidence_threshold · dedup_threshold · agreement_threshold |
eval.* |
golden_path · retrieval_k · regression_tolerance |
| Store | Engine | Notes |
|---|---|---|
| 🧭 Vectors | ChromaDB (default, on disk) or Postgres + pgvector | HNSW index, GIN on metadata |
| 🔤 Keyword index | BM25 | Rebuilt from the vector store after every ingest, pickled to disk |
| 🗃 Operational | SQLite (default) or Postgres | ingestion_audit (max id = corpus version) · eval_runs / eval_case_results · eval_candidates · feedback (append-only; a retraction is a new row) |
| ⚡ Cache | Redis Stack | HNSW COSINE index; entries tagged with params hash + corpus version |
🐘 Switching to Postgres
uv add "psycopg[binary,pool]"
python scripts/migrate_to_postgres.py --dry-run
python scripts/migrate_to_postgres.py
# then set: stores.vector: pgvector · stores.relational: postgresℹ️
psycopgisn't currently installed (uv blocked by machine policy), so the Postgres code paths are written and SQL-verified against a live container but haven't been run from Python. They fail with an actionable message if the driver is missing.
1. Config over constants. Every threshold, model name and strategy lives in
config/system.yaml. There are no magic numbers in the code.2. Measure before fixing. Every bug above was reproduced and quantified first — several had a different cause than the symptom suggested.
3. Refusing is allowed. The system is designed to say "I don't know" and is graded on how well it does so.
4. Degrade, never crash. Redis down, OCR missing, a title model failing, a malformed JSON file — each is logged and stepped around. Ingest and ask keep working.
5. Fail loudly where silence is dangerous. An unsupported metadata filter raises instead of being dropped, because a silently ignored filter widens a scoped search without telling anyone.
6. One seam per engine. Everything engine-specific lives in
app/clients/.7. Every phase ships with tests — and, from Phase 4 on, must pass the evaluation gate before the next phase starts.
The product targets medicine; these still carry the original generic-RAG domain and should be retired.
-
prompt.SYSTEM_PROMPTstill says "technical documentation assistant for FastAPI" — every medical answer is currently produced under that persona -
eval/golden_set.jsonlis 20 FastAPI questions, so the regression gate measures a domain the product no longer targets -
scripts/fetch_corpus.pyfetches FastAPI documentation - The auto-eval draft prompt refers to a "FastAPI docs assistant"
- Phase 9B (service split) not started
-
cache.thresholdis still0.90— near-dead for the current embedding model;0.80is the measured recommendation (→ 8.7) -
autoeval.dedup_thresholdandagreement_thresholdwere calibrated for the old embedding model and need the same treatment -
psycopgnot installed, so Postgres paths are unrun from Python -
.jsonlisn't a registered format, despite being a natural fit for the record-per-line model - Only the top level of a deeply nested JSON object is exploded; a single very deep object still becomes one large block (then token-capped)
-
frontend/components/upload-dialog.tsxis no longer rendered (the composer replaced it) but is still in the tree
🪟 Environment notes (Windows)
uv.exeis intermittently blocked by an Application Control policy. The venv binaries work directly:.\.venv\Scripts\uvicorn.exe,.\.venv\Scripts\python.exe -m pytest- The same policy blocks a DLL inside
easyocr, so the slow real-OCR test fails on this machine. The fast suite fakes OCR and is unaffected. - Never run two
npm run devservers — they share.nextand corrupt each other's CSS chunks, producing a completely unstyled page. - Redis is mapped to host
6380and Postgres to5433because6379/5432are commonly taken.
| ~5,500 lines of Python | ~3,100 lines of TypeScript | ~1,500 lines of tests | 157 commits |
| 17 HTTP endpoints | 9 ingestion formats | 154-document eval corpus | 20 golden cases |
Built by Hareesh Kumar K
Learn deeply. Build relentlessly. Improve continuously.
⭐ Star this repo if a RAG system that knows when to shut up sounds useful to you.