bclermo's picture
Upload folder using huggingface_hub
f46d32a verified
Raw
History Blame Contribute Delete
9.24 kB
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()