File size: 4,228 Bytes
15d6f43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135bd9e
35491df
135bd9e
15d6f43
135bd9e
 
15d6f43
 
 
 
 
35491df
15d6f43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135bd9e
15d6f43
 
135bd9e
35491df
135bd9e
15d6f43
e4f07ae
15d6f43
 
e4f07ae
 
 
135bd9e
e4f07ae
35491df
15d6f43
 
35491df
 
 
 
15d6f43
e4f07ae
35491df
135bd9e
e4f07ae
135bd9e
 
 
15d6f43
e4f07ae
135bd9e
 
 
15d6f43
e4f07ae
135bd9e
 
35491df
e4f07ae
135bd9e
15d6f43
135bd9e
 
 
 
15d6f43
e4f07ae
15d6f43
 
 
135bd9e
 
 
15d6f43
 
 
 
135bd9e
 
15d6f43
 
135bd9e
15d6f43
35491df
135bd9e
 
35491df
 
135bd9e
15d6f43
 
135bd9e
15d6f43
135bd9e
 
35491df
15d6f43
 
 
35491df
135bd9e
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
"""
LifeAdmin AI - Main Gradio Application
Hackathon Project: Track 2 - MCP in Action
"""

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 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  (Injected manually)
# -------------------------------------------
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 (NO css= , NO theme= arguments)
# ---------------------------------------------------------
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)

            # Voice Agent
            with gr.Tab("🎀 Voice Agent"):
                gr.Markdown("### πŸ€– Voice Agent – Speak Commands, Agent Executes")
                create_voice_agent_ui(agent)

            # About
            with gr.Tab("ℹ️ About"):
                gr.Markdown("### About LifeAdmin AI\nDocumentation...")

        # 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")

    # ⭐ FIX: Removed invalid argument show_api
    app.launch(
        server_name="0.0.0.0",
        server_port=int(os.getenv("GRADIO_SERVER_PORT", 7860)),
        show_error=True
    )