Spaces:
Running
Running
| """ | |
| LifeAdmin AI - Main Gradio Application | |
| Hackathon Project: Track 2 - MCP in Action | |
| Updated with LifeAdmin Coach chatbot tab | |
| """ | |
| import gradio as gr | |
| import asyncio | |
| import os | |
| from pathlib import Path | |
| from dotenv import load_dotenv | |
| # Load environment variables | |
| load_dotenv() | |
| from ui.manual_dashboard import create_manual_dashboard | |
| from ui.voice_agent_ui import create_voice_agent_ui | |
| from ui.lifeadmin_coach_ui import create_lifeadmin_coach_ui | |
| from agent.agent_core import LifeAdminAgent | |
| from utils.llm_utils import setup_llm_fallback | |
| # Initialize directories | |
| Path("data/uploads").mkdir(parents=True, exist_ok=True) | |
| Path("data/outputs").mkdir(parents=True, exist_ok=True) | |
| Path("data/chroma_db").mkdir(parents=True, exist_ok=True) | |
| print("π€ Initializing LifeAdmin AI Agent...") | |
| agent = LifeAdminAgent() | |
| print("β Agent initialized successfully!") | |
| # ------------------------------------------- | |
| # CUSTOM CSS | |
| # ------------------------------------------- | |
| custom_css = """ | |
| <style> | |
| /* Main container styling */ | |
| .gradio-container { | |
| font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; | |
| max-width: 1400px !important; | |
| } | |
| /* Header styling */ | |
| .header-container { | |
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); | |
| padding: 2rem; | |
| border-radius: 1rem; | |
| color: white; | |
| margin-bottom: 2rem; | |
| box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3); | |
| } | |
| .header-container h1 { | |
| margin: 0; | |
| font-size: 2.5rem; | |
| font-weight: 700; | |
| } | |
| .tool-card:hover { | |
| border-color: #667eea; | |
| transform: translateY(-2px); | |
| } | |
| .primary-button { | |
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important; | |
| color: white !important; | |
| } | |
| .footer { | |
| text-align: center; | |
| margin-top: 3rem; | |
| padding: 1.5rem; | |
| color: #718096; | |
| } | |
| </style> | |
| """ | |
| # --------------------------------------------------------- | |
| # Create Gradio App | |
| # --------------------------------------------------------- | |
| def create_app(): | |
| app = gr.Blocks( | |
| title="LifeAdmin AI - Your Autonomous Life Management Agent", | |
| analytics_enabled=False | |
| ) | |
| with app: | |
| gr.HTML(custom_css) | |
| # Header | |
| with gr.Row(): | |
| gr.HTML(""" | |
| <div class="header-container"> | |
| <h1>π€ LifeAdmin AI</h1> | |
| <p>Your Autonomous Life Management Agent</p> | |
| </div> | |
| """) | |
| # Tabs | |
| with gr.Tabs(): | |
| # Manual Dashboard | |
| with gr.Tab("π Manual Dashboard"): | |
| gr.Markdown("### π― Manual Mode β Full Control Over Tools") | |
| create_manual_dashboard(agent) | |
| # LifeAdmin Coach (NEW!) | |
| with gr.Tab("π¬ LifeAdmin Coach"): | |
| gr.Markdown("### π€ AI Assistant β Chat About Your Documents & Tasks") | |
| create_lifeadmin_coach_ui(agent) | |
| # Voice Agent | |
| with gr.Tab("π€ Voice Agent"): | |
| gr.Markdown("### π€ Voice Agent β Speak Commands, Agent Executes") | |
| create_voice_agent_ui(agent) | |
| # Footer | |
| gr.HTML(""" | |
| <div class="footer"> | |
| <p>π Hugging Face MCP Birthday Hackathon Submission</p> | |
| <p>Track 2: MCP in Action | Built with Gradio 6</p> | |
| </div> | |
| """) | |
| return app | |
| # --------------------------------------------------------- | |
| # MAIN ENTRY POINT | |
| # --------------------------------------------------------- | |
| if __name__ == "__main__": | |
| print("=" * 60) | |
| print("π Starting LifeAdmin AI") | |
| print("=" * 60) | |
| print("\nβοΈ Setting up LLM providers...") | |
| try: | |
| setup_llm_fallback() | |
| print("β LLM providers configured!") | |
| except Exception as e: | |
| print("β οΈ Warning:", e) | |
| print("\nπ€ Checking voice requirements...") | |
| print("β ElevenLabs API found" if os.getenv("ELEVENLABS_API_KEY") else "β οΈ Missing ElevenLabs") | |
| print("β Groq API found" if os.getenv("GROQ_API_KEY") else "β οΈ Missing Groq") | |
| print("\nπ¨ Creating Gradio interface...") | |
| app = create_app() | |
| print("\nβ LifeAdmin AI is ready!") | |
| print("π± Open: http://localhost:7860") | |
| app.launch( | |
| server_name="0.0.0.0", | |
| server_port=int(os.getenv("GRADIO_SERVER_PORT", 7860)), | |
| show_error=True | |
| ) |