AI 资讯
Building a 'Chief Health Officer' with LangGraph: Automatically Filter Your Food Delivery Based on Real-Time Blood Sugar
We’ve all been there: it’s 7:00 PM, you’re exhausted after a long sprint, and you open a food delivery app. Your brain screams "Double Cheeseburger," but your body is still recovering from that mid-afternoon sugar spike. What if your phone was smart enough to say, "Hey, your blood sugar is currently 160 mg/dL and rising—maybe skip the extra fries?" In this tutorial, we are building a Chief Health Officer (CHO) Agent . This isn't just a simple chatbot; it’s a sophisticated AI Agent using LangGraph to bridge the gap between real-time medical data (CGM) and real-world actions (Food Delivery APIs). By leveraging automation , function calling , and state machines , we’ll create a system that actively protects your metabolic health. The Architecture: How the CHO Agent Thinks To build a reliable agent, we need a "stateful" workflow. We aren't just sending a prompt to an LLM; we are creating a loop that monitors glucose levels, analyzes food options, and interacts with the browser. graph TD A[Start: Hunger Trigger] --> B{Fetch CGM Data} B -->|Sugar High/Unstable| C[Constraint: Low GI Only] B -->|Sugar Stable| D[Constraint: Balanced Meal] C --> E[Scrape Delivery App Menu] D --> E E --> F[Agent: Analyze Ingredients & GI Index] F --> G[Selenium: Mark/Filter Non-Compliant Items] G --> H[End: Safe Ordering] subgraph "The LangGraph Loop" C D E F end Prerequisites Before we dive into the code, ensure you have the following: LangGraph & LangChain : For the agent's cognitive architecture. Dexcom API Credentials : To fetch real-time Continuous Glucose Monitor (CGM) data. Selenium : For interacting with food delivery web interfaces (Meituan/Ele.me). OpenAI API Key : Specifically for GPT-4o’s reasoning and function-calling capabilities. Step 1: Defining the Agent State In LangGraph, everything revolves around the State . Our CHO agent needs to track the current glucose level, the user's health constraints, and the list of available food items. from typing import TypedDict , List , Anno
AI 资讯
Fix Your "Developer Slouch": Building a Real-time AI Posture Monitor with MediaPipe and Electron
We’ve all been there. You start your morning feeling like a Productivity God, sitting straight and typing at 120 WPM. Fast forward four hours, and you've morphed into a literal shrimp, face inches away from the monitor, hunting for a missing semicolon. 🦐 In this era of remote work, real-time posture correction and computer vision for health have become more than just "cool projects"—they are spinal lifesavers. Today, we’re going to build a desktop application using MediaPipe , WebRTC , and Electron that monitors your neck angle and sends a desktop notification the moment you start slouching. By leveraging MediaPipe Pose and TensorFlow.js , we can calculate the Forward Head Posture (FHP) ratio with surgical precision directly in the browser environment. The Architecture 🏗️ Before we dive into the code, let’s look at how the data flows from your webcam to that "Sit up straight!" notification. graph TD A[Webcam Feed] -->|MediaStream| B(WebRTC API) B -->|Video Frames| C[MediaPipe Pose Model] C -->|Landmarks| D{Geometry Engine} D -->|Calculate Ear-Shoulder Angle| E{Threshold Check} E -->|Angle > 30°| F[Electron Main Process] F -->|Trigger| G[System Desktop Notification] E -->|Healthy| H[Continue Monitoring] style G fill:#f96,stroke:#333,stroke-width:2px Prerequisites 🛠️ To follow along, you'll need the following tech stack: MediaPipe Pose : For high-fidelity body tracking. WebRTC : To capture the video stream from your webcam. Electron : To wrap our logic into a desktop app that runs in the background. TensorFlow.js : The backbone for running ML models in JavaScript. Step 1: Setting up the Video Stream (WebRTC) First, we need to grab the camera feed. In a modern browser environment (or Electron's Chromium), we use navigator.mediaDevices.getUserMedia . async function setupCamera () { const videoElement = document . getElementById ( ' input_video ' ); const stream = await navigator . mediaDevices . getUserMedia ({ video : { width : 640 , height : 480 }, audio : false }); v
AI 资讯
How we built a medicine-substitution engine that refuses to be clever
How we built a medicine-substitution engine that refuses to be clever There is a category of bugs where the code looks perfectly correct in code review, the unit tests pass, the demo on stage goes beautifully, and a real person dies. Medicine substitution is one of them. We built Agada — point a phone camera at a medicine strip in India, and the app tells you whether the drug is registered with the regulator, what it does, and whether a chemically identical version is available at the government pharmacy for a fraction of the price. The point is real: Indians spend about ₹65,000 crore a year out of pocket on branded medicines when the same molecule sits in a Jan Aushadhi Kendra at a tenth of the cost. The Dolo-650 story (₹32 vs ₹4.90 for the same paracetamol) is the most famous example, not the only one. The hard part isn't the camera, the OCR, or the price lookup. The hard part is the substitution engine — the piece of code that decides "is this salt the same as that salt." Get that wrong in the wrong direction, and the app cheerfully tells a user that their 500mg anti-epileptic can be replaced with a 200mg one, because the strings look similar. So we built a matcher that refuses to be clever. This post is about the parts we deleted. The starting problem A user scans "Crocin 500mg Tablet IP". A Jan Aushadhi record says "Paracetamol 500 mg". A naive matcher says: both contain "500", both contain "Paracetamol" (or "Acetaminophen", which is the same thing in a different country), ship it. The user buys the generic. Savings: ₹20. Everyone wins. Now consider: Crocin 650 Advance vs Dolo 650 — same molecule, same dose, different brands. Fine. Augmentin 625 vs Augmentin 375 — same two salts, different ratio. The combo tolerance might let it through, but the clinical implication is real. Levofloxacin 500 vs Ofloxacin 400 — both fluoroquinolones, both "similar," but levofloxacin is the levo-isomer of ofloxacin and is dosed at roughly half. A "fuzzy" match here could halve so
AI 资讯
If your agent touches health data, do the boring part first
I’ll say it plainly: the first health-adjacent agent workflow I’d trust is not an AI doctor. It’s a narrow pipeline that takes 6 months of Apple Watch sleep data, cleans timestamps, maps records into a fixed sleep-diary schema, flags broken rows, and stops for human review before anything reaches a clinician. That sounds unsexy. Good. That’s exactly why it’s the first version I’d trust. I landed on this after reading a post on r/openclaw where someone said they had their AI assistant turn months of Apple Watch sleep data into the diary their sleep clinic requested, and the data gotchas were brutal. That sentence contains the whole product. Not “AI healthcare.” Not “autonomous wellness.” Not a GPT-5 wrapper with a soothing UI pretending it understands sleep medicine. Just a very practical engineering problem: parse ugly export data normalize time boundaries fit it into a clinician-friendly format fail loudly on bad rows require a human to approve it That is a real use case. And if you build automations in n8n, Make, Zapier, OpenClaw, or Python, it should feel familiar: the hard part is not the final prompt. The hard part is the ugly middle. The hard part is ETL, not reasoning Most health-agent demos skip the only part that matters. They show the polished summary. They show Claude or GPT-5 saying something calm and articulate. They show a dashboard. I don’t think that’s the hard part. The hard part is ETL: extraction transformation loading For sleep data, that means dealing with stuff like: timestamps crossing midnight timezone normalization naps vs overnight sleep missing start or end times overlapping intervals gaps from the device not recording clinic-specific diary formats If you get any of that wrong, the model summary at the end is not helpful. It is actively misleading. That’s why I think the boring pipeline is the real product. The workflow I’d actually ship If I had to build this today, I would keep the architecture aggressively narrow. Apple Health export ->
AI 资讯
Mirror Therapy Without the Mirror Box: Treating Phantom Limbs in a Browser Tab
A 1990s Nobel-adjacent therapy, a webcam, and 21 hand keypoints — recreating the mirror-box illusion for phantom limb pain, no hardware required. A therapy built on an illusion In the 1990s, neuroscientist V.S. Ramachandran discovered something remarkable: amputees suffering phantom limb pain often felt relief just by seeing their missing limb move again. His apparatus was almost comically simple — a box with a mirror. Put your intact hand in, look at its reflection where the missing hand would be, and move. The brain, watching the "missing" hand obey commands again, often dials the pain down. The limitation was never the science. It was the box: a physical apparatus, used in clinics, hard to scale, impossible to measure. Replacing glass with keypoints A webcam plus real-time hand tracking can produce the same illusion with better properties: webcam frame → hand landmark model (21 keypoints, on-device) → reflect: phantom[i] = { x: 1 − x, y, z } → render real hand (solid) + phantom twin (ghost) on canvas The reflection is one line of math. Everything around it is what makes the illusion land: const phantom = real . map ( p => ({ x : 1 - p . x , y : p . y , z : p . z })); The visual treatment matters more than I expected. The phantom hand is rendered as a ghostly cyan skeleton with a translucent palm fill, a "breathing" glow that pulses on a ~3 second cycle, and a fading afterimage trail of its last few frames — it reads as present but ethereal , which is exactly the perceptual story mirror therapy needs to tell. A dashed mirror plane down the center of the frame makes the reflection relationship legible at a glance. The engineering details that matter Tracking : MediaPipe HandLandmarker (Google's pretrained model — credit where due), running via WebAssembly with GPU delegate. ~30 FPS on a laptop. Privacy by architecture : every frame is processed on-device. For a medical-adjacent application, "video never leaves your browser" isn't a feature, it's a requirement. Lazy
AI 资讯
Day 48: Why AI-Verified 'Desi Ilaaj' is GoDavaii's Toughest (and Most Important) Challenge
Day 48 of building GoDavaii, and the toughest problem isn't the sheer volume of allopathic medicines or the complexity of their interactions. It's the invisible logic of 'Desi Ilaaj' - the home remedies and traditional practices deeply ingrained in Indian families for generations. When everyone knows the comfort and efficacy of 'haldi-doodh' (turmeric milk) for a cold, how does an AI health platform authentically verify and integrate that knowledge without replacing professional medical advice? This isn't just a cultural nod; it's a fundamental challenge for any health AI truly built for India. Global competitors like Epocrates or drugs.com, while excellent within their scope, are entirely English-centric and focused on Western allopathic data. They have no framework for the millions of people who search for health guidance in Hindi, Tamil, or Marathi, and whose first instinct for a cough might be a herbal concoction, not an over-the-counter syrup. The Unspoken Truth About India's Health Landscape For a vast majority of Indian families, health decisions often involve a blend of modern medicine and traditional wisdom. From specific herbs to dietary adjustments passed down through generations, these practices are effective for many minor ailments. Yet, in the digital health space, they're largely ignored. Why? Because the data is fragmented, often anecdotal, and doesn't fit neatly into structured pharmacological databases. It's a goldmine of practical health knowledge, but also a minefield for safety if not handled with care. My realization as Pururva Agarwal, 27-year-old founder of GoDavaii, was simple but profound: if we truly want to serve families coming online in their mother tongue, our AI needs to understand and interact with this context. This means going far beyond just translating English medical terms into 22+ Indian languages. It means building a knowledge graph that can intelligently cross-reference traditional remedies with known active compounds, potent
AI 资讯
Building a Life-Saving AI: Automating Medical Response with LangGraph and Python 🏥
Imagine your smartwatch detects an irregular heart rhythm at 3 AM. Instead of just waking you up with a frantic "beep," an AI agent immediately analyzes your historical health data, searches for the best cardiologist nearby, and prepares a calendar invite for a consultation. This isn't science fiction—it's the power of Healthcare Automation driven by AI Agents . In this tutorial, we are diving deep into LangGraph , the cutting-edge framework for building stateful, multi-agent applications. We’ll explore how to use State Machines to orchestrate a complex medical workflow, moving from an "Abnormal Heart Rate Alert" to a "Specialist Appointment" using the Tavily API for research and Twilio for urgent notifications. By the end of this guide, you’ll understand how to manage non-linear LLM workflows that require reliability and precision. The Architecture: Why LangGraph? Traditional LLM chains are linear. But medical emergencies are not. They require loops, conditional branching (e.g., "Is this an emergency or a routine check-up?"), and state persistence. LangGraph allows us to define a graph where each node is a function and edges define the transition logic. Data Flow Overview The following diagram illustrates how our agent processes a heart rate alert: graph TD A[Start: Heart Rate Alert] --> B{Severity Triage} B -- Emergency --> C[Twilio: Alert Emergency Services] B -- High Risk --> D[Tavily API: Find Best Specialist] B -- Normal/Review --> E[Log to Health Records] D --> F[Google Calendar: Draft Appointment] F --> G[Twilio: SMS Patient Confirmation] C --> H[End] G --> H E --> H Prerequisites 🛠️ To follow along with this advanced tutorial, you'll need: Python 3.10+ LangGraph & LangChain : The orchestration engine. Tavily API Key : For searching local medical specialists. Twilio Account : For SMS/Voice alerting. An OpenAI API Key (GPT-4o is recommended for medical reasoning). Step 1: Defining the Agent State In LangGraph, the State is a shared schema that evolves as it m