File size: 9,244 Bytes
f46d32a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import json
from datetime import datetime
import random

CSS = """
:root {
    --primary: #4f46e5;
    --bg: #0a0a0f;
    --surface: #12121a;
    --text: #f0f0f4;
    --accent: #818cf8;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--text); font-family: 'Inter', system-ui, sans-serif; }
.gradio-container { max-width: 1000px !important; margin: 0 auto; }
"""

AGENTS = [
    {"name": "Code Assistant", "icon": "πŸ’»", "status": "ready", "description": "Write, review, and refactor code"},
    {"name": "Data Analyst", "icon": "πŸ“Š", "status": "ready", "description": "Analyze data and generate insights"},
    {"name": "Research Bot", "icon": "πŸ”¬", "status": "ready", "description": "Research topics and summarize findings"},
    {"name": "Email Composer", "icon": "βœ‰οΈ", "status": "ready", "description": "Draft and refine email communications"},
    {"name": "Document Processor", "icon": "πŸ“„", "status": "beta", "description": "Extract and process document content"},
    {"name": "Task Scheduler", "icon": "πŸ“…", "status": "beta", "description": "Manage schedules and set reminders"},
]

def get_agent_status():
    return [{"name": a["name"], "icon": a["icon"], "status": a["status"]} for a in AGENTS]

def simulate_agent_response(agent_name: str, task: str):
    responses = {
        "Code Assistant": f"```python\n# Generated by {agent_name}\ndef solution():\n    # Analyzing: {task}\n    return \"Implementation complete\"\n```",
        "Data Analyst": f"πŸ“Š **Analysis Results**\n\nAnalyzed: {task}\n- Rows processed: {random.randint(1000, 50000):,}\n- Insights found: {random.randint(3, 12)}\n- Confidence: {random.uniform(85, 99):.1f}%",
        "Research Bot": f"πŸ”¬ **Research Summary**\n\nTopic: {task}\n- Sources reviewed: {random.randint(5, 25)}\n- Key findings: {random.randint(3, 8)}\n- Generated: {datetime.now().strftime('%Y-%m-%d %H:%M')}",
    }
    default = f"**{agent_name}** processing: _{task}_\n\nTask has been queued and will be processed locally on your device."
    return responses.get(agent_name, default)

def get_system_metrics():
    return {
        "cpu_usage": f"{random.uniform(10, 80):.1f}%",
        "memory_usage": f"{random.uniform(1, 8):.1f} GB",
        "active_agents": random.randint(1, 4),
        "tasks_completed": random.randint(50, 500),
        "uptime": f"{random.randint(1, 72)}h {random.randint(0, 59)}m",
        "local_model": "Raven AI Core v0.1.0",
        "privacy_mode": "βœ… Enabled (All processing local)",
    }

with gr.Blocks(css=CSS, title="Home for AI", theme=gr.themes.Soft(
    primary_hue="indigo",
    neutral_hue="slate",
)) as demo:
    gr.HTML("""
    <div style="text-align: center; padding: 2rem 0;">
        <div style="font-size: 4rem;">🏠</div>
        <h1 style="margin: 0.5rem 0; font-size: 2.5rem; background: linear-gradient(135deg, #4f46e5, #818cf8);
            -webkit-background-clip: text; -webkit-text-fill-color: transparent;">
            Home for AI
        </h1>
        <p style="font-size: 1.1rem; color: #a0a0b0; margin-top: 0;">
            Enterprise Desktop Operations Platform
        </p>
        <div style="display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; margin-top: 1rem;">
            <span style="background: #4f46e520; color: #818cf8; padding: 0.25rem 0.75rem; border-radius: 999px; font-size: 0.85rem;">Zero Trust</span>
            <span style="background: #4f46e520; color: #818cf8; padding: 0.25rem 0.75rem; border-radius: 999px; font-size: 0.85rem;">Local First</span>
            <span style="background: #4f46e520; color: #818cf8; padding: 0.25rem 0.75rem; border-radius: 999px; font-size: 0.85rem;">Cross Platform</span>
            <span style="background: #4f46e520; color: #818cf8; padding: 0.25rem 0.75rem; border-radius: 999px; font-size: 0.85rem;">Tauri + Rust</span>
        </div>
    </div>
    """)

    with gr.Tabs():
        with gr.Tab("πŸ€– Agent Hub"):
            gr.HTML("<h3>Available Agents</h3>")
            agent_grid = gr.HTML()
            refresh_btn = gr.Button("πŸ”„ Refresh Agents", variant="secondary")
            def render_agents():
                agents = get_agent_status()
                cards = "<div style='display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem;'>"
                for a in agents:
                    status_color = "#22c55e" if a["status"] == "ready" else "#fbbf24"
                    status_text = "Ready" if a["status"] == "ready" else "Beta"
                    cards += f"""
                    <div style="background: #12121a; border: 1px solid #2a2a3a; border-radius: 8px; padding: 1rem;">
                        <div style="font-size: 2rem;">{a["icon"]}</div>
                        <div style="font-weight: 600; margin: 0.5rem 0;">{a["name"]}</div>
                        <div style="color: {status_color}; font-size: 0.85rem;">● {status_text}</div>
                    </div>
                    """
                cards += "</div>"
                return cards
            refresh_btn.click(fn=render_agents, outputs=agent_grid)
            agent_grid.value = render_agents()

        with gr.Tab("πŸ’¬ Agent Chat"):
            agent_selector = gr.Dropdown(
                choices=[a["name"] for a in AGENTS],
                label="Select Agent",
                value="Code Assistant",
            )
            task_input = gr.Textbox(
                label="Describe your task",
                placeholder="e.g., Write a Python function to sort a list...",
                lines=3,
            )
            submit_btn = gr.Button("Run Task", variant="primary")
            agent_output = gr.Markdown(label="Agent Response")
            submit_btn.click(
                fn=simulate_agent_response,
                inputs=[agent_selector, task_input],
                outputs=agent_output,
            )

        with gr.Tab("πŸ“Š System Monitor"):
            metrics_btn = gr.Button("Refresh Metrics", variant="primary")
            metrics_output = gr.JSON(label="System Metrics")
            metrics_btn.click(fn=get_system_metrics, outputs=metrics_output)
            gr.HTML("""
            <div style="background: #12121a; border: 1px solid #2a2a3a; border-radius: 8px; padding: 1rem; margin-top: 1rem;">
                <h4>Privacy Notice</h4>
                <p style="color: #a0a0b0; font-size: 0.9rem;">
                    All processing happens locally on your device. No data leaves your machine.
                    Home for AI operates on a zero-trust architecture β€” your data, your compute.
                </p>
            </div>
            """)

        with gr.Tab("πŸ“± Download"):
            gr.HTML("""
            <div style="text-align: center; padding: 2rem 0;">
                <h3>Get Home for AI</h3>
                <div style="display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin: 2rem 0;">
                    <div style="background: #12121a; border: 1px solid #2a2a3a; border-radius: 12px; padding: 1.5rem; min-width: 180px;">
                        <div style="font-size: 2rem;">πŸͺŸ</div>
                        <h4>Windows</h4>
                        <p style="color: #a0a0b0; font-size: 0.85rem;">.exe installer</p>
                        <button disabled style="background: #4f46e5; color: white; border: none; padding: 0.5rem 1rem; border-radius: 6px; cursor: not-allowed;">Coming Soon</button>
                    </div>
                    <div style="background: #12121a; border: 1px solid #2a2a3a; border-radius: 12px; padding: 1.5rem; min-width: 180px;">
                        <div style="font-size: 2rem;">🍎</div>
                        <h4>macOS</h4>
                        <p style="color: #a0a0b0; font-size: 0.85rem;">.dmg installer</p>
                        <button disabled style="background: #4f46e5; color: white; border: none; padding: 0.5rem 1rem; border-radius: 6px; cursor: not-allowed;">Coming Soon</button>
                    </div>
                    <div style="background: #12121a; border: 1px solid #2a2a3a; border-radius: 12px; padding: 1.5rem; min-width: 180px;">
                        <div style="font-size: 2rem;">🐧</div>
                        <h4>Linux</h4>
                        <p style="color: #a0a0b0; font-size: 0.85rem;">.AppImage / .deb</p>
                        <button disabled style="background: #4f46e5; color: white; border: none; padding: 0.5rem 1rem; border-radius: 6px; cursor: not-allowed;">Coming Soon</button>
                    </div>
                </div>
                <p style="color: #a0a0b0; font-size: 0.9rem;">
                    <a href="https://github.com/simpliibarrii-crypto/home-for-ai" style="color: #818cf8;">GitHub Repository β†’</a>
                </p>
            </div>
            """)

    gr.HTML("""
    <div style="text-align: center; padding: 1.5rem 0; color: #6b6b80; font-size: 0.85rem; border-top: 1px solid #2a2a3a; margin-top: 2rem;">
        <p>Home for AI β€” Zero-Trust Desktop AI | <a href="https://github.com/simpliibarrii-crypto/home-for-ai" style="color: #818cf8;">GitHub</a></p>
    </div>
    """)

if __name__ == "__main__":
    demo.launch()