An agentic dispatch and response optimization dashboard built to estimate response times and suggest optimal emergency dispatch recommendations using Gradient Boosting predictors, Conformal Prediction, and Reinforcement Learning (PPO).
From the project root directory (c:/Users/DELL/fire_dept), activate the virtual environment and install dependencies:
- PowerShell:
.\venv\Scripts\Activate.ps1
- Command Prompt:
.\venv\Scripts\activate.bat
- Install Requirements:
pip install -r requirements.md
Navigate to the frontend directory and install the Node packages:
cd interface/frontend
npm installTo train the Response Time Prediction engines, train the RL Agent, and pre-generate discrete-event simulation outputs:
python main.pyNote: Training compiles the PPO agent models and writes the response-time predictor models to
models/predictor.pkl.
From the project root directory, launch the uvicorn server:
uvicorn interface.app:app --host 127.0.0.1 --port 8000 --reload- The backend automatically pre-loads the road network graph from memory caches on startup and runs at
http://127.0.0.1:8000.
In a separate terminal, navigate to the frontend directory and run the Vite development server:
cd interface/frontend
npm run dev- Access the control room interface at
http://localhost:5173. Click Trigger Simulation to start.
- Pickle Serialization: The 61.5 MB OSMnx road network graph (
tamil_nadu_road_graph.graphml) is parsed once, and cached as a serialized python pickle file (tamil_nadu_road_graph.pkl). This drops server load times from 10+ minutes to under 2 seconds. - Dijkstra Query Memoization: To allow real-time discrete event simulation over WebSockets, the travel time routing calls are cached using
@lru_cache. Unique coordinate pairs are rounded to 4 decimal places (~11 meters) to achieve a 100% cache hit rate, reducing step delay overhead from seconds to 0 milliseconds.
The interface has been redesigned to resemble a modern fleet logistics control panel:
-
Route Timeline: Selecting any active incident displays a vertical milestones timeline tracing Call Intake
$\to$ Crew Turnout$\to$ En Route$\to$ Resolution. - Light Map Style: Integrates CartoDB Positron map styling with custom numbered circular route checkpoints.
-
Operational HUD: Displays Conformal Prediction ranges (e.g.
8.2 – 10.4 min), SHAP-driven explainable AI (XAI) text, and dynamic KPI grid counters for utilization percentage and fleet tracking.
fire_dispatch/
├── data/
│ ├── road_network.py # Cached Dijkstra routing & OSMnx wrapper
│ ├── feature_engineering.py # Ingestion to model feature engineering transformer
│ └── generate_data.py # Synthetic CAD records generator
├── models/
│ ├── response_time_predictor.py # GB Regressors & Conformal Interval models
│ └── explainer.py # SHAP explainability text generator
├── optimization/
│ └── dispatch_optimizer.py # SciPy MILP + Gym PPO Agent environment
├── simulation/
│ └── fire_service_sim.py # Discrete event policy simulation
├── interface/
│ ├── app.py # FastAPI + WebSocket backend app
│ └── frontend/ # React (Vite) + MapLibre light GUI console
├── main.py # Master pipeline training script
└── requirements.md # Project python package list
An automated, non-blocking AI-assisted developer workflow that detects code changes, generates structured handoff notes using LLMs, and updates GitHub pull request comment states and issue trackers.
Developer pushes code / updates PR
↓
GitHub Action (handoff.yml)
↓
HandoffContext (unified diffs, commit metadata, PR title)
↓
Handoff Generation Service (FastAPI /api/handoff/generate)
↓
LLMService (Gemini / OpenAI structured response schema)
↓
Structured Handoff Note (Summary, Complete, Unresolved, Risks, Owner)
↓
GitHub Integration (Idempotent comment on PR & Follow-up Issue creation)
- Idempotent Comments: Puts a single comment pinned by a hidden HTML marker
<!-- AI-HANDOFF -->on PRs and updates it in place when new commits are pushed, avoiding spam. - Follow-up Issue Integration: Automatically generates follow-up tasks linked back to the PR if unresolved work is detected and
CREATE_FOLLOWUP_ISSUES=trueis enabled. It performs duplicate checking against existing issues to prevent double-logging. - Handoff History Log: Persists generated handoff notes in a lightweight database (
logs/handoff_history.json). - Handoff Dashboard Panel: Includes a premium interactive tab Handoff in the operations sidebar to inspect logs and see details of recent handoffs.
To run the automated tests for the handoff collector, LLM service, GitHub API clients, and the retrieval tool:
py -m unittest scripts.handoff.tests.test_notes
python -m unittest discover -s scripts/handoff/tests -p "test_*.py"Retrieve the AI handoff note corresponding to your most recent push or pull request without generating a new LLM response. The notes.py tool securely downloads the already-generated handoff note from GitHub Actions artifacts and saves it locally.
Configure your GitHub Personal Access Token (GITHUB_TOKEN) in your terminal:
- Windows (PowerShell):
$env:GITHUB_TOKEN="your_personal_access_token"
- Linux/macOS:
export GITHUB_TOKEN="your_personal_access_token"
Run the script from the repository root:
python notes.pyThis automatically detects your current repository, branch, and latest commit (preferring the latest PR commit handoff if a PR exists), downloads the artifact, saves it as Markdown to handoffs/handoff-<short_sha>.md, and prints a summary to your terminal.
- Latest Handoff (Default):
python notes.py --latest
- Specific Commit Handoff (Supports full or short SHAs):
python notes.py --commit <sha>
- Specific Pull Request Handoff:
python notes.py --pr <pr_number>
- List Recent Handoffs:
python notes.py --list