A production-grade AI pricing and information engine built over Version 3 of the ASSAR Rwandan Insurance Manual. Features a hybrid architecture that routes semantic prose queries to a vector store (ChromaDB) and isolates mathematical calculations inside typed Python functions reading exact rates from SQLite, eliminating LLM math hallucination
# ASSAR Pricing Assistant
A pricing and information tool built over ASSAR's Approved General Business
Pricing Manual for the Rwandan Insurance Industry (Version 3). Through a
Streamlit chat it answers underwriting questions, produces deterministic premium
quotes with a step-by-step breakdown, and renders side-by-side rate comparison
tables. It combines SQL lookups for the manual's numbers with reranked hybrid
search over its prose, and it will not state a rate that is not grounded in the
manual.
## Why a hybrid of SQL and retrieval
The manual holds two kinds of content, and they are best handled in different
ways.
| Content | Stored in | Reason |
|---|---|---|
| Rate tables (fire grid, transit and marine commodity rates, liability, PA, engineering, bonds, PVT, schedules, minimums) | SQLite | The numbers must stay exact. Embedding a value such as 0.3144% would blur it. |
| Prose (definitions, conditions, warranties, exclusions, underwriting guidance) | Vector store (ChromaDB with local embeddings) | Semantic questions, where no figure is at stake. |
Premiums are computed by typed Python functions in `assar/pricing/` that read
exact rates from SQLite. The language model does not do the arithmetic. It
extracts the parameters, calls a pricing function, and phrases the result, which
keeps quotes deterministic. The pricing code is covered by 39 tests in `tests/`.
```
free-text query -> router -> pricing tools -> SQLite rates -> deterministic premium
|--> table request -> assar_info.db -> rendered comparison table
\--> hybrid search + rerank -> manual prose -> grounded answer
|
v
LLM composes a grounded answer
(no ungrounded figures allowed)
```
The Get a Quote tab bypasses the model and calls the calculators directly, so
pricing works with no API key. The Database tab lets you browse and run
read-only SQL against the rate tables.
## Two databases
The project keeps two SQLite files, both built from the same manual but shaped
for different uses.
- `data/assar.d …