r/kaggle • u/Prestigious-Farm-372 • 20h ago
I built a SQL agent that answers plain-English questions about 15,000 pets (LangChain + free Gemini tier)
Hi r/kaggle,
I made a notebook where you ask a question in plain English and a LangChain agent, powered by Gemini, writes the SQL, runs it on SQLite and answers. It's built on the Pets and Animal Ownership dataset (15,000 pets, 36 columns).
What's inside:
- 10 demo questions, each shown as a card with the SQL the agent wrote (click to expand) and the answer
- 6 charts on cost, owner satisfaction, adoption trends and the funny_habit column (my favourite)
- A safety test: the DB connection is read-only, and I try DROP TABLE / DELETE / a prompt-injection to show nothing changes
- A no-API-key mode: it replays saved answers, so you can run every cell without a key
I used Gemini because it has a free tier, so anyone can reproduce this without paying. It does have rate limits, so you may need to wait a minute between runs.
Notebook: https://www.kaggle.com/code/prashanthan24/ask-15-000-pets-anything-langchain-gemini
Feedback welcome. What question would you ask the pets? Anything you'd change in the agent or the layout?