How does the "ask a question about the data" feature actually work?
I tried the AI question box on the live data page and it answered a question I typed in plain English. Is this just ChatGPT bolted on, or is it really querying your database? Genuinely curious how it's built.
Good question, and it's a fair one to be skeptical about. It's not a chatbot guessing from general knowledge — it's a text-to-SQL setup. When you type a question, a model (gpt-4o-mini, kept small on purpose) translates it into an actual SQL query against the Han River park dataset, the query runs on the real Postgres tables, and you get back numbers that came from the database, not from the model's imagination. The reason I built it that way: a model answering data questions from memory will confidently make things up. Forcing it to produce SQL means the answer is grounded in rows that exist. The tradeoff is the model sometimes writes a query that doesn't quite match what you meant — so it's a helper, not an oracle. I keep it embedded inside the data page rather than as a headline feature for exactly that reason. Treat it as a faster way to poke at the data, then sanity-check anything surprising.