Problem
Employees of a food-delivery company ask an in-house data assistant very different questions. Some are precise; others show the user does not know where to start. In beta tests, PMs asked for query explanations, table lookups and log guidance, not only SQL. Over 10% of all questions had nothing to do with data, and text-to-SQL answers them wrongly. One chain cannot serve all of this.
Example from the article: a user may ask for the share of STOD orders from yesterday's Order Master table, excluding test restaurants, rounded to two decimals, while another cannot formulate a question at all.
Solution in brief
A supervisor chain scores and classifies each question first, and asks vague ones to be rephrased. Accepted questions go to one of several specialised chains. Each chain feeds the LLM only reduced, retrieved metadata (trimmed DDL, enriched table descriptions, a log terminology dictionary) to limit hallucinations.
Questions this case answers
- How to route questions of very different quality and intent to specialised LLM chains so that vague or off-topic questions do not produce wrong answers
- How to let non-technical users find the right tables and event logs when metadata is sparse, abbreviated, and uses company-specific terms
- How to route vague business questions to the right LLM chain in an internal data assistant?
- How to find the right table or event log from a natural-language description in a company data catalog?
Tools and methods
- Router Supervisor chain — scores question quality, classifies the question, routes it to a feature chain (idea from LangGraph's Agent Supervisor)
- Vector store — holds DDL, enriched table metadata, and log descriptions for retrieval
- SQLGlot with regular expressions — extracts table names from a user's query
- LLM-enriched table metadata — purpose, characteristics and keywords per table
- Business term dictionary and topic modeling — expand the user's question before table search
- Plan and Solve prompting — guides query and table interpretation
Google or a one-time email code. No password.