Agentic IPL analyst Β· 2024 & 2025
Agentic IPL Analyst β GDG Baroda Hackathon
A question goes through three hops before an answer appears.
User asks a question
Browser sends the query to /api/ask as a GET request, opening an SSE stream.
Agent loop β up to 5 rounds
The Cloudflare Worker runs an async generator. Round 0 forces a tool call (tool_choice: "required") so the model can never guess. Subsequent rounds are auto with JSON output mode.
Tool execution β pure JS, in-memory
Each tool call runs synchronously over 34,388 deliveries bundled as an ES module. Zero network round-trips. Results are appended back into the conversation.
Azure OpenAI β gpt-5.4-mini
Uses the Responses API (/openai/responses), not Chat Completions. System prompt goes into instructions, tool results as function_call_output items.
SSE β Answer card
The Worker streams tool_call events (chips animate in real-time) then a final event with a structured JSON payload β headline, insight, chart, sources, follow-ups.
Every layer runs at the edge. No servers. No databases.
Cloudflare Workers
Serverless edge runtime. Handles routing, SSE streaming via TransformStream, and serves static assets β all from a single Worker.
Azure OpenAI β gpt-5.4-mini
Latest model via the Responses API. Native function calling, structured JSON output, and instructions field for system prompts.
Static JSON as ES Module
The entire 34 k-delivery dataset is bundled into the Worker as import data from "./data.json". 12 MB raw, 306 KB gzip β well within Worker limits.
Vanilla JS + Tailwind CDN
Zero build step, zero framework. SSE via EventSource, SVG charts hand-rolled, player name linkification with regex β all in plain JS.
Six pure-JS functions. No async. No I/O. The agent picks which to call.
get_player_stats
Batting and bowling splits for any player β filterable by season (2024/2025), phase (powerplay/middle/death), and opponent team.
compare_players
Side-by-side comparison of 2β4 players on a chosen metric (strike rate, economy, average, wicketsβ¦). Drives most "X vs Y" questions.
find_matches
Looks up matches by season, stage (Final, Qualifier), or team. Called first for "Who won IPL 2024?" style questions to get the right match ID before fetching context.
match_context
Full match summary β teams, venue, innings totals, wickets, result β for a given Cricsheet match ID.
clutch_index
Composite 0β100 pressure score. Weights death-overs performance (40%), boundary/dot % under pressure (30%), and sample-size confidence (30%). Answers "Was X clutch?"
head_to_head
Batter vs bowler matchup β balls faced, runs, dismissals, strike rate. Filterable by season.
Ball-by-ball Cricsheet data, flattened and bundled at build time.
145
Matches
34,388
Deliveries
222
Players
Row schema
Source: cricsheet.org Β· Flattened by scripts/flatten.js
Built at GDG Baroda Β· Build with AI Hackathon
GitHubAsk about any player, match, or stat from IPL 2024 & 2025.
Try asking