Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -216,19 +216,23 @@ custom_css = """
|
|
| 216 |
|
| 217 |
def create_app():
|
| 218 |
"""Create and configure the Gradio application"""
|
| 219 |
-
|
| 220 |
-
|
| 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 |
-
)
|
| 231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
# Header
|
| 233 |
with gr.Row():
|
| 234 |
gr.HTML("""
|
|
@@ -260,228 +264,27 @@ def create_app():
|
|
| 260 |
</div>
|
| 261 |
</div>
|
| 262 |
""")
|
| 263 |
-
|
| 264 |
-
# Main tabs
|
| 265 |
with gr.Tabs() as tabs:
|
| 266 |
-
|
| 267 |
with gr.Tab("📊 Manual Dashboard", id="manual"):
|
| 268 |
gr.Markdown("""
|
| 269 |
### 🎯 Manual Mode
|
| 270 |
-
Upload files and use individual tools with full control
|
| 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
|
| 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 |
-
#
|
| 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;">
|
|
@@ -490,12 +293,9 @@ def create_app():
|
|
| 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 |
|
|
|
|
| 216 |
|
| 217 |
def create_app():
|
| 218 |
"""Create and configure the Gradio application"""
|
| 219 |
+
|
| 220 |
+
app = gr.Blocks(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
css=custom_css,
|
| 222 |
title="LifeAdmin AI - Your Autonomous Life Management Agent",
|
| 223 |
analytics_enabled=False
|
| 224 |
+
)
|
| 225 |
+
|
| 226 |
+
# Apply theme AFTER creation
|
| 227 |
+
app.theme = gr.themes.Soft(
|
| 228 |
+
primary_hue="purple",
|
| 229 |
+
secondary_hue="blue",
|
| 230 |
+
neutral_hue="slate",
|
| 231 |
+
font=[gr.themes.GoogleFont("Inter"), "system-ui", "sans-serif"],
|
| 232 |
+
)
|
| 233 |
+
|
| 234 |
+
with app:
|
| 235 |
+
|
| 236 |
# Header
|
| 237 |
with gr.Row():
|
| 238 |
gr.HTML("""
|
|
|
|
| 264 |
</div>
|
| 265 |
</div>
|
| 266 |
""")
|
| 267 |
+
|
|
|
|
| 268 |
with gr.Tabs() as tabs:
|
| 269 |
+
|
| 270 |
with gr.Tab("📊 Manual Dashboard", id="manual"):
|
| 271 |
gr.Markdown("""
|
| 272 |
### 🎯 Manual Mode
|
| 273 |
+
Upload files and use individual tools with full control.
|
|
|
|
| 274 |
""")
|
| 275 |
create_manual_dashboard(agent)
|
| 276 |
+
|
|
|
|
| 277 |
with gr.Tab("🎤 Voice Agent", id="voice"):
|
| 278 |
gr.Markdown("""
|
| 279 |
### 🤖 Voice Agent Mode
|
| 280 |
+
Speak commands. Agent auto-plans and executes tasks.
|
|
|
|
| 281 |
""")
|
| 282 |
create_voice_agent_ui(agent)
|
| 283 |
+
|
|
|
|
| 284 |
with gr.Tab("ℹ️ About", id="about"):
|
| 285 |
+
gr.Markdown("### About LifeAdmin AI ...")
|
| 286 |
+
# (your about text remains unchanged)
|
| 287 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
gr.HTML("""
|
| 289 |
<div class="footer">
|
| 290 |
<p style="font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem;">
|
|
|
|
| 293 |
<p style="margin-bottom: 0.25rem;">
|
| 294 |
Track 2: MCP in Action | Built with Gradio 6 & Real MCP Tool Servers
|
| 295 |
</p>
|
|
|
|
|
|
|
|
|
|
| 296 |
</div>
|
| 297 |
""")
|
| 298 |
+
|
| 299 |
return app
|
| 300 |
|
| 301 |
|