Ask this site

How it works

A retrieval-augmented assistant (RAG) with the controls a production AI system needs: guardrails, verified citations, cost limits, an audit log and a quality gate.

What happens when you ask

  1. Clean and mask. Emails, phone numbers, Aadhaar, PAN and card numbers (Luhn-checked) are replaced with placeholders. Only the masked text goes any further.
  2. Guardrail. Obvious attempts to change the assistant's instructions are refused without calling the model.
  3. Limits. Per-visitor rate limits at two layers (the web server and the API), plus a daily cap on model calls, so a busy day can't exhaust the free API quota.
  4. Search. An open embedding model running on this server finds the most relevant passages across the sites (at most two per page, for variety). If nothing is relevant enough, you get an honest “not on these sites” and no model call is made.
  5. Answer. The passages are sent to Gemini, fenced as data, with instructions to use only them and to return a fixed JSON shape: answer, citations, answerable. The fast model goes first; a stronger one is the fallback.
  6. Verify. Every citation must point to a passage that was actually provided. An answer that cites nothing valid is replaced with “not found”. No unsupported answers get through.
  7. Log. Outcome, timings, tokens and sources go to the audit log, which feeds the stats page.

Keeping the knowledge fresh and correct

Architecture

PartChoiceWhy
EmbeddingsEmbeddingGemma, running on this serverNo per-request cost or quota; the search step never leaves the server
Vector storePostgres + pgvector (HNSW index)One database for vectors, audit log and cache; no extra service
Answer modelGemini Flash-Lite, falling back to Gemini FlashMeasured about 2 s vs 7–18 s; the fallback covers outages
Model accessOne gateway moduleModel choice, timeouts, fallback and token accounting in one place; changing provider touches one file
NetworkDatabase on an internal network with no internet; only the API can reach outSmallest possible exposure
SecretsMounted by Docker from outside the code repositoryNothing sensitive in Git

Privacy