RegelWerk
RAG that refuses to answer without a verified legal citation.
Try it live
Open full screen ↗The real app, running live — interact with it right here.
The problem
Most RAG demos stop at retrieval and happily hallucinate citations. For a legal-rules assistant, an unbacked claim is worse than no answer.
The solution
A Swiss tenancy-law Q&A where every statement traces back to a cited article. A second, adversarial agent verifies each citation against the real article text; unbacked claims are flagged and the answer is revised. No source, no answer.
What it does
- ▹Citation verification by a second adversarial agent
- ▹Guardrail rejects off-topic questions instead of hallucinating
- ▹116 legal articles embedded in Supabase pgvector (HNSW, cosine)
- ▹Tool calling with zod-validated schemas (searchLaw, getArticle)
- ▹Eval: 20/20 retrieval hit-rate over a fixed question set
How it works
- 1
Retrieve
The question is embedded with Gemini and matched against 116 articles in pgvector; a score threshold guards against off-topic queries.
- 2
Answer with tools
An answer agent composes a response using searchLaw / getArticle tool calls, quoting specific articles.
- 3
Verify & revise
An adversarial checker validates every [Art. XXX] reference against the real text and forces a revision if any claim is unbacked.
Architecture
Click a node to see what it does.
Tech stack
- Next.js
- TypeScript
- Gemini
- Supabase pgvector
- Zod