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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
LifeAdmin AI - Main Gradio Application
|
| 3 |
+
Hackathon Project: Track 2 - MCP in Action
|
| 4 |
+
Hugging Face MCP Birthday Hackathon
|
| 5 |
+
|
| 6 |
+
An autonomous life management agent with real MCP tool servers,
|
| 7 |
+
RAG-enabled document search, and voice control.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
import gradio as gr
|
| 11 |
+
import asyncio
|
| 12 |
+
import os
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
from dotenv import load_dotenv
|
| 15 |
+
|
| 16 |
+
# Load environment variables
|
| 17 |
+
load_dotenv()
|
| 18 |
+
|
| 19 |
+
from ui.manual_dashboard import create_manual_dashboard
|
| 20 |
+
from ui.voice_agent_ui import create_voice_agent_ui
|
| 21 |
+
from agent.agent_core import LifeAdminAgent
|
| 22 |
+
from utils.llm_utils import setup_llm_fallback
|
| 23 |
+
|
| 24 |
+
# Initialize directories
|
| 25 |
+
Path("data/uploads").mkdir(parents=True, exist_ok=True)
|
| 26 |
+
Path("data/outputs").mkdir(parents=True, exist_ok=True)
|
| 27 |
+
Path("data/chroma_db").mkdir(parents=True, exist_ok=True)
|
| 28 |
+
|
| 29 |
+
# Initialize agent
|
| 30 |
+
print("π€ Initializing LifeAdmin AI Agent...")
|
| 31 |
+
agent = LifeAdminAgent()
|
| 32 |
+
print("β Agent initialized successfully!")
|
| 33 |
+
|
| 34 |
+
# Custom CSS for beautiful UI
|
| 35 |
+
custom_css = """
|
| 36 |
+
/* Main container styling */
|
| 37 |
+
.gradio-container {
|
| 38 |
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
| 39 |
+
max-width: 1400px !important;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/* Header styling */
|
| 43 |
+
.header-container {
|
| 44 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 45 |
+
padding: 2rem;
|
| 46 |
+
border-radius: 1rem;
|
| 47 |
+
color: white;
|
| 48 |
+
margin-bottom: 2rem;
|
| 49 |
+
box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
.header-container h1 {
|
| 53 |
+
margin: 0;
|
| 54 |
+
font-size: 2.5rem;
|
| 55 |
+
font-weight: 700;
|
| 56 |
+
text-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
.header-container p {
|
| 60 |
+
margin: 0.5rem 0 0 0;
|
| 61 |
+
opacity: 0.95;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
/* Tool card styling */
|
| 65 |
+
.tool-card {
|
| 66 |
+
border: 2px solid #e2e8f0;
|
| 67 |
+
border-radius: 0.75rem;
|
| 68 |
+
padding: 1.25rem;
|
| 69 |
+
transition: all 0.3s ease;
|
| 70 |
+
background: white;
|
| 71 |
+
margin: 0.5rem 0;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
.tool-card:hover {
|
| 75 |
+
border-color: #667eea;
|
| 76 |
+
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
|
| 77 |
+
transform: translateY(-2px);
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
/* Thought bubble styling */
|
| 81 |
+
.thought-bubble {
|
| 82 |
+
background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
|
| 83 |
+
border-left: 4px solid #667eea;
|
| 84 |
+
padding: 1rem;
|
| 85 |
+
margin: 0.75rem 0;
|
| 86 |
+
border-radius: 0.5rem;
|
| 87 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
/* Success banner */
|
| 91 |
+
.success-banner {
|
| 92 |
+
background: linear-gradient(135deg, #c6f6d5 0%, #9ae6b4 100%);
|
| 93 |
+
color: #22543d;
|
| 94 |
+
padding: 1rem;
|
| 95 |
+
border-radius: 0.5rem;
|
| 96 |
+
border-left: 4px solid #38a169;
|
| 97 |
+
font-weight: 500;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
/* Error banner */
|
| 101 |
+
.error-banner {
|
| 102 |
+
background: linear-gradient(135deg, #fed7d7 0%, #fc8181 100%);
|
| 103 |
+
color: #742a2a;
|
| 104 |
+
padding: 1rem;
|
| 105 |
+
border-radius: 0.5rem;
|
| 106 |
+
border-left: 4px solid #e53e3e;
|
| 107 |
+
font-weight: 500;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
/* Button styling */
|
| 111 |
+
.primary-button {
|
| 112 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
| 113 |
+
border: none !important;
|
| 114 |
+
color: white !important;
|
| 115 |
+
font-weight: 600 !important;
|
| 116 |
+
padding: 0.75rem 1.5rem !important;
|
| 117 |
+
border-radius: 0.5rem !important;
|
| 118 |
+
transition: all 0.3s ease !important;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
.primary-button:hover {
|
| 122 |
+
transform: translateY(-2px);
|
| 123 |
+
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4) !important;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
/* Tab styling */
|
| 127 |
+
.tab-nav button {
|
| 128 |
+
font-weight: 500 !important;
|
| 129 |
+
padding: 0.75rem 1.5rem !important;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
.tab-nav button.selected {
|
| 133 |
+
border-bottom: 3px solid #667eea !important;
|
| 134 |
+
color: #667eea !important;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
/* File upload area */
|
| 138 |
+
.upload-area {
|
| 139 |
+
border: 2px dashed #cbd5e0;
|
| 140 |
+
border-radius: 0.75rem;
|
| 141 |
+
padding: 2rem;
|
| 142 |
+
text-align: center;
|
| 143 |
+
transition: all 0.3s ease;
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
.upload-area:hover {
|
| 147 |
+
border-color: #667eea;
|
| 148 |
+
background: #f7fafc;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
/* Status indicator */
|
| 152 |
+
.status-indicator {
|
| 153 |
+
display: inline-block;
|
| 154 |
+
width: 10px;
|
| 155 |
+
height: 10px;
|
| 156 |
+
border-radius: 50%;
|
| 157 |
+
margin-right: 0.5rem;
|
| 158 |
+
animation: pulse 2s infinite;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
@keyframes pulse {
|
| 162 |
+
0%, 100% { opacity: 1; }
|
| 163 |
+
50% { opacity: 0.5; }
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
.status-active {
|
| 167 |
+
background: #48bb78;
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
.status-processing {
|
| 171 |
+
background: #ed8936;
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
.status-error {
|
| 175 |
+
background: #f56565;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
/* Footer styling */
|
| 179 |
+
.footer {
|
| 180 |
+
text-align: center;
|
| 181 |
+
margin-top: 3rem;
|
| 182 |
+
padding: 1.5rem;
|
| 183 |
+
border-top: 1px solid #e2e8f0;
|
| 184 |
+
color: #718096;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
/* Responsive adjustments */
|
| 188 |
+
@media (max-width: 768px) {
|
| 189 |
+
.header-container h1 {
|
| 190 |
+
font-size: 1.75rem;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
.gradio-container {
|
| 194 |
+
padding: 1rem;
|
| 195 |
+
}
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
/* Custom scrollbar */
|
| 199 |
+
::-webkit-scrollbar {
|
| 200 |
+
width: 8px;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
::-webkit-scrollbar-track {
|
| 204 |
+
background: #f1f1f1;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
::-webkit-scrollbar-thumb {
|
| 208 |
+
background: #667eea;
|
| 209 |
+
border-radius: 4px;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
::-webkit-scrollbar-thumb:hover {
|
| 213 |
+
background: #764ba2;
|
| 214 |
+
}
|
| 215 |
+
"""
|
| 216 |
+
|
| 217 |
+
def create_app():
|
| 218 |
+
"""Create and configure the Gradio application"""
|
| 219 |
+
|
| 220 |
+
with gr.Blocks(
|
| 221 |
+
theme=gr.themes.Soft(
|
| 222 |
+
primary_hue="purple",
|
| 223 |
+
secondary_hue="blue",
|
| 224 |
+
neutral_hue="slate",
|
| 225 |
+
font=[gr.themes.GoogleFont("Inter"), "system-ui", "sans-serif"],
|
| 226 |
+
),
|
| 227 |
+
css=custom_css,
|
| 228 |
+
title="LifeAdmin AI - Your Autonomous Life Management Agent",
|
| 229 |
+
analytics_enabled=False
|
| 230 |
+
) as app:
|
| 231 |
+
|
| 232 |
+
# Header
|
| 233 |
+
with gr.Row():
|
| 234 |
+
gr.HTML("""
|
| 235 |
+
<div class="header-container">
|
| 236 |
+
<h1>π€ LifeAdmin AI</h1>
|
| 237 |
+
<p style="font-size: 1.3rem; margin-top: 0.5rem;">
|
| 238 |
+
Your Autonomous Life Management Agent
|
| 239 |
+
</p>
|
| 240 |
+
<p style="font-size: 0.95rem; margin-top: 0.75rem; opacity: 0.9;">
|
| 241 |
+
Powered by 7 Real MCP Tool Servers β’ Built for Hugging Face Hackathon
|
| 242 |
+
</p>
|
| 243 |
+
<div style="margin-top: 1rem; display: flex; gap: 1.5rem; font-size: 0.9rem;">
|
| 244 |
+
<div style="display: flex; align-items: center; gap: 0.5rem;">
|
| 245 |
+
<span>β‘</span>
|
| 246 |
+
<span>Autonomous Execution</span>
|
| 247 |
+
</div>
|
| 248 |
+
<div style="display: flex; align-items: center; gap: 0.5rem;">
|
| 249 |
+
<span>π€</span>
|
| 250 |
+
<span>Voice Control</span>
|
| 251 |
+
</div>
|
| 252 |
+
<div style="display: flex; align-items: center; gap: 0.5rem;">
|
| 253 |
+
<span>π</span>
|
| 254 |
+
<span>RAG-Powered Search</span>
|
| 255 |
+
</div>
|
| 256 |
+
<div style="display: flex; align-items: center; gap: 0.5rem;">
|
| 257 |
+
<span>πΎ</span>
|
| 258 |
+
<span>Memory System</span>
|
| 259 |
+
</div>
|
| 260 |
+
</div>
|
| 261 |
+
</div>
|
| 262 |
+
""")
|
| 263 |
+
|
| 264 |
+
# Main tabs
|
| 265 |
+
with gr.Tabs() as tabs:
|
| 266 |
+
# Manual Dashboard Mode
|
| 267 |
+
with gr.Tab("π Manual Dashboard", id="manual"):
|
| 268 |
+
gr.Markdown("""
|
| 269 |
+
### π― Manual Mode
|
| 270 |
+
Upload files and use individual tools with full control over parameters and outputs.
|
| 271 |
+
Perfect for precise document processing and batch operations.
|
| 272 |
+
""")
|
| 273 |
+
create_manual_dashboard(agent)
|
| 274 |
+
|
| 275 |
+
# Voice Agent Mode
|
| 276 |
+
with gr.Tab("π€ Voice Agent", id="voice"):
|
| 277 |
+
gr.Markdown("""
|
| 278 |
+
### π€ Voice Agent Mode
|
| 279 |
+
Speak your commands and let the AI agent autonomously plan and execute tasks.
|
| 280 |
+
The agent will use multiple tools, manage context, and provide voice responses.
|
| 281 |
+
""")
|
| 282 |
+
create_voice_agent_ui(agent)
|
| 283 |
+
|
| 284 |
+
# About & Documentation
|
| 285 |
+
with gr.Tab("βΉοΈ About", id="about"):
|
| 286 |
+
gr.Markdown("""
|
| 287 |
+
# About LifeAdmin AI
|
| 288 |
+
|
| 289 |
+
## π― What is LifeAdmin AI?
|
| 290 |
+
|
| 291 |
+
LifeAdmin AI is an autonomous life management agent that helps you handle everyday administrative tasks through natural language and voice commands. Built for the **Hugging Face MCP Birthday Hackathon (Track 2: MCP in Action)**.
|
| 292 |
+
|
| 293 |
+
### Key Capabilities
|
| 294 |
+
|
| 295 |
+
- π **Document Processing**: OCR, summarization, metadata extraction
|
| 296 |
+
- π
**Calendar Management**: Automatic event creation from extracted dates
|
| 297 |
+
- βοΈ **Email Drafting**: Context-aware professional email generation
|
| 298 |
+
- π **Form Filling**: Auto-fill templates with extracted data
|
| 299 |
+
- ποΈ **File Organization**: Intelligent file classification and management
|
| 300 |
+
- π **Document Search**: RAG-powered semantic search across all documents
|
| 301 |
+
|
| 302 |
+
---
|
| 303 |
+
|
| 304 |
+
## ποΈ Architecture
|
| 305 |
+
|
| 306 |
+
### System Components
|
| 307 |
+
|
| 308 |
+
```
|
| 309 |
+
βββββββββββββββββββββββββββββββββββββββ
|
| 310 |
+
β Gradio 6 UI Layer β
|
| 311 |
+
β Manual Dashboard | Voice Agent β
|
| 312 |
+
βββββββββββββββββββββββββββββββββββββββ
|
| 313 |
+
β
|
| 314 |
+
βββββββββββββββββββββββββββββββββββββββ
|
| 315 |
+
β Autonomous Agent Core β
|
| 316 |
+
β Planning β Execution β Reflection β
|
| 317 |
+
βββββββββββββββββββββββββββββββββββββββ
|
| 318 |
+
β
|
| 319 |
+
βββββββββββββββββββββββββββββββββββββββ
|
| 320 |
+
β MCP Tool Servers (7) β
|
| 321 |
+
β OCR | PDF | Forms | Calendar β
|
| 322 |
+
β Email | Files | RAG Search β
|
| 323 |
+
βββββββββββββββββββββββββββββββββββββββ
|
| 324 |
+
β
|
| 325 |
+
βββββββββββββββββββββββββββββββββββββββ
|
| 326 |
+
β Supporting Infrastructure β
|
| 327 |
+
β RAG Engine | Memory | LLM Chain β
|
| 328 |
+
βββββββββββββββββββββββββββββββββββββββ
|
| 329 |
+
```
|
| 330 |
+
|
| 331 |
+
### MCP Tool Servers
|
| 332 |
+
|
| 333 |
+
1. **OCR Server** - Extract text from images and scanned documents
|
| 334 |
+
2. **PDF Server** - Summarize and analyze PDF documents
|
| 335 |
+
3. **Form Filler** - Auto-fill DOCX/XLSX templates
|
| 336 |
+
4. **Calendar Server** - Generate ICS calendar events
|
| 337 |
+
5. **Email Server** - Draft context-aware emails
|
| 338 |
+
6. **File Manager** - Organize and classify files
|
| 339 |
+
7. **RAG Server** - Semantic document search
|
| 340 |
+
|
| 341 |
+
---
|
| 342 |
+
|
| 343 |
+
## π How to Use
|
| 344 |
+
|
| 345 |
+
### Manual Mode
|
| 346 |
+
|
| 347 |
+
1. **Upload Documents**: Drag and drop PDFs, images, or documents
|
| 348 |
+
2. **Select Tool**: Choose from available tools (OCR, Summarize, etc.)
|
| 349 |
+
3. **Configure Parameters**: Set language, summary length, tone, etc.
|
| 350 |
+
4. **Execute**: Click the execute button to run the tool
|
| 351 |
+
5. **Download Results**: Save generated files (ICS, emails, forms)
|
| 352 |
+
|
| 353 |
+
### Voice Mode
|
| 354 |
+
|
| 355 |
+
1. **Click Microphone**: Start voice recording
|
| 356 |
+
2. **Speak Command**: Give a natural language instruction
|
| 357 |
+
3. **Agent Plans**: Watch the agent create an execution plan
|
| 358 |
+
4. **Auto-Execute**: Agent runs necessary tools autonomously
|
| 359 |
+
5. **Listen to Response**: Hear the results via text-to-speech
|
| 360 |
+
|
| 361 |
+
---
|
| 362 |
+
|
| 363 |
+
## π‘ Example Commands
|
| 364 |
+
|
| 365 |
+
### For Voice Agent
|
| 366 |
+
|
| 367 |
+
- *"Extract all deadlines from my PDFs and create calendar events"*
|
| 368 |
+
- *"Summarize this invoice and draft a dispute email"*
|
| 369 |
+
- *"Organize my receipts folder by date"*
|
| 370 |
+
- *"Find all documents mentioning Project X and summarize them"*
|
| 371 |
+
- *"Fill out this form using data from my uploaded documents"*
|
| 372 |
+
- *"Create a calendar event for tomorrow at 2 PM titled Team Meeting"*
|
| 373 |
+
|
| 374 |
+
### For Manual Mode
|
| 375 |
+
|
| 376 |
+
- Upload an invoice β Use OCR β Extract metadata β Create calendar event
|
| 377 |
+
- Upload multiple PDFs β Summarize each β Draft summary email
|
| 378 |
+
- Upload form template β Provide data β Generate filled form
|
| 379 |
+
|
| 380 |
+
---
|
| 381 |
+
|
| 382 |
+
## π οΈ Technical Stack
|
| 383 |
+
|
| 384 |
+
### Core Technologies
|
| 385 |
+
|
| 386 |
+
- **Framework**: Gradio 6 (latest features, metadata traces)
|
| 387 |
+
- **Agent**: Custom autonomous agent with planning & reflection
|
| 388 |
+
- **MCP**: Real JSONRPC-based tool servers
|
| 389 |
+
- **RAG**: ChromaDB + Sentence Transformers
|
| 390 |
+
- **Memory**: SQLite persistent storage
|
| 391 |
+
- **Voice**: ElevenLabs TTS + Groq Whisper STT
|
| 392 |
+
|
| 393 |
+
### LLM Providers (Fallback Chain)
|
| 394 |
+
|
| 395 |
+
1. OpenAI (GPT-4) - Best quality
|
| 396 |
+
2. Groq (Llama-3.3-70B) - Fast, recommended
|
| 397 |
+
3. Hyperbolic (Llama-3.3-70B) - Alternative
|
| 398 |
+
4. Hugging Face (Mixtral-8x7B) - Free fallback
|
| 399 |
+
|
| 400 |
+
### Document Processing
|
| 401 |
+
|
| 402 |
+
- **OCR**: EasyOCR, Tesseract
|
| 403 |
+
- **PDF**: PyPDF2, pdf2image
|
| 404 |
+
- **Forms**: python-docx, openpyxl
|
| 405 |
+
- **Calendar**: icalendar
|
| 406 |
+
|
| 407 |
+
---
|
| 408 |
+
|
| 409 |
+
## π Agent Workflow
|
| 410 |
+
|
| 411 |
+
### Three-Phase Autonomous Loop
|
| 412 |
+
|
| 413 |
+
**Phase 1: Planning**
|
| 414 |
+
- Analyze user request
|
| 415 |
+
- Query RAG for relevant context
|
| 416 |
+
- Check memory for user preferences
|
| 417 |
+
- Create step-by-step execution plan
|
| 418 |
+
- Select appropriate MCP tools
|
| 419 |
+
|
| 420 |
+
**Phase 2: Execution**
|
| 421 |
+
- Execute tasks sequentially
|
| 422 |
+
- Call MCP tools via JSONRPC
|
| 423 |
+
- Handle errors with retries
|
| 424 |
+
- Store intermediate results
|
| 425 |
+
- Update progress in UI
|
| 426 |
+
|
| 427 |
+
**Phase 3: Reflection**
|
| 428 |
+
- Review execution results
|
| 429 |
+
- Synthesize final answer
|
| 430 |
+
- Generate voice response (if voice mode)
|
| 431 |
+
- Update long-term memory
|
| 432 |
+
- Provide downloadable outputs
|
| 433 |
+
|
| 434 |
+
---
|
| 435 |
+
|
| 436 |
+
## π Hackathon Submission
|
| 437 |
+
|
| 438 |
+
**Event**: Hugging Face MCP Birthday Hackathon
|
| 439 |
+
**Track**: Track 2 - MCP in Action
|
| 440 |
+
**Features**:
|
| 441 |
+
- β
Real MCP tool servers (not mocked)
|
| 442 |
+
- β
Autonomous agent with planning
|
| 443 |
+
- β
RAG integration for context
|
| 444 |
+
- β
Voice control interface
|
| 445 |
+
- β
Production-ready deployment
|
| 446 |
+
- β
Comprehensive documentation
|
| 447 |
+
|
| 448 |
+
---
|
| 449 |
+
|
| 450 |
+
## π Resources
|
| 451 |
+
|
| 452 |
+
- [GitHub Repository](#) - Complete source code
|
| 453 |
+
- [Documentation](#) - Detailed setup guide
|
| 454 |
+
- [Demo Video](#) - 5-minute walkthrough
|
| 455 |
+
- [MCP Specification](https://modelcontextprotocol.io)
|
| 456 |
+
|
| 457 |
+
---
|
| 458 |
+
|
| 459 |
+
## π Privacy & Security
|
| 460 |
+
|
| 461 |
+
- **Local Processing**: All data processed locally by default
|
| 462 |
+
- **No Telemetry**: No usage tracking or data collection
|
| 463 |
+
- **Secure Storage**: Files stored locally in encrypted directories
|
| 464 |
+
- **API Keys**: Stored securely in environment variables
|
| 465 |
+
|
| 466 |
+
---
|
| 467 |
+
|
| 468 |
+
## π Acknowledgments
|
| 469 |
+
|
| 470 |
+
Built with amazing open-source tools:
|
| 471 |
+
- Gradio by Hugging Face
|
| 472 |
+
- Model Context Protocol by Anthropic
|
| 473 |
+
- ChromaDB for vector search
|
| 474 |
+
- ElevenLabs for voice synthesis
|
| 475 |
+
- Groq for fast inference
|
| 476 |
+
|
| 477 |
+
Special thanks to the Hugging Face and Anthropic teams for making this hackathon possible!
|
| 478 |
+
|
| 479 |
+
---
|
| 480 |
+
|
| 481 |
+
**Made with β€οΈ for the Hugging Face MCP Birthday Hackathon**
|
| 482 |
+
""")
|
| 483 |
+
|
| 484 |
+
# Footer
|
| 485 |
+
gr.HTML("""
|
| 486 |
+
<div class="footer">
|
| 487 |
+
<p style="font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem;">
|
| 488 |
+
π Hugging Face MCP Birthday Hackathon Submission
|
| 489 |
+
</p>
|
| 490 |
+
<p style="margin-bottom: 0.25rem;">
|
| 491 |
+
Track 2: MCP in Action | Built with Gradio 6 & Real MCP Tool Servers
|
| 492 |
+
</p>
|
| 493 |
+
<p style="font-size: 0.9rem; color: #a0aec0;">
|
| 494 |
+
Open Source β’ Production Ready β’ Fully Autonomous
|
| 495 |
+
</p>
|
| 496 |
+
</div>
|
| 497 |
+
""")
|
| 498 |
+
|
| 499 |
+
return app
|
| 500 |
+
|
| 501 |
+
|
| 502 |
+
if __name__ == "__main__":
|
| 503 |
+
print("=" * 60)
|
| 504 |
+
print("π Starting LifeAdmin AI")
|
| 505 |
+
print("=" * 60)
|
| 506 |
+
|
| 507 |
+
# Setup LLM fallback chain
|
| 508 |
+
print("\nβοΈ Setting up LLM providers...")
|
| 509 |
+
try:
|
| 510 |
+
setup_llm_fallback()
|
| 511 |
+
print("β LLM providers configured successfully!")
|
| 512 |
+
except Exception as e:
|
| 513 |
+
print(f"β οΈ Warning: {e}")
|
| 514 |
+
print(" Please set at least one API key (GROQ_API_KEY, OPENAI_API_KEY, etc.)")
|
| 515 |
+
|
| 516 |
+
# Check for voice mode requirements
|
| 517 |
+
print("\nπ€ Checking voice mode requirements...")
|
| 518 |
+
if os.getenv('ELEVENLABS_API_KEY'):
|
| 519 |
+
print("β ElevenLabs API key found (TTS enabled)")
|
| 520 |
+
else:
|
| 521 |
+
print("β οΈ ElevenLabs API key not found (voice output disabled)")
|
| 522 |
+
|
| 523 |
+
if os.getenv('GROQ_API_KEY'):
|
| 524 |
+
print("β Groq API key found (STT enabled)")
|
| 525 |
+
else:
|
| 526 |
+
print("β οΈ Groq API key not found (voice input disabled)")
|
| 527 |
+
|
| 528 |
+
# Create and launch app
|
| 529 |
+
print("\nπ¨ Creating Gradio interface...")
|
| 530 |
+
app = create_app()
|
| 531 |
+
|
| 532 |
+
print("\nβ
LifeAdmin AI is ready!")
|
| 533 |
+
print("=" * 60)
|
| 534 |
+
print("\nπ± Access the app at: http://localhost:7860")
|
| 535 |
+
print("\nπ‘ Tips:")
|
| 536 |
+
print(" - Use Manual Mode for precise control")
|
| 537 |
+
print(" - Use Voice Mode for autonomous execution")
|
| 538 |
+
print(" - Upload files to enable document-based commands")
|
| 539 |
+
print("\n" + "=" * 60 + "\n")
|
| 540 |
+
|
| 541 |
+
# Launch the application
|
| 542 |
+
app.launch(
|
| 543 |
+
server_name="0.0.0.0",
|
| 544 |
+
server_port=int(os.getenv("GRADIO_SERVER_PORT", 7860)),
|
| 545 |
+
share=False,
|
| 546 |
+
show_error=True,
|
| 547 |
+
show_api=False
|
| 548 |
+
)
|