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---
|
| 7 |
+
# Extracted and adapted from the original HTML to fit Gradio 6
|
| 8 |
+
custom_css = """
|
| 9 |
+
/* --- CSS Variables & The Alchemical Palette --- */
|
| 10 |
+
:root {
|
| 11 |
+
--bg-deep: #050505;
|
| 12 |
+
--bg-panel: #0f1014;
|
| 13 |
+
--bg-glass: rgba(20, 20, 25, 0.7);
|
| 14 |
+
|
| 15 |
+
--primary: #8b5cf6; /* Electric Violet */
|
| 16 |
+
--secondary: #f59e0b; /* Amber Gold */
|
| 17 |
+
--accent: #10b981; /* Bioluminescent Green */
|
| 18 |
+
--danger: #ef4444;
|
| 19 |
+
|
| 20 |
+
--gradient-odyssey: linear-gradient(135deg, #4c1d95 0%, #8b5cf6 50%, #c084fc 100%);
|
| 21 |
+
--gradient-text: linear-gradient(to right, #c084fc, #f472b6);
|
| 22 |
+
|
| 23 |
+
--text-main: #f3f4f6;
|
| 24 |
+
--text-muted: #9ca3af;
|
| 25 |
+
|
| 26 |
+
--border: rgba(255, 255, 255, 0.08);
|
| 27 |
+
|
| 28 |
+
--font-head: 'Space Grotesk', 'Segoe UI', sans-serif;
|
| 29 |
+
--font-body: 'Inter', 'Segoe UI', sans-serif;
|
| 30 |
+
--font-code: 'Fira Code', 'Consolas', monospace;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
/* --- Global Overrides --- */
|
| 34 |
+
.gradio-container {
|
| 35 |
+
background-color: var(--bg-deep) !important;
|
| 36 |
+
color: var(--text-main) !important;
|
| 37 |
+
font-family: var(--font-body);
|
| 38 |
+
background-image:
|
| 39 |
+
radial-gradient(circle at 10% 20%, rgba(76, 29, 149, 0.15) 0%, transparent 40%),
|
| 40 |
+
radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 40%);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
/* --- Typography --- */
|
| 44 |
+
h1, h2, h3 {
|
| 45 |
+
font-family: var(--font-head);
|
| 46 |
+
color: var(--text-main);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/* --- Custom Header --- */
|
| 50 |
+
.cyber-header {
|
| 51 |
+
background: rgba(5, 5, 5, 0.8);
|
| 52 |
+
backdrop-filter: blur(12px);
|
| 53 |
+
border-bottom: 1px solid var(--border);
|
| 54 |
+
padding: 1rem 2rem;
|
| 55 |
+
display: flex;
|
| 56 |
+
justify-content: space-between;
|
| 57 |
+
align-items: center;
|
| 58 |
+
margin-bottom: 2rem;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
.brand {
|
| 62 |
+
display: flex;
|
| 63 |
+
align-items: center;
|
| 64 |
+
gap: 1rem;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
.brand h1 {
|
| 68 |
+
font-size: 1.4rem;
|
| 69 |
+
font-weight: 700;
|
| 70 |
+
background: var(--gradient-text);
|
| 71 |
+
-webkit-background-clip: text;
|
| 72 |
+
-webkit-text-fill-color: transparent;
|
| 73 |
+
text-transform: uppercase;
|
| 74 |
+
letter-spacing: 0.05em;
|
| 75 |
+
margin: 0;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/* --- Navigation Tabs --- */
|
| 79 |
+
.tabs {
|
| 80 |
+
border: none !important;
|
| 81 |
+
background: transparent !important;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
.tab-nav {
|
| 85 |
+
display: flex !important;
|
| 86 |
+
gap: 0.5rem;
|
| 87 |
+
background: var(--bg-glass);
|
| 88 |
+
backdrop-filter: blur(16px);
|
| 89 |
+
border: 1px solid var(--border);
|
| 90 |
+
border-radius: 12px;
|
| 91 |
+
padding: 0.5rem;
|
| 92 |
+
margin-bottom: 2rem;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
.tabitem {
|
| 96 |
+
border-radius: 8px !important;
|
| 97 |
+
color: var(--text-muted) !important;
|
| 98 |
+
font-family: var(--font-head) !important;
|
| 99 |
+
font-weight: 600 !important;
|
| 100 |
+
border: none !important;
|
| 101 |
+
background: transparent !important;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
.tabitem:hover {
|
| 105 |
+
color: var(--text-main) !important;
|
| 106 |
+
background: rgba(255, 255, 255, 0.03) !important;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
.tabitem[aria-selected="true"] {
|
| 110 |
+
background: var(--primary) !important;
|
| 111 |
+
color: white !important;
|
| 112 |
+
box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
/* --- Components Styling --- */
|
| 116 |
+
.cyber-card {
|
| 117 |
+
background: var(--bg-panel);
|
| 118 |
+
border: 1px solid var(--border);
|
| 119 |
+
border-radius: 16px;
|
| 120 |
+
padding: 1.5rem;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
/* Inputs */
|
| 124 |
+
input, textarea, select {
|
| 125 |
+
background: rgba(0, 0, 0, 0.3) !important;
|
| 126 |
+
border: 1px solid var(--border) !important;
|
| 127 |
+
color: var(--text-main) !important;
|
| 128 |
+
border-radius: 4px !important;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
/* Buttons */
|
| 132 |
+
.cyber-btn-primary {
|
| 133 |
+
background: var(--gradient-odyssey) !important;
|
| 134 |
+
color: white !important;
|
| 135 |
+
border: 1px solid rgba(139, 92, 246, 0.3) !important;
|
| 136 |
+
transition: all 0.2s;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
.cyber-btn-primary:hover {
|
| 140 |
+
transform: translateY(-2px);
|
| 141 |
+
box-shadow: 0 0 25px rgba(139, 92, 246, 0.6);
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
.cyber-btn-secondary {
|
| 145 |
+
background: transparent !important;
|
| 146 |
+
border: 1px solid var(--border) !important;
|
| 147 |
+
color: var(--text-main) !important;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
/* Code Editor */
|
| 151 |
+
ace_editor {
|
| 152 |
+
border: 1px solid var(--border) !important;
|
| 153 |
+
border-radius: 8px !important;
|
| 154 |
+
background: #0d0d0d !important;
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
/* Terminal Output */
|
| 158 |
+
.terminal-output {
|
| 159 |
+
background: #0a0a0a;
|
| 160 |
+
border: 1px solid var(--border);
|
| 161 |
+
border-radius: 8px;
|
| 162 |
+
font-family: var(--font-code);
|
| 163 |
+
font-size: 0.85rem;
|
| 164 |
+
min-height: 200px;
|
| 165 |
+
max-height: 400px;
|
| 166 |
+
overflow-y: auto;
|
| 167 |
+
padding: 1rem;
|
| 168 |
+
color: #d1d5db;
|
| 169 |
+
white-space: pre-wrap;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
.log-entry {
|
| 173 |
+
margin-bottom: 0.5rem;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
.log-info { color: #3b82f6; }
|
| 177 |
+
.log-success { color: var(--accent); }
|
| 178 |
+
.log-warn { color: var(--secondary); }
|
| 179 |
+
|
| 180 |
+
/* Footer */
|
| 181 |
+
footer {
|
| 182 |
+
margin-top: 2rem;
|
| 183 |
+
padding: 2rem;
|
| 184 |
+
border-top: 1px solid var(--border);
|
| 185 |
+
text-align: center;
|
| 186 |
+
color: var(--text-muted);
|
| 187 |
+
font-size: 0.85rem;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
footer a {
|
| 191 |
+
color: var(--primary);
|
| 192 |
+
text-decoration: none;
|
| 193 |
+
}
|
| 194 |
+
"""
|
| 195 |
+
|
| 196 |
+
# --- The Python Logic: The Living Manifesto ---
|
| 197 |
+
|
| 198 |
+
def run_analysis(action_type: str, code: str, model: str, language: str):
|
| 199 |
+
"""
|
| 200 |
+
Simulates the AI processing with a touch of 'Cyber-Noir' flair.
|
| 201 |
+
"""
|
| 202 |
+
if not code:
|
| 203 |
+
return gr.Warning("The forge is empty. Provide some source material."), "", ""
|
| 204 |
+
|
| 205 |
+
logs = []
|
| 206 |
+
logs.append(f"[{time.strftime('%H:%M:%S')}] INITIATING {action_type.upper()} SEQUENCE...")
|
| 207 |
+
logs.append(f"[{time.strftime('%H:%M:%S')}] MODEL: {model.upper()} // LANGUAGE: {language.upper()}")
|
| 208 |
+
time.sleep(0.5) # Simulate thinking
|
| 209 |
+
|
| 210 |
+
if action_type == "analyze":
|
| 211 |
+
logs.append("[SYSTEM] Scanning syntax trees...")
|
| 212 |
+
logs.append("[SYSTEM] Detecting entropy levels...")
|
| 213 |
+
time.sleep(0.5)
|
| 214 |
+
logs.append("[SUCCESS] Analysis complete. Structure integrity: 98.4%")
|
| 215 |
+
artifact = f"# Analysis Report for {language}\n# Generated by {model}\n\n1. Complexity: Moderate\n2. Security: Standard\n3. Optimization: Potential found in loop 4."
|
| 216 |
+
|
| 217 |
+
elif action_type == "optimize":
|
| 218 |
+
logs.append("[SYSTEM] Refactoring logic gates...")
|
| 219 |
+
logs.append("[SYSTEM] Compressing redundant data structures...")
|
| 220 |
+
time.sleep(0.8)
|
| 221 |
+
logs.append("[SUCCESS] Optimization applied. Efficiency gain: +15%")
|
| 222 |
+
artifact = code + "\n\n# --- OPTIMIZED ---\n# AI Optimizations Applied"
|
| 223 |
+
|
| 224 |
+
elif action_type == "secure":
|
| 225 |
+
logs.append("[SYSTEM] Scanning for vulnerabilities...")
|
| 226 |
+
logs.append("[SYSTEM] Patching injection vectors...")
|
| 227 |
+
time.sleep(0.6)
|
| 228 |
+
logs.append("[SUCCESS] Security audit passed. Firewall active.")
|
| 229 |
+
artifact = code + "\n\n# --- SECURED ---\n# Input validation added."
|
| 230 |
+
|
| 231 |
+
log_output = "\n".join(logs)
|
| 232 |
+
return gr.Info(f"{action_type.capitalize()} complete."), log_output, artifact
|
| 233 |
+
|
| 234 |
+
def create_project(name: str, framework: str, desc: str):
|
| 235 |
+
"""Incepts a new project into the system."""
|
| 236 |
+
if not name:
|
| 237 |
+
return gr.Warning("Project designation required."), None
|
| 238 |
+
|
| 239 |
+
project_data = {
|
| 240 |
+
"name": name,
|
| 241 |
+
"framework": framework,
|
| 242 |
+
"status": "Initializing...",
|
| 243 |
+
"created_at": time.strftime("%Y-%m-%d %H:%M")
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
html_card = f"""
|
| 247 |
+
<div style="background: rgba(255,255,255,0.05); border: 1px solid var(--border); padding: 1rem; border-radius: 8px; margin-bottom: 0.5rem; display: flex; justify-content: space-between; align-items: center;">
|
| 248 |
+
<div>
|
| 249 |
+
<div style="font-weight: 700; color: white;">{name}</div>
|
| 250 |
+
<div style="font-size: 0.8rem; color: var(--text-muted);">{framework} • {project_data['created_at']}</div>
|
| 251 |
+
</div>
|
| 252 |
+
<div style="color: var(--accent); font-size: 0.8rem; font-family: monospace;">ACTIVE</div>
|
| 253 |
+
</div>
|
| 254 |
+
"""
|
| 255 |
+
|
| 256 |
+
return gr.Info(f"Project '{name}' initialized."), html_card
|
| 257 |
+
|
| 258 |
+
def get_analytics_html():
|
| 259 |
+
"""Returns the Cyber-Noir Analytics Dashboard."""
|
| 260 |
+
return f"""
|
| 261 |
+
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; margin-bottom: 2rem;">
|
| 262 |
+
<div class="cyber-card" style="border-left: 3px solid var(--primary);">
|
| 263 |
+
<div style="color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase;">Compute</div>
|
| 264 |
+
<div style="font-size: 2.5rem; font-weight: 700; color: var(--primary);">98.4%</div>
|
| 265 |
+
</div>
|
| 266 |
+
<div class="cyber-card" style="border-left: 3px solid var(--secondary);">
|
| 267 |
+
<div style="color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase;">Requests</div>
|
| 268 |
+
<div style="font-size: 2.5rem; font-weight: 700; color: var(--secondary);">2.4M</div>
|
| 269 |
+
</div>
|
| 270 |
+
<div class="cyber-card" style="border-left: 3px solid var(--accent);">
|
| 271 |
+
<div style="color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase;">Latency</div>
|
| 272 |
+
<div style="font-size: 2.5rem; font-weight: 700; color: var(--accent);">12ms</div>
|
| 273 |
+
</div>
|
| 274 |
+
<div class="cyber-card" style="border-left: 3px solid white;">
|
| 275 |
+
<div style="color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase;">Uptime</div>
|
| 276 |
+
<div style="font-size: 2.5rem; font-weight: 700; color: white;">99.99%</div>
|
| 277 |
+
</div>
|
| 278 |
+
</div>
|
| 279 |
+
|
| 280 |
+
<h3 style="margin-bottom: 1rem;">Model Performance Metrics</h3>
|
| 281 |
+
<div style="background: var(--bg-panel); padding: 1.5rem; border-radius: 12px; border: 1px solid var(--border);">
|
| 282 |
+
<div style="margin-bottom: 1rem;">
|
| 283 |
+
<div style="display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.25rem;">
|
| 284 |
+
<span>GPT-4 Turbo</span><span>98%</span>
|
| 285 |
+
</div>
|
| 286 |
+
<div style="height: 6px; background: #1f2937; border-radius: 3px; overflow: hidden;">
|
| 287 |
+
<div style="height: 100%; background: var(--primary); width: 98%;"></div>
|
| 288 |
+
</div>
|
| 289 |
+
</div>
|
| 290 |
+
<div style="margin-bottom: 1rem;">
|
| 291 |
+
<div style="display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.25rem;">
|
| 292 |
+
<span>Claude 3 Opus</span><span>95%</span>
|
| 293 |
+
</div>
|
| 294 |
+
<div style="height: 6px; background: #1f2937; border-radius: 3px; overflow: hidden;">
|
| 295 |
+
<div style="height: 100%; background: var(--secondary); width: 95%;"></div>
|
| 296 |
+
</div>
|
| 297 |
+
</div>
|
| 298 |
+
<div>
|
| 299 |
+
<div style="display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.25rem;">
|
| 300 |
+
<span>DeepSeek Coder</span><span>92%</span>
|
| 301 |
+
</div>
|
| 302 |
+
<div style="height: 6px; background: #1f2937; border-radius: 3px; overflow: hidden;">
|
| 303 |
+
<div style="height: 100%; background: var(--accent); width: 92%;"></div>
|
| 304 |
+
</div>
|
| 305 |
+
</div>
|
| 306 |
+
</div>
|
| 307 |
+
"""
|
| 308 |
+
|
| 309 |
+
def get_team_html():
|
| 310 |
+
"""Returns the Collective Operatives Grid."""
|
| 311 |
+
return """
|
| 312 |
+
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem;">
|
| 313 |
+
<div class="cyber-card" style="display: flex; align-items: center; gap: 1rem;">
|
| 314 |
+
<div style="width: 48px; height: 48px; border-radius: 50%; background: var(--gradient-odyssey); display: flex; align-items: center; justify-content: center; font-weight: 700; color: white;">A</div>
|
| 315 |
+
<div>
|
| 316 |
+
<div style="font-weight: 700; color: white;">Admin Prime</div>
|
| 317 |
+
<div style="font-size: 0.8rem; color: var(--accent);">Architect • Online</div>
|
| 318 |
+
</div>
|
| 319 |
+
</div>
|
| 320 |
+
<div class="cyber-card" style="display: flex; align-items: center; gap: 1rem;">
|
| 321 |
+
<div style="width: 48px; height: 48px; border-radius: 50%; background: #333; border: 2px solid var(--secondary); display: flex; align-items: center; justify-content: center; font-weight: 700; color: white;">JS</div>
|
| 322 |
+
<div>
|
| 323 |
+
<div style="font-weight: 700; color: white;">Janus Smith</div>
|
| 324 |
+
<div style="font-size: 0.8rem; color: var(--text-muted);">Engineer • Away</div>
|
| 325 |
+
</div>
|
| 326 |
+
</div>
|
| 327 |
+
<div class="cyber-card" style="display: flex; align-items: center; gap: 1rem;">
|
| 328 |
+
<div style="width: 48px; height: 48px; border-radius: 50%; background: #333; border: 2px solid var(--danger); display: flex; align-items: center; justify-content: center; font-weight: 700; color: white;">MK</div>
|
| 329 |
+
<div>
|
| 330 |
+
<div style="font-weight: 700; color: white;">Mike K.</div>
|
| 331 |
+
<div style="font-size: 0.8rem; color: var(--text-muted);">Security • Offline</div>
|
| 332 |
+
</div>
|
| 333 |
+
</div>
|
| 334 |
+
</div>
|
| 335 |
+
"""
|
| 336 |
+
|
| 337 |
+
# --- The Gradio 6 Application ---
|
| 338 |
+
|
| 339 |
+
with gr.Blocks() as demo:
|
| 340 |
+
# Header
|
| 341 |
+
gr.HTML("""
|
| 342 |
+
<div class="cyber-header">
|
| 343 |
+
<div class="brand">
|
| 344 |
+
<i class="fas fa-cube fa-lg" style="color: var(--primary);"></i>
|
| 345 |
+
<div>
|
| 346 |
+
<h1>Studio Engine</h1>
|
| 347 |
+
<span style="font-size: 0.7rem; font-family: monospace; color: var(--text-muted); border: 1px solid var(--border); padding: 2px 6px; border-radius: 4px;">v3.0 OMEGA</span>
|
| 348 |
+
</div>
|
| 349 |
+
</div>
|
| 350 |
+
<div style="display: flex; align-items: center; gap: 1rem;">
|
| 351 |
+
<div style="display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: var(--accent); font-family: monospace;">
|
| 352 |
+
<div style="width: 6px; height: 6px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 8px var(--accent);"></div>
|
| 353 |
+
<span>SYSTEM OPTIMAL</span>
|
| 354 |
+
</div>
|
| 355 |
+
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" style="color: var(--primary); text-decoration: none; font-size: 0.85rem; border: 1px solid var(--border); padding: 0.4rem 0.8rem; border-radius: 4px; transition: all 0.3s;" onmouseover="this.style.borderColor='var(--primary)'" onmouseout="this.style.borderColor='var(--border)'">Built with anycoder</a>
|
| 356 |
+
</div>
|
| 357 |
+
</div>
|
| 358 |
+
""")
|
| 359 |
+
|
| 360 |
+
# Navigation Tabs
|
| 361 |
+
with gr.Tabs() as tabs:
|
| 362 |
+
# --- TAB 1: Code Forge ---
|
| 363 |
+
with gr.Tab("Code Forge", id="studio"):
|
| 364 |
+
with gr.Row():
|
| 365 |
+
# Input Column
|
| 366 |
+
with gr.Column(scale=3):
|
| 367 |
+
code_editor = gr.Code(
|
| 368 |
+
label="Source Code",
|
| 369 |
+
language="python",
|
| 370 |
+
value="# Begin your odyssey here...\ndef hello_world():\n print('Hello, Digital Wilderness.')",
|
| 371 |
+
interactive=True,
|
| 372 |
+
lines=20,
|
| 373 |
+
elem_classes=["cyber-card"]
|
| 374 |
+
)
|
| 375 |
+
|
| 376 |
+
with gr.Row():
|
| 377 |
+
language = gr.Dropdown(
|
| 378 |
+
choices=["python", "javascript", "rust", "html"],
|
| 379 |
+
value="python",
|
| 380 |
+
label="Language",
|
| 381 |
+
scale=1
|
| 382 |
+
)
|
| 383 |
+
ai_model = gr.Dropdown(
|
| 384 |
+
choices=["GPT-4 Turbo", "Claude 3 Opus", "DeepSeek Coder V2"],
|
| 385 |
+
value="GPT-4 Turbo",
|
| 386 |
+
label="AI Model",
|
| 387 |
+
scale=2
|
| 388 |
+
)
|
| 389 |
+
|
| 390 |
+
with gr.Row():
|
| 391 |
+
btn_analyze = gr.Button("Analyze", variant="primary", scale=2, elem_classes=["cyber-btn-primary"])
|
| 392 |
+
btn_optimize = gr.Button("Optimize", scale=1, elem_classes=["cyber-btn-secondary"])
|
| 393 |
+
btn_secure = gr.Button("Secure", scale=1, elem_classes=["cyber-btn-secondary"])
|
| 394 |
+
|
| 395 |
+
# Output Column
|
| 396 |
+
with gr.Column(scale=2):
|
| 397 |
+
terminal_output = gr.Textbox(
|
| 398 |
+
label="Output Stream",
|
| 399 |
+
value="[SYSTEM] Ready for input. Awaiting quantum synchronization...",
|
| 400 |
+
lines=10,
|
| 401 |
+
interactive=False,
|
| 402 |
+
elem_classes=["terminal-output"]
|
| 403 |
+
)
|
| 404 |
+
|
| 405 |
+
artifact_output = gr.Code(
|
| 406 |
+
label="Processed Artifact",
|
| 407 |
+
language="python",
|
| 408 |
+
value="// Results manifest here...",
|
| 409 |
+
interactive=False,
|
| 410 |
+
lines=10,
|
| 411 |
+
elem_classes=["cyber-card"]
|
| 412 |
+
)
|
| 413 |
+
|
| 414 |
+
# --- TAB 2: Projects ---
|
| 415 |
+
with gr.Tab("Projects", id="projects"):
|
| 416 |
+
with gr.Row():
|
| 417 |
+
with gr.Column(scale=1):
|
| 418 |
+
gr.Markdown("### Incept Project")
|
| 419 |
+
proj_name = gr.Textbox(label="Project Designation", placeholder="e.g. Project Ouroboros")
|
| 420 |
+
proj_template = gr.Dropdown(
|
| 421 |
+
label="Framework",
|
| 422 |
+
choices=["Next.js Enterprise", "Go Microservice", "Python Library"]
|
| 423 |
+
)
|
| 424 |
+
proj_desc = gr.Textbox(label="Manifest", lines=4, placeholder="Describe the architecture...")
|
| 425 |
+
btn_create = gr.Button("Initialize", variant="primary", elem_classes=["cyber-btn-primary"])
|
| 426 |
+
|
| 427 |
+
with gr.Column(scale=1):
|
| 428 |
+
gr.Markdown("### Active Operations")
|
| 429 |
+
project_list = gr.HTML(value='<div style="text-align: center; padding-top: 4rem; color: var(--text-muted);"><i class="fas fa-cube fa-3x" style="margin-bottom: 1rem; opacity: 0.2;"></i><p>No active constructs found.</p></div>')
|
| 430 |
+
|
| 431 |
+
# --- TAB 3: Analytics ---
|
| 432 |
+
with gr.Tab("Analytics", id="analytics"):
|
| 433 |
+
analytics_view = gr.HTML(value=get_analytics_html())
|
| 434 |
+
|
| 435 |
+
# --- TAB 4: Team ---
|
| 436 |
+
with gr.Tab("Collective", id="team"):
|
| 437 |
+
team_view = gr.HTML(value=get_team_html())
|
| 438 |
+
|
| 439 |
+
# --- Footer ---
|
| 440 |
+
gr.HTML("""
|
| 441 |
+
<footer>
|
| 442 |
+
<p>© 2026 Studio Workflow Engine Enterprise. The Alchemical Fusion.</p>
|
| 443 |
+
</footer>
|
| 444 |
+
""")
|
| 445 |
+
|
| 446 |
+
# --- Event Listeners ---
|
| 447 |
+
|
| 448 |
+
# Language change updates code editor language
|
| 449 |
+
language.change(lambda l: gr.Code(language=l), language, code_editor)
|
| 450 |
+
|
| 451 |
+
# Code Forge Actions
|
| 452 |
+
btn_analyze.click(
|
| 453 |
+
fn=run_analysis,
|
| 454 |
+
inputs=[gr.State("analyze"), code_editor, ai_model, language],
|
| 455 |
+
outputs=[terminal_output, terminal_output, artifact_output],
|
| 456 |
+
api_visibility="public"
|
| 457 |
+
)
|
| 458 |
+
|
| 459 |
+
btn_optimize.click(
|
| 460 |
+
fn=run_analysis,
|
| 461 |
+
inputs=[gr.State("optimize"), code_editor, ai_model, language],
|
| 462 |
+
outputs=[terminal_output, terminal_output, artifact_output],
|
| 463 |
+
api_visibility="public"
|
| 464 |
+
)
|
| 465 |
+
|
| 466 |
+
btn_secure.click(
|
| 467 |
+
fn=run_analysis,
|
| 468 |
+
inputs=[gr.State("secure"), code_editor, ai_model, language],
|
| 469 |
+
outputs=[terminal_output, terminal_output, artifact_output],
|
| 470 |
+
api_visibility="public"
|
| 471 |
+
)
|
| 472 |
+
|
| 473 |
+
# Project Creation
|
| 474 |
+
btn_create.click(
|
| 475 |
+
fn=create_project,
|
| 476 |
+
inputs=[proj_name, proj_template, proj_desc],
|
| 477 |
+
outputs=[terminal_output, project_list],
|
| 478 |
+
api_visibility="public"
|
| 479 |
+
)
|
| 480 |
+
|
| 481 |
+
# --- Launch: The Grand Unveiling ---
|
| 482 |
+
demo.launch(
|
| 483 |
+
theme=gr.themes.Base(),
|
| 484 |
+
css=custom_css,
|
| 485 |
+
footer_links=[{"label": "Built with anycoder", "url": "https://huggingface.co/spaces/akhaliq/anycoder"}]
|
| 486 |
+
)
|