An AI analyst for structured-credit data. Ask about assets, collections, repayments and contracts in plain English. Every number comes from a deterministic query, never from the model.
The LLM never produces a number.
A deterministic query layer produces every figure. The model only handles unclear wording and explanations, and a grounding check blocks any figure it invents.
The company’s data lives in Google Sheets spread across teams. Answering a simple question like “what is pending for this project?” meant opening several sheets, matching inconsistent names and adding up by hand.
That is slow and error-prone. Leo reads those sheets on a schedule and answers from a single database, with the source and data freshness on every answer.
Common questions skip the LLM entirely and are answered straight from the query layer.
Each layer exists to keep the numbers right.
A registry-driven loader pulls sheets through the Google Sheets and Drive APIs with read-only service-account access and writes to PostgreSQL. It checks a header contract before loading and keeps the last good data when a check fails.
Loads are idempotent, with row-level change history, overrides, duplicate and test-row flags, and daily refresh with freshness tracking. One source has 51 tabs in 8 different header layouts, which the loader maps by column name.
Clients, projects and assets are matched with aliases and fuzzy matching, plus guardrails so “Project 63” is never silently swapped for “Project 62”.
A deterministic router classifies questions and runs parameterised lookups: totals, profiles, comparisons, group-by, overdue and due-soon views. Common questions never reach the LLM, which keeps most answers under a second and the cost near zero.
Parameterised lookups were chosen over free text-to-SQL for safety and accuracy.
For free-text questions, a tool-calling LLM picks the lookup and explains the result. It launched on an open model, with a move to Claude Haiku and Sonnet planned. Model tiering, token budgets, caching and reasoning-effort limits keep cost predictable.
A numeric grounding check compares every figure in the model’s text with the lookup result and replaces any figure it can’t find. The model never produces a number.
About 6,600 contract files are indexed with PostgreSQL full-text search (tsvector with ranked retrieval) and trigram similarity for misspellings. Answers cite the file, the page and a verbatim passage, and say whether a contract matches a funded asset.
Next phase: OCR for scans and an LLM generation step with citations (RAG). Embeddings could be added for hybrid retrieval.
Conversation scope carries across follow-ups. Charts, Excel export, voice input and pinned client pages all run without any LLM call.
Access is admin-approved with role gating for sensitive modules, a per-user daily cap, and an audit log that stores no data. A status page shows the freshness and health of every source.
Keep the LLM out of the numbers.
Put data contracts at every boundary.
Make refresh failures visible and safe.
Every answer comes back with its source and how fresh the data is.
| Project 12 | ₹40.0 L |
| Project 41 | ₹25.0 L |
| Project 63 | ₹60.0 L |
Illustrative conversations with sample data.
Leo is an internal BetterInvest tool. Get in touch and I’ll happily walk you through it.
Get in touch Back to works