Inspiration

Every second counts in a medical emergency. The average ambulance response time in urban India is 8–15 minutes. For cardiac arrests, survival drops by roughly \( P(\text{survival}) \approx e^{-\lambda t} \) — about 10% per minute without intervention. We saw a system still running on phone calls and manual dispatch logs, and knew AI could change that.


What We Learned

  • API integration in Python — routing Gemini through a backend proxy to handle CORS
  • Prompt engineering — structuring prompts so Gemini could triage severity from raw emergency text
  • Runtime API key injection — accepting the key at runtime instead of hardcoding, safe for public demo
  • Pure Python constraint — our judges required explainable Python-only code, which kept our logic clean
  • Grace under pressure — debugging a live proxy mid-hackathon taught us more than any lab session

How We Built It

The system follows a three-layer pipeline:

$$\text{Input} \xrightarrow{\text{triage}} \text{Gemini API} \xrightarrow{\text{dispatch logic}} \text{Response}$$

  1. Frontend — minimal HTML form collects emergency description and location
  2. Python proxy server — handles the Gemini API call server-side, keeping the API key off the client
  3. AI triage engine — Gemini classifies severity and returns a structured dispatch recommendation

The priority model:

$$\text{Priority Score} = \alpha \cdot S + \beta \cdot D + \gamma \cdot T$$

where \( S \) = symptom severity, \( D \) = distance factor, \( T \) = time elapsed.

response = requests.post(
    "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent",
    headers={"Content-Type": "application/json"},
    json={"contents": [{"parts": [{"text": prompt}]}]},
    params={"key": api_key}
)

Challenges We Faced

  • CORS — browser blocked direct Gemini calls; solved by routing through our Python proxy
  • Judge constraint — pure Python only meant no black-box frameworks; forced clean, readable code
  • Prompt instability — early prompts gave inconsistent triage output; fixed through structured prompt iteration
  • Time pressure — ruthless prioritization under hackathon hours
  • Team coordination — four people, one repo, zero (eventual) merge conflicts

Built With

Share this project:

Updates