Skip to content
Lubo Bali
All projects

AI agentsTransport

Citibike analytics agent

Ask where the bikes need to go tomorrow morning, in plain English

68%higher demand in November than in July

See the code on GitHub (opens in a new tab)

Proof you can check:Code on GitHub

AI agents

7 everyday questions need no AI at all

“Which stations need bikes tomorrow morning?”

Tested SQL template7 everyday questions, instant, no AI
AI writes the queryfor new questions (GPT-4o or a local model)
Answer + chartby station and bike type

Lubo Bali · lubobali.com

No. 08NYC Citibike, July and November

The problem

In NYC's bike sharing system, every morning some stations run empty and others overflow. The redistribution team needs to know which stations need bikes, how many and of which type, without writing SQL.

What I built

An agent over a star schema of the rides: common questions go to 7 tested SQL templates (no AI, instant), new questions go to an AI that writes the query, and every answer can come with a chart.

Tech & why

Templates for the questions asked every day: faster, cheaper and never wrong. The AI only for the rest, with a local model option for private data.

  • Python
  • FastAPI
  • PostgreSQL
  • AdalFlow
  • Next.js

The result

Answers like "top 10 stations that need bikes, classic vs electric" in plain English, and the finding that November has about 68% higher demand than July.

How this agent is built

Every AI agent has the same five parts. Here is what each one is in Citibike analytics agent, so you can judge any agent the same way.

  1. ModelGPT-4o, or a local Llama model through Ollama for private data.
  2. HarnessA router: a question that matches a tested template skips the AI; anything else goes to the AI.
  3. Guardrails7 pre-tested SQL templates for everyday questions, so the most-asked answers can't be made up.
  4. KnowledgeNYC Citibike rides for July and November in a star schema, plus past successful questions.
  5. ToolsPostgreSQL queries and Plotly charts.

Similar projects

Have a problem like this? Get your free AI blueprint in about a minute.

Tell me your problem. I'll find a way to build the solution.

Available now

Book a free 30-min call (opens Calendly in a new tab)

No obligation. Pick a time that suits you.

Prefer email?data@lubobali.com