File size: 11,632 Bytes
6f69718
be2d916
6f69718
 
 
 
 
be2d916
6f69718
be2d916
6f69718
be2d916
6f69718
be2d916
 
 
 
 
6f69718
be2d916
6f69718
 
be2d916
6f69718
be2d916
6f69718
be2d916
6f69718
be2d916
 
6f69718
 
 
be2d916
8950391
6f69718
be2d916
6f69718
be2d916
 
 
 
 
 
 
6f69718
be2d916
6f69718
be2d916
6f69718
be2d916
6f69718
be2d916
 
 
 
6f69718
be2d916
6f69718
be2d916
 
 
 
 
 
6f69718
be2d916
6f69718
be2d916
 
 
 
 
 
6f69718
be2d916
 
 
 
 
6f69718
be2d916
6f69718
be2d916
6f69718
be2d916
 
 
 
6f69718
be2d916
 
6f69718
be2d916
 
 
 
 
 
6f69718
be2d916
 
 
6f69718
be2d916
6f69718
be2d916
 
 
 
 
6f69718
be2d916
6f69718
be2d916
 
 
6f69718
be2d916
 
 
6f69718
be2d916
 
 
 
6f69718
be2d916
 
 
 
6f69718
be2d916
6f69718
be2d916
 
 
 
 
6f69718
be2d916
 
 
 
 
6f69718
be2d916
 
 
 
 
6f69718
be2d916
6f69718
be2d916
 
 
 
 
 
6f69718
be2d916
 
 
 
 
6f69718
be2d916
6f69718
be2d916
 
 
 
 
6f69718
be2d916
 
 
 
6f69718
be2d916
 
 
 
6f69718
be2d916
 
 
 
6f69718
be2d916
6f69718
be2d916
 
 
 
 
6f69718
be2d916
6f69718
be2d916
 
 
 
 
 
 
 
6f69718
 
 
be2d916
6f69718
be2d916
 
 
 
 
 
6f69718
be2d916
 
 
 
 
6f69718
be2d916
6f69718
be2d916
6f69718
be2d916
 
6f69718
be2d916
 
 
6f69718
be2d916
6f69718
be2d916
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6f69718
be2d916
 
 
 
6f69718
be2d916
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6f69718
be2d916
6f69718
be2d916
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
---
title: GlycoAI - AI-Powered Glucose Insights
emoji: 🩺
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 4.44.0
app_file: app.py
pinned: false
license: apache-2.0
tags:
  - agent-demo-track
  - diabetes
  - glucose-monitoring
  - healthcare-ai
  - medical-analysis
  - dexcom-api
  - mistral-ai
  - gradio
  - demo
---

# GlycoAI 🩺 - AI-Powered Glucose Insights

> **Transform your glucose data into actionable health insights with intelligent AI analysis**

[![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Gradio](https://img.shields.io/badge/Gradio-4.44.0-orange)](https://gradio.app/)
[![Agent Demo Track](https://img.shields.io/badge/Agent-Demo_Track-green)](https://huggingface.co/spaces)
[![Mistral AI](https://img.shields.io/badge/Powered_by-Mistral_AI-purple)](https://mistral.ai/)

## 🌟 Overview

GlycoAI is an advanced AI-powered application that analyzes continuous glucose monitoring (CGM) data to provide personalized diabetes management insights. Using state-of-the-art AI agents powered by Mistral AI, GlycoAI transforms complex glucose patterns into clear, actionable recommendations for better diabetes control.
🎯 Video demo: [deleted ](https://huggingface.co/spaces/Agents-MCP-Hackathon/GlycoAI/blob/main/GlycoAI%20Demo-v1.0.mp4)

### 🎯 Key Features

- **πŸ€– Intelligent AI Agent**: Conversational AI that understands glucose patterns and provides personalized insights
- **πŸ“Š Comprehensive Analysis**: 14-day glucose trend analysis with clinical metrics (Time in Range, GMI, CV)
- **🎭 Demo Users**: Four realistic patient profiles showcasing different glucose management scenarios
- **πŸ” Dexcom Integration**: OAuth-authenticated connection to Dexcom Sandbox API
- **πŸ“ˆ Interactive Visualizations**: Color-coded glucose charts with target range overlays
- **⚠️ Smart Notifications**: Real-time alerts for concerning glucose patterns
- **πŸ₯ Clinical Focus**: Evidence-based recommendations aligned with diabetes care standards

## πŸš€ Live Demo

**Try GlycoAI now:** [https://huggingface.co/spaces/your-username/glycoai](https://huggingface.co/spaces/your-username/glycoai)

### 🎭 Demo Users Available

1. **Sarah Thompson** - G7 Mobile - ⚠️ **Unstable Control** (Demonstrates crisis management)
2. **Marcus Rodriguez** - ONE+ Mobile - Type 2 Diabetes with Dawn Phenomenon
3. **Jennifer Chen** - G6 Mobile - Athletic lifestyle with excellent control
4. **Robert Williams** - G6 Receiver - Experienced user with good management

## πŸ› οΈ Technology Stack

- **Frontend**: Gradio 4.44.0 with custom CSS styling
- **AI Engine**: Mistral AI for intelligent glucose pattern analysis
- **Data Processing**: Pandas, NumPy for glucose data analysis
- **Visualization**: Plotly for interactive glucose charts
- **API Integration**: Dexcom API with OAuth 2.0 authentication
- **Deployment**: Hugging Face Spaces

## πŸ₯ Clinical Significance

### Metrics Analyzed
- **Time in Range (TIR)**: Target >70% (70-180 mg/dL)
- **Time Below Range (TBR)**: Target <4% (<70 mg/dL)
- **Time Above Range (TAR)**: Target <25% (>180 mg/dL)
- **Glucose Management Indicator (GMI)**: Estimated A1C
- **Coefficient of Variation (CV)**: Target <36% (glucose variability)

### AI Capabilities
- **Pattern Recognition**: Identifies dawn phenomenon, post-meal spikes, nocturnal hypoglycemia
- **Safety Prioritization**: Emphasizes hypoglycemia prevention and severe glucose excursions
- **Personalized Recommendations**: Tailored advice based on individual glucose patterns
- **Clinical Context**: Provides education on diabetes management principles

## πŸ”§ Installation & Setup

### For Local Development

```bash
# Clone the repository
git clone https://github.com/your-username/glycoai.git
cd glycoai

# Install dependencies
pip install -r requirements.txt

# Set up environment variables
cp .env.example .env
# Edit .env with your API keys:
# MISTRAL_API_KEY=your_mistral_api_key_here
# DEXCOM_CLIENT_ID=your_dexcom_client_id (optional)
# DEXCOM_CLIENT_SECRET=your_dexcom_client_secret (optional)

# Run the application
python app.py
```

### Environment Variables

| Variable | Description | Required |
|----------|-------------|----------|
| `MISTRAL_API_KEY` | Mistral AI API key for chat functionality | βœ… Yes |
| `DEXCOM_CLIENT_ID` | Dexcom developer client ID | ❌ Optional |
| `DEXCOM_CLIENT_SECRET` | Dexcom developer client secret | ❌ Optional |

## πŸ“– Usage Guide

### 1. **Select Data Source**
   - Choose from 4 demo users for instant testing
   - Or connect via Dexcom Sandbox OAuth (requires developer credentials)

### 2. **Load Glucose Data**
   - Click "Load 14-Day Glucose Data" button
   - Watch for notification indicating data quality and patterns

### 3. **Analyze with AI**
   - Navigate to "Chat with AI" tab
   - Click on suggested prompts or ask custom questions
   - Get personalized insights about glucose patterns

### 4. **Explore Visualizations**
   - View interactive 14-day glucose trends
   - Examine detailed statistics and clinical metrics
   - Understand time-in-range analysis

## 🎯 Use Cases

### For Healthcare Providers
- **Patient Education**: Explain glucose patterns in accessible language
- **Treatment Planning**: Identify areas for intervention
- **Progress Monitoring**: Track improvement over time
- **Clinical Documentation**: Generate insights for medical records

### For Patients & Caregivers
- **Self-Management**: Understand personal glucose patterns
- **Medication Timing**: Optimize treatment schedules
- **Lifestyle Adjustments**: Learn about food and exercise impacts
- **Safety Awareness**: Recognize dangerous patterns

### For Researchers & Developers
- **Algorithm Development**: Study glucose pattern recognition
- **AI Applications**: Explore conversational health AI
- **Data Analysis**: Understand CGM data processing
- **Clinical Decision Support**: Build evidence-based tools

## πŸ”¬ Technical Details

### Data Processing Pipeline
1. **Data Ingestion**: Accepts Dexcom API format or generates realistic mock data
2. **Preprocessing**: Validates timestamps, handles missing values, calculates trends
3. **Statistical Analysis**: Computes clinical metrics using standardized formulas
4. **Pattern Recognition**: Identifies glucose variability, meal responses, and anomalies
5. **AI Context Building**: Structures data for intelligent conversation

### AI Agent Architecture
- **Context Awareness**: Maintains conversation state with glucose data context
- **Clinical Knowledge**: Trained on diabetes management best practices
- **Safety Focus**: Prioritizes urgent recommendations for dangerous patterns
- **Personalization**: Adapts advice to individual glucose characteristics

## πŸ“Š Demo Scenarios

### Sarah Thompson - Crisis Management
- **Scenario**: Highly unstable glucose with frequent dangerous excursions
- **TIR**: ~45% (concerning)
- **CV**: ~52% (very high variability)
- **AI Response**: Urgent safety recommendations and healthcare provider consultation

### Marcus Rodriguez - Dawn Phenomenon
- **Scenario**: Type 2 diabetes with morning glucose elevation
- **Pattern**: Consistent 6-8 AM glucose rises
- **AI Response**: Medication timing optimization and morning routine adjustments

### Jennifer Chen - Athletic Lifestyle
- **Scenario**: Active individual with exercise-related glucose variations
- **Pattern**: Exercise-induced lows and recovery patterns
- **AI Response**: Pre/post-workout glucose management strategies

### Robert Williams - Experienced Management
- **Scenario**: Long-term diabetes with good overall control
- **Focus**: Fine-tuning and maintaining excellent management
- **AI Response**: Advanced optimization strategies and pattern maintenance

## πŸ›‘οΈ Privacy & Security

- **Data Processing**: All analysis performed in real-time, no permanent storage
- **API Security**: OAuth 2.0 authentication for Dexcom integration
- **Privacy by Design**: No personal health information retained between sessions
- **Compliance**: Designed with HIPAA principles in mind
- **Transparency**: Open-source approach for algorithm audibility

## ⚠️ Medical Disclaimer

**IMPORTANT**: GlycoAI is for informational and educational purposes only. This application:

- **IS NOT** a medical device or diagnostic tool
- **DOES NOT** replace professional medical advice
- **SHOULD NOT** be used for treatment decisions without healthcare provider consultation
- **REQUIRES** users to always consult their healthcare team before making management changes

Always follow your healthcare provider's guidance for diabetes management.

## 🀝 Contributing

We welcome contributions from the healthcare AI, diabetes technology, and open-source communities!

### Ways to Contribute
- πŸ› **Bug Reports**: Submit issues with detailed reproduction steps
- πŸ’‘ **Feature Requests**: Suggest new capabilities or improvements
- πŸ”§ **Code Contributions**: Submit pull requests with enhancements
- πŸ“š **Documentation**: Improve guides, examples, and explanations
- πŸ§ͺ **Testing**: Help validate algorithms with diverse glucose patterns

### Development Guidelines
- Follow clinical evidence-based recommendations
- Prioritize patient safety in all features
- Maintain code quality with comprehensive testing
- Document clinical rationale for algorithm decisions

## πŸ“œ License

This project is licensed under the **Apache License 2.0** - see the [LICENSE](LICENSE) file for details.

```
Copyright 2024 GlycoAI Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

## πŸ™ Acknowledgments

- **Mistral AI** for providing the intelligent conversation capabilities
- **Dexcom** for continuous glucose monitoring technology and API access
- **Diabetes Community** for inspiration and clinical insights
- **Open Source Community** for tools and frameworks that make this possible
- **Healthcare Providers** who guide evidence-based diabetes management

## πŸ“ž Support & Contact

- **Issues**: [GitHub Issues](https://github.com/your-username/glycoai/issues)
- **Discussions**: [GitHub Discussions](https://github.com/your-username/glycoai/discussions)
- **Documentation**: [Project Wiki](https://github.com/your-username/glycoai/wiki)
- **Email**: your-email@example.com

## πŸš€ Roadmap

### Upcoming Features
- **Multi-language Support**: Expand accessibility globally
- **Advanced Pattern Recognition**: Machine learning-based anomaly detection
- **Integration Expansion**: Support for additional CGM devices
- **Clinical Decision Support**: Enhanced recommendations for healthcare providers
- **Mobile Optimization**: Improved mobile device experience
- **API Development**: RESTful API for third-party integrations

### Research Directions
- **Federated Learning**: Privacy-preserving model improvements
- **Predictive Analytics**: Glucose forecasting capabilities
- **Behavioral Analysis**: Lifestyle factor correlation
- **Population Health**: Aggregate insights for public health

---

**Made with ❀️ for the diabetes community**

*Empowering better glucose management through intelligent AI analysis*