Spaces:
Running
Running
Update app.py from anycoder
Browse files
app.py
CHANGED
|
@@ -2,139 +2,177 @@ import gradio as gr
|
|
| 2 |
import time
|
| 3 |
import random
|
| 4 |
|
| 5 |
-
# --- THE ALCHEMICAL PALETTE (CSS) ---
|
| 6 |
-
#
|
| 7 |
custom_css = """
|
| 8 |
/* --- CSS Variables: The Elements of Change --- */
|
| 9 |
:root {
|
| 10 |
/* The Deep Void */
|
| 11 |
-
--bg-deep: #
|
| 12 |
-
--bg-panel:
|
| 13 |
|
| 14 |
-
/* Prince's Legacy
|
| 15 |
--prince-dark: #2e1065;
|
| 16 |
--prince-main: #7c3aed;
|
| 17 |
--prince-light: #c084fc;
|
| 18 |
--prince-pink: #f472b6;
|
| 19 |
|
| 20 |
-
/* Wu-Tang Gold
|
| 21 |
--wu-gold: #fbbf24;
|
| 22 |
--wu-amber: #d97706;
|
| 23 |
|
| 24 |
-
/* Attenborough's Green
|
| 25 |
--nature-green: #10b981;
|
| 26 |
--nature-glow: #34d399;
|
| 27 |
|
| 28 |
/* Typography */
|
| 29 |
-
--font-display: 'Cinzel', serif;
|
| 30 |
--font-tech: 'Space Grotesk', sans-serif;
|
| 31 |
-
--font-funk: 'Rye', serif;
|
| 32 |
|
| 33 |
-
/*
|
| 34 |
-
--border-glass: rgba(255, 255, 255, 0.
|
| 35 |
-
--glow-purple: 0 0 20px rgba(124, 58, 237, 0.
|
| 36 |
-
--glow-gold: 0 0 15px rgba(251, 191, 36, 0.
|
|
|
|
| 37 |
}
|
| 38 |
|
| 39 |
-
/* --- Global Atmosphere --- */
|
| 40 |
.gradio-container {
|
| 41 |
background-color: var(--bg-deep) !important;
|
| 42 |
color: #f3f4f6 !important;
|
| 43 |
font-family: var(--font-tech);
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
}
|
| 50 |
|
| 51 |
-
/* ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
h1, h2, h3 {
|
| 53 |
font-family: var(--font-display) !important;
|
| 54 |
text-transform: uppercase;
|
| 55 |
letter-spacing: 0.1em;
|
| 56 |
}
|
| 57 |
|
| 58 |
-
|
| 59 |
-
.odyssey-header {
|
| 60 |
-
background: linear-gradient(90deg, rgba(46, 16, 101, 0.9), rgba(5, 5, 5, 0.95));
|
| 61 |
-
border-bottom: 2px solid var(--prince-main);
|
| 62 |
-
padding: 1.5rem 2rem;
|
| 63 |
-
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
|
| 64 |
position: relative;
|
| 65 |
-
|
| 66 |
}
|
| 67 |
|
| 68 |
-
.
|
| 69 |
-
content:
|
| 70 |
position: absolute;
|
| 71 |
top: 0;
|
| 72 |
left: 0;
|
| 73 |
width: 100%;
|
| 74 |
-
height:
|
| 75 |
-
background: linear-gradient(90deg, var(--wu-gold), var(--prince-pink), var(--nature-green));
|
| 76 |
-
animation: flow 5s linear infinite;
|
| 77 |
}
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
| 82 |
}
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
|
|
|
| 88 |
}
|
| 89 |
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
border-radius: 4px;
|
| 96 |
-
padding: 0.5rem;
|
| 97 |
-
backdrop-filter: blur(10px);
|
| 98 |
}
|
| 99 |
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
text-transform: uppercase;
|
| 106 |
-
letter-spacing: 1px;
|
| 107 |
-
border: 1px solid transparent !important;
|
| 108 |
-
transition: all 0.3s ease;
|
| 109 |
}
|
| 110 |
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
border-
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
}
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
}
|
| 125 |
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
-
/* The Code Editor
|
| 129 |
.ace_editor {
|
| 130 |
border: 1px solid var(--border-glass) !important;
|
| 131 |
border-radius: 8px !important;
|
| 132 |
-
background:
|
| 133 |
font-family: 'Fira Code', monospace !important;
|
| 134 |
-
box-shadow:
|
| 135 |
}
|
| 136 |
|
| 137 |
-
/* Buttons:
|
| 138 |
.prince-btn {
|
| 139 |
background: linear-gradient(135deg, var(--prince-dark), var(--prince-main)) !important;
|
| 140 |
color: white !important;
|
|
@@ -142,12 +180,12 @@ h1, h2, h3 {
|
|
| 142 |
text-transform: uppercase;
|
| 143 |
font-weight: 700;
|
| 144 |
letter-spacing: 1px;
|
| 145 |
-
transition:
|
| 146 |
}
|
| 147 |
|
| 148 |
.prince-btn:hover {
|
| 149 |
-
transform: scale(1.02);
|
| 150 |
-
box-shadow: 0
|
| 151 |
}
|
| 152 |
|
| 153 |
.wu-btn {
|
|
@@ -156,59 +194,81 @@ h1, h2, h3 {
|
|
| 156 |
border: 2px solid var(--wu-gold) !important;
|
| 157 |
font-family: var(--font-funk) !important;
|
| 158 |
text-shadow: 0 0 5px var(--wu-amber);
|
|
|
|
| 159 |
}
|
| 160 |
|
| 161 |
.wu-btn:hover {
|
| 162 |
background: var(--wu-gold) !important;
|
| 163 |
color: black !important;
|
| 164 |
-
box-shadow: var(--
|
|
|
|
| 165 |
}
|
| 166 |
|
| 167 |
-
/* The Terminal (The Log of the Journey) */
|
| 168 |
-
.terminal-log {
|
| 169 |
-
background: #000000 !important;
|
| 170 |
-
border: 1px solid var(--border-glass) !important;
|
| 171 |
-
border-left: 3px solid var(--nature-green);
|
| 172 |
-
font-family: 'Fira Code', monospace;
|
| 173 |
-
color: #d1d5db;
|
| 174 |
-
padding: 1rem;
|
| 175 |
-
border-radius: 4px;
|
| 176 |
-
min-height: 250px;
|
| 177 |
-
white-space: pre-wrap;
|
| 178 |
-
box-shadow: inset 0 0 30px rgba(16, 185, 129, 0.05);
|
| 179 |
-
}
|
| 180 |
-
|
| 181 |
-
.log-prince { color: var(--prince-pink); font-style: italic; }
|
| 182 |
-
.log-wu { color: var(--wu-gold); font-weight: bold; text-transform: uppercase; }
|
| 183 |
-
.log-nature { color: var(--nature-green); }
|
| 184 |
-
.log-system { color: #6b7280; }
|
| 185 |
-
|
| 186 |
-
/* The Cards (The Habitats) */
|
| 187 |
.cyber-card {
|
| 188 |
background: rgba(20, 20, 25, 0.6);
|
| 189 |
-
backdrop-filter: blur(
|
| 190 |
border: 1px solid var(--border-glass);
|
| 191 |
border-radius: 12px;
|
| 192 |
padding: 1.5rem;
|
| 193 |
-
transition:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
}
|
| 195 |
|
| 196 |
.cyber-card:hover {
|
| 197 |
border-color: var(--prince-main);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
}
|
| 199 |
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
animation: glitter 3s linear infinite;
|
| 208 |
}
|
| 209 |
|
| 210 |
-
@keyframes
|
| 211 |
-
|
|
|
|
|
|
|
| 212 |
}
|
| 213 |
"""
|
| 214 |
|
|
@@ -216,112 +276,105 @@ h1, h2, h3 {
|
|
| 216 |
|
| 217 |
def run_odyssey(action_type: str, code: str, model: str, language: str):
|
| 218 |
"""
|
| 219 |
-
The core processor.
|
| 220 |
"""
|
| 221 |
if not code:
|
| 222 |
gr.Warning("The canvas is blank, darling. Paint something first.")
|
| 223 |
-
return "[SYSTEM] ERROR: No input detected
|
| 224 |
|
| 225 |
logs = []
|
| 226 |
-
logs.append(f"[SYSTEM] INITIATING SEQUENCE: {action_type.upper()}
|
| 227 |
-
logs.append(f"[SYSTEM] MODEL: {model} // LANGUAGE: {language.upper()}
|
| 228 |
|
| 229 |
-
# Simulate processing
|
| 230 |
-
time.sleep(random.uniform(0.
|
| 231 |
|
| 232 |
if action_type == "analyze":
|
| 233 |
-
|
| 234 |
-
logs.append("[NATURE]
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
logs.append("[NATURE] A delicate balance of logic and entropy. Structure integrity: 98.4%.")
|
| 238 |
result = f"# Analysis Report: The Digital Species\n# Habitat: {language}\n# Observer: {model}\n\n1. Behavior: Predictable yet elegant.\n2. Diet: Consumes memory efficiently.\n3. Status: Thriving in the compiler."
|
| 239 |
-
gr.Info("Analysis complete.
|
| 240 |
|
| 241 |
elif action_type == "optimize":
|
| 242 |
-
|
| 243 |
-
logs.append(
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
gr.Info("The Purple Rain Remix is ready to drop.")
|
| 249 |
|
| 250 |
elif action_type == "secure":
|
| 251 |
-
|
| 252 |
-
logs.append("[WU-TANG]
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
result = code + "\n\n# --- WU-TANG SECURITY PROTOCOL ---\n# 36 Chambers of Defense activated.\n# No weak links in the chain."
|
| 257 |
gr.Info("Protect Ya Neck! Security protocols active.")
|
| 258 |
|
| 259 |
-
log_output = "
|
| 260 |
return log_output, result
|
| 261 |
|
| 262 |
def create_habitat(name: str, framework: str, desc: str):
|
| 263 |
"""Founding a new ecosystem."""
|
| 264 |
if not name:
|
| 265 |
-
|
| 266 |
-
return '<div style="text-align: center; padding: 4rem; color: var(--text-muted); opacity: 0.5;"><h3>Error</h3><p>Name required for genesis.</p></div>'
|
| 267 |
|
| 268 |
-
# Generative HTML for the new project
|
| 269 |
card = f"""
|
| 270 |
-
<div style="
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
position: relative;
|
| 276 |
-
overflow: hidden;">
|
| 277 |
-
<div style="position: absolute; top: 0; right: 0; background: var(--wu-gold); color: black; font-size: 0.7rem; padding: 2px 8px; font-weight: bold;">NEW</div>
|
| 278 |
-
<div style="font-family: var(--font-display); font-size: 1.2rem; color: var(--prince-light); margin-bottom: 0.5rem;">{name}</div>
|
| 279 |
-
<div style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0.5rem;">Framework: <span style="color: var(--nature-green);">{framework}</span></div>
|
| 280 |
-
<div style="font-style: italic; color: #9ca3af; font-size: 0.85rem;">"{desc}"</div>
|
| 281 |
</div>
|
| 282 |
"""
|
| 283 |
-
|
| 284 |
-
gr.Info(f"Habitat '{name}' established in the digital wild.")
|
| 285 |
return card
|
| 286 |
|
| 287 |
-
# --- THE GRADIO 6 APP
|
| 288 |
|
| 289 |
-
# Gradio 6 Syntax: gr.Blocks() takes NO parameters
|
| 290 |
with gr.Blocks() as demo:
|
| 291 |
|
| 292 |
-
#
|
| 293 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 294 |
<div class="odyssey-header">
|
| 295 |
<div style="display: flex; flex-direction: column; gap: 0.5rem;">
|
| 296 |
-
<h1 class="
|
| 297 |
-
<div style="display: flex; gap: 2rem; align-items: center;">
|
| 298 |
-
<span style="color: var(--nature-green); font-family: 'Fira Code', monospace;">
|
| 299 |
-
<span style="color: var(--wu-gold); font-family: var(--font-funk);">
|
| 300 |
-
<span style="color: var(--prince-pink); font-style: italic;">"Let's go crazy"</span>
|
| 301 |
</div>
|
| 302 |
</div>
|
| 303 |
<div style="text-align: right;">
|
| 304 |
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank"
|
| 305 |
-
style="background: var(--
|
| 306 |
text-decoration: none; font-weight: bold; border-radius: 4px;
|
| 307 |
-
font-family: var(--font-
|
| 308 |
-
onmouseover="this.style.
|
| 309 |
-
onmouseout="this.style.
|
| 310 |
Built with anycoder
|
| 311 |
</a>
|
| 312 |
</div>
|
| 313 |
</div>
|
| 314 |
""")
|
| 315 |
|
| 316 |
-
# NAVIGATION
|
| 317 |
with gr.Tabs() as tabs:
|
| 318 |
|
| 319 |
-
# --- CHAMBER 1: THE FORGE
|
| 320 |
with gr.Tab("The Forge", id="forge"):
|
| 321 |
with gr.Row():
|
| 322 |
with gr.Column(scale=3):
|
| 323 |
-
gr.Markdown("### **
|
| 324 |
-
gr.Markdown("*Paint your logic
|
| 325 |
|
| 326 |
code_editor = gr.Code(
|
| 327 |
label="Source Material",
|
|
@@ -336,30 +389,25 @@ with gr.Blocks() as demo:
|
|
| 336 |
lang_select = gr.Dropdown(
|
| 337 |
choices=["python", "javascript", "rust", "typescript", "go"],
|
| 338 |
value="python",
|
| 339 |
-
label="Dialect
|
| 340 |
scale=1
|
| 341 |
)
|
| 342 |
model_select = gr.Dropdown(
|
| 343 |
choices=["GPT-4 Omni (The Architect)", "Claude 3.5 Sonnet (The Poet)", "Llama 3 (The Rebel)"],
|
| 344 |
value="GPT-4 Omni (The Architect)",
|
| 345 |
-
label="
|
| 346 |
scale=2
|
| 347 |
)
|
| 348 |
|
| 349 |
with gr.Row():
|
| 350 |
btn_analyze = gr.Button("Inspect Species", variant="primary", scale=1, elem_classes=["wu-btn"])
|
| 351 |
-
btn_evolve = gr.Button("
|
| 352 |
btn_secure = gr.Button("Protect Ya Neck", scale=1, elem_classes=["wu-btn"])
|
| 353 |
|
| 354 |
with gr.Column(scale=2):
|
| 355 |
-
gr.Markdown("### **
|
| 356 |
-
terminal = gr.
|
| 357 |
-
|
| 358 |
-
value="[SYSTEM] The Odyssey Engine is online. Awaiting input...",
|
| 359 |
-
lines=12,
|
| 360 |
-
interactive=False,
|
| 361 |
-
elem_classes=["terminal-log"],
|
| 362 |
-
show_label=False
|
| 363 |
)
|
| 364 |
|
| 365 |
artifact = gr.Code(
|
|
@@ -371,7 +419,7 @@ with gr.Blocks() as demo:
|
|
| 371 |
elem_classes=["cyber-card"]
|
| 372 |
)
|
| 373 |
|
| 374 |
-
# --- CHAMBER 2: THE HABITATS
|
| 375 |
with gr.Tab("The Habitats", id="habitats"):
|
| 376 |
gr.Markdown("### **Found New Ecosystems**")
|
| 377 |
with gr.Row():
|
|
@@ -387,51 +435,51 @@ with gr.Blocks() as demo:
|
|
| 387 |
with gr.Column(scale=1):
|
| 388 |
gr.Markdown("### **Active Lifeforms**")
|
| 389 |
habitats_display = gr.HTML(
|
| 390 |
-
value='<div style="text-align: center; padding: 4rem;
|
| 391 |
)
|
| 392 |
|
| 393 |
-
# --- CHAMBER 3:
|
| 394 |
with gr.Tab("C.R.E.A.M. Metrics", id="cream"):
|
| 395 |
gr.HTML("""
|
| 396 |
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin-bottom: 2rem;">
|
| 397 |
<div class="cyber-card" style="border-top: 4px solid var(--prince-main);">
|
| 398 |
-
<div style="color:
|
| 399 |
-
<div style="font-size:
|
| 400 |
-
<div style="font-size: 0.8rem; color: var(--prince-pink);">Efficiency:
|
| 401 |
</div>
|
| 402 |
<div class="cyber-card" style="border-top: 4px solid var(--wu-gold);">
|
| 403 |
-
<div style="color:
|
| 404 |
-
<div style="font-size:
|
| 405 |
<div style="font-size: 0.8rem; color: var(--wu-amber);">Dolla dolla bill, y'all</div>
|
| 406 |
</div>
|
| 407 |
<div class="cyber-card" style="border-top: 4px solid var(--nature-green);">
|
| 408 |
-
<div style="color:
|
| 409 |
-
<div style="font-size:
|
| 410 |
<div style="font-size: 0.8rem; color: var(--nature-glow);">Bioluminescent</div>
|
| 411 |
</div>
|
| 412 |
</div>
|
| 413 |
""")
|
| 414 |
|
| 415 |
-
# --- CHAMBER 4: THE CLAN
|
| 416 |
with gr.Tab("The Clan", id="clan"):
|
| 417 |
gr.HTML("""
|
| 418 |
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem;">
|
| 419 |
<div class="cyber-card" style="display: flex; align-items: center; gap: 1rem; border-left: 4px solid var(--prince-main);">
|
| 420 |
-
<div style="width: 50px; height: 50px; border-radius: 50%; background: var(--prince-dark); display: flex; align-items: center; justify-content: center; font-weight: bold; color: var(--prince-pink); font-size: 1.2rem;">P</div>
|
| 421 |
<div>
|
| 422 |
<div style="font-weight: bold; font-family: var(--font-display);">The Architect</div>
|
| 423 |
<div style="font-size: 0.8rem; color: var(--prince-light);">Visionary • Online</div>
|
| 424 |
</div>
|
| 425 |
</div>
|
| 426 |
<div class="cyber-card" style="display: flex; align-items: center; gap: 1rem; border-left: 4px solid var(--wu-gold);">
|
| 427 |
-
<div style="width: 50px; height: 50px; border-radius: 50%; background: #222; display: flex; align-items: center; justify-content: center; font-weight: bold; color: var(--wu-gold); font-size: 1.2rem;">M</div>
|
| 428 |
<div>
|
| 429 |
<div style="font-weight: bold; font-family: var(--font-funk);">Method Man</div>
|
| 430 |
<div style="font-size: 0.8rem; color: var(--wu-amber);">Deployment • Smokin'</div>
|
| 431 |
</div>
|
| 432 |
</div>
|
| 433 |
<div class="cyber-card" style="display: flex; align-items: center; gap: 1rem; border-left: 4px solid var(--nature-green);">
|
| 434 |
-
<div style="width: 50px; height: 50px; border-radius: 50%; background: #022c22; display: flex; align-items: center; justify-content: center; font-weight: bold; color: var(--nature-green); font-size: 1.2rem;">G</div>
|
| 435 |
<div>
|
| 436 |
<div style="font-weight: bold; font-family: var(--font-display);">The Guardian</div>
|
| 437 |
<div style="font-size: 0.8rem; color: var(--nature-glow);">Security • Watchful</div>
|
|
@@ -442,18 +490,18 @@ with gr.Blocks() as demo:
|
|
| 442 |
|
| 443 |
# FOOTER
|
| 444 |
gr.HTML("""
|
| 445 |
-
<div style="margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border-glass); text-align: center; color:
|
| 446 |
<p>© 2026 THE ODYSSEY ENGINE. <span style="color: var(--prince-pink);">Code is the canvas.</span> <span style="color: var(--wu-gold);">Creativity is the color.</span></p>
|
| 447 |
</div>
|
| 448 |
""")
|
| 449 |
|
| 450 |
-
# --- EVENT LISTENERS
|
| 451 |
|
| 452 |
# Dynamic Language Switching
|
| 453 |
lang_select.change(lambda l: gr.Code(language=l), lang_select, code_editor)
|
| 454 |
|
| 455 |
# The Forge Actions
|
| 456 |
-
#
|
| 457 |
btn_analyze.click(
|
| 458 |
fn=run_odyssey,
|
| 459 |
inputs=[gr.State("analyze"), code_editor, model_select, lang_select],
|
|
@@ -483,9 +531,143 @@ with gr.Blocks() as demo:
|
|
| 483 |
api_visibility="public"
|
| 484 |
)
|
| 485 |
|
| 486 |
-
# ---
|
| 487 |
-
|
| 488 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 489 |
custom_head = """
|
| 490 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 491 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
@@ -493,8 +675,9 @@ custom_head = """
|
|
| 493 |
"""
|
| 494 |
|
| 495 |
demo.launch(
|
| 496 |
-
theme=gr.themes.Base(),
|
| 497 |
css=custom_css,
|
|
|
|
| 498 |
head=custom_head,
|
| 499 |
footer_links=[{"label": "Built with anycoder", "url": "https://huggingface.co/spaces/akhaliq/anycoder"}]
|
| 500 |
)
|
|
|
|
| 2 |
import time
|
| 3 |
import random
|
| 4 |
|
| 5 |
+
# --- THE ALCHEMICAL PALETTE v4.0 (CSS) ---
|
| 6 |
+
# Enhanced for the "Dreamscape" aesthetic
|
| 7 |
custom_css = """
|
| 8 |
/* --- CSS Variables: The Elements of Change --- */
|
| 9 |
:root {
|
| 10 |
/* The Deep Void */
|
| 11 |
+
--bg-deep: #020204;
|
| 12 |
+
--bg-panel: rgba(15, 15, 19, 0.7);
|
| 13 |
|
| 14 |
+
/* Prince's Legacy */
|
| 15 |
--prince-dark: #2e1065;
|
| 16 |
--prince-main: #7c3aed;
|
| 17 |
--prince-light: #c084fc;
|
| 18 |
--prince-pink: #f472b6;
|
| 19 |
|
| 20 |
+
/* Wu-Tang Gold */
|
| 21 |
--wu-gold: #fbbf24;
|
| 22 |
--wu-amber: #d97706;
|
| 23 |
|
| 24 |
+
/* Attenborough's Green */
|
| 25 |
--nature-green: #10b981;
|
| 26 |
--nature-glow: #34d399;
|
| 27 |
|
| 28 |
/* Typography */
|
| 29 |
+
--font-display: 'Cinzel', serif;
|
| 30 |
--font-tech: 'Space Grotesk', sans-serif;
|
| 31 |
+
--font-funk: 'Rye', serif;
|
| 32 |
|
| 33 |
+
/* Effects */
|
| 34 |
+
--border-glass: rgba(255, 255, 255, 0.08);
|
| 35 |
+
--glow-purple: 0 0 20px rgba(124, 58, 237, 0.6);
|
| 36 |
+
--glow-gold: 0 0 15px rgba(251, 191, 36, 0.5);
|
| 37 |
+
--scanline-color: rgba(0, 0, 0, 0.5);
|
| 38 |
}
|
| 39 |
|
| 40 |
+
/* --- Global Atmosphere & Dreamscape --- */
|
| 41 |
.gradio-container {
|
| 42 |
background-color: var(--bg-deep) !important;
|
| 43 |
color: #f3f4f6 !important;
|
| 44 |
font-family: var(--font-tech);
|
| 45 |
+
overflow-x: hidden;
|
| 46 |
+
position: relative;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/* The Neural Network Canvas Background */
|
| 50 |
+
#dreamscape-canvas {
|
| 51 |
+
position: fixed;
|
| 52 |
+
top: 0;
|
| 53 |
+
left: 0;
|
| 54 |
+
width: 100%;
|
| 55 |
+
height: 100%;
|
| 56 |
+
z-index: -1;
|
| 57 |
+
pointer-events: none; /* Let clicks pass through */
|
| 58 |
}
|
| 59 |
|
| 60 |
+
/* --- CRT Scanline Effect Overlay --- */
|
| 61 |
+
.crt-overlay {
|
| 62 |
+
position: fixed;
|
| 63 |
+
top: 0;
|
| 64 |
+
left: 0;
|
| 65 |
+
width: 100vw;
|
| 66 |
+
height: 100vh;
|
| 67 |
+
background: linear-gradient(
|
| 68 |
+
rgba(18, 16, 16, 0) 50%,
|
| 69 |
+
rgba(0, 0, 0, 0.25) 50%
|
| 70 |
+
), linear-gradient(
|
| 71 |
+
90deg,
|
| 72 |
+
rgba(255, 0, 0, 0.06),
|
| 73 |
+
rgba(0, 255, 0, 0.02),
|
| 74 |
+
rgba(0, 0, 255, 0.06)
|
| 75 |
+
);
|
| 76 |
+
background-size: 100% 2px, 3px 100%;
|
| 77 |
+
z-index: 9999;
|
| 78 |
+
pointer-events: none;
|
| 79 |
+
opacity: 0.15;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/* --- Typography & Glitch Effects --- */
|
| 83 |
h1, h2, h3 {
|
| 84 |
font-family: var(--font-display) !important;
|
| 85 |
text-transform: uppercase;
|
| 86 |
letter-spacing: 0.1em;
|
| 87 |
}
|
| 88 |
|
| 89 |
+
.glitch-text {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
position: relative;
|
| 91 |
+
animation: glitch-skew 3s infinite linear alternate-reverse;
|
| 92 |
}
|
| 93 |
|
| 94 |
+
.glitch-text::before, .glitch-text::after {
|
| 95 |
+
content: attr(data-text);
|
| 96 |
position: absolute;
|
| 97 |
top: 0;
|
| 98 |
left: 0;
|
| 99 |
width: 100%;
|
| 100 |
+
height: 100%;
|
|
|
|
|
|
|
| 101 |
}
|
| 102 |
|
| 103 |
+
.glitch-text::before {
|
| 104 |
+
left: 2px;
|
| 105 |
+
text-shadow: -1px 0 var(--prince-pink);
|
| 106 |
+
clip: rect(44px, 450px, 56px, 0);
|
| 107 |
+
animation: glitch-anim 5s infinite linear alternate-reverse;
|
| 108 |
}
|
| 109 |
|
| 110 |
+
.glitch-text::after {
|
| 111 |
+
left: -2px;
|
| 112 |
+
text-shadow: -1px 0 var(--wu-gold);
|
| 113 |
+
clip: rect(44px, 450px, 56px, 0);
|
| 114 |
+
animation: glitch-anim2 5s infinite linear alternate-reverse;
|
| 115 |
}
|
| 116 |
|
| 117 |
+
@keyframes glitch-anim {
|
| 118 |
+
0% { clip: rect(12px, 9999px, 32px, 0); }
|
| 119 |
+
10% { clip: rect(64px, 9999px, 12px, 0); }
|
| 120 |
+
20% { clip: rect(32px, 9999px, 88px, 0); }
|
| 121 |
+
100% { clip: rect(12px, 9999px, 32px, 0); }
|
|
|
|
|
|
|
|
|
|
| 122 |
}
|
| 123 |
|
| 124 |
+
@keyframes glitch-anim2 {
|
| 125 |
+
0% { clip: rect(82px, 9999px, 2px, 0); }
|
| 126 |
+
10% { clip: rect(4px, 9999px, 92px, 0); }
|
| 127 |
+
20% { clip: rect(52px, 9999px, 22px, 0); }
|
| 128 |
+
100% { clip: rect(82px, 9999px, 2px, 0); }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
}
|
| 130 |
|
| 131 |
+
/* --- The Odyssey Header --- */
|
| 132 |
+
.odyssey-header {
|
| 133 |
+
background: linear-gradient(90deg, rgba(46, 16, 101, 0.8), rgba(2, 2, 4, 0.9));
|
| 134 |
+
border-bottom: 2px solid var(--prince-main);
|
| 135 |
+
padding: 2rem;
|
| 136 |
+
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.6);
|
| 137 |
+
backdrop-filter: blur(5px);
|
| 138 |
+
position: relative;
|
| 139 |
+
z-index: 10;
|
| 140 |
}
|
| 141 |
|
| 142 |
+
/* --- Component Alchemy --- */
|
| 143 |
+
|
| 144 |
+
/* The Terminal (The Log of the Journey) - CRT Style */
|
| 145 |
+
.terminal-log {
|
| 146 |
+
background: #000505 !important;
|
| 147 |
+
border: 1px solid var(--border-glass) !important;
|
| 148 |
+
border-left: 3px solid var(--nature-green);
|
| 149 |
+
font-family: 'Fira Code', monospace;
|
| 150 |
+
color: #33ff33; /* Terminal Green */
|
| 151 |
+
padding: 1.5rem;
|
| 152 |
+
border-radius: 4px;
|
| 153 |
+
min-height: 300px;
|
| 154 |
+
white-space: pre-wrap;
|
| 155 |
+
box-shadow: inset 0 0 40px rgba(0, 255, 0, 0.1);
|
| 156 |
+
text-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
|
| 157 |
+
line-height: 1.4;
|
| 158 |
+
font-size: 0.9rem;
|
| 159 |
}
|
| 160 |
|
| 161 |
+
.log-prince { color: var(--prince-pink); text-shadow: 0 0 8px var(--prince-pink); }
|
| 162 |
+
.log-wu { color: var(--wu-gold); font-weight: bold; text-shadow: 0 0 8px var(--wu-gold); }
|
| 163 |
+
.log-nature { color: var(--nature-glow); }
|
| 164 |
+
.log-system { color: #6b7280; font-style: italic; }
|
| 165 |
|
| 166 |
+
/* The Code Editor */
|
| 167 |
.ace_editor {
|
| 168 |
border: 1px solid var(--border-glass) !important;
|
| 169 |
border-radius: 8px !important;
|
| 170 |
+
background: rgba(10, 10, 12, 0.8) !important;
|
| 171 |
font-family: 'Fira Code', monospace !important;
|
| 172 |
+
box-shadow: 0 0 15px rgba(124, 58, 237, 0.1);
|
| 173 |
}
|
| 174 |
|
| 175 |
+
/* Buttons: Enhanced Hover */
|
| 176 |
.prince-btn {
|
| 177 |
background: linear-gradient(135deg, var(--prince-dark), var(--prince-main)) !important;
|
| 178 |
color: white !important;
|
|
|
|
| 180 |
text-transform: uppercase;
|
| 181 |
font-weight: 700;
|
| 182 |
letter-spacing: 1px;
|
| 183 |
+
transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
| 184 |
}
|
| 185 |
|
| 186 |
.prince-btn:hover {
|
| 187 |
+
transform: translateY(-2px) scale(1.02);
|
| 188 |
+
box-shadow: 0 10px 25px -5px var(--prince-main);
|
| 189 |
}
|
| 190 |
|
| 191 |
.wu-btn {
|
|
|
|
| 194 |
border: 2px solid var(--wu-gold) !important;
|
| 195 |
font-family: var(--font-funk) !important;
|
| 196 |
text-shadow: 0 0 5px var(--wu-amber);
|
| 197 |
+
transition: all 0.3s ease;
|
| 198 |
}
|
| 199 |
|
| 200 |
.wu-btn:hover {
|
| 201 |
background: var(--wu-gold) !important;
|
| 202 |
color: black !important;
|
| 203 |
+
box-shadow: 0 0 30px var(--wu-gold);
|
| 204 |
+
transform: rotate(-1deg);
|
| 205 |
}
|
| 206 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
.cyber-card {
|
| 208 |
background: rgba(20, 20, 25, 0.6);
|
| 209 |
+
backdrop-filter: blur(15px);
|
| 210 |
border: 1px solid var(--border-glass);
|
| 211 |
border-radius: 12px;
|
| 212 |
padding: 1.5rem;
|
| 213 |
+
transition: all 0.4s ease;
|
| 214 |
+
position: relative;
|
| 215 |
+
overflow: hidden;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
.cyber-card::before {
|
| 219 |
+
content: '';
|
| 220 |
+
position: absolute;
|
| 221 |
+
top: 0; left: -100%;
|
| 222 |
+
width: 100%; height: 100%;
|
| 223 |
+
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
|
| 224 |
+
transition: 0.5s;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
.cyber-card:hover::before {
|
| 228 |
+
left: 100%;
|
| 229 |
}
|
| 230 |
|
| 231 |
.cyber-card:hover {
|
| 232 |
border-color: var(--prince-main);
|
| 233 |
+
transform: translateY(-5px);
|
| 234 |
+
box-shadow: 0 10px 30px rgba(0,0,0,0.5);
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
/* --- Splash Screen Overlay (Injected by JS) --- */
|
| 238 |
+
#splash-screen {
|
| 239 |
+
position: fixed;
|
| 240 |
+
top: 0; left: 0; width: 100%; height: 100%;
|
| 241 |
+
background: #000;
|
| 242 |
+
z-index: 10000;
|
| 243 |
+
display: flex;
|
| 244 |
+
flex-direction: column;
|
| 245 |
+
justify-content: center;
|
| 246 |
+
align-items: center;
|
| 247 |
+
transition: opacity 1s ease-out;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
.loader-bar {
|
| 251 |
+
width: 300px;
|
| 252 |
+
height: 2px;
|
| 253 |
+
background: #111;
|
| 254 |
+
margin-top: 20px;
|
| 255 |
+
position: relative;
|
| 256 |
+
overflow: hidden;
|
| 257 |
}
|
| 258 |
|
| 259 |
+
.loader-progress {
|
| 260 |
+
position: absolute;
|
| 261 |
+
top: 0; left: 0; height: 100%;
|
| 262 |
+
background: var(--prince-main);
|
| 263 |
+
width: 0%;
|
| 264 |
+
box-shadow: 0 0 10px var(--prince-main);
|
| 265 |
+
animation: load 2s ease-in-out forwards;
|
|
|
|
| 266 |
}
|
| 267 |
|
| 268 |
+
@keyframes load {
|
| 269 |
+
0% { width: 0%; }
|
| 270 |
+
50% { width: 70%; }
|
| 271 |
+
100% { width: 100%; }
|
| 272 |
}
|
| 273 |
"""
|
| 274 |
|
|
|
|
| 276 |
|
| 277 |
def run_odyssey(action_type: str, code: str, model: str, language: str):
|
| 278 |
"""
|
| 279 |
+
The core processor. Returns HTML string for rich formatting.
|
| 280 |
"""
|
| 281 |
if not code:
|
| 282 |
gr.Warning("The canvas is blank, darling. Paint something first.")
|
| 283 |
+
return '<span class="log-system">[SYSTEM] ERROR: No input detected.</span>', ""
|
| 284 |
|
| 285 |
logs = []
|
| 286 |
+
logs.append(f'<span class="log-system">[SYSTEM] INITIATING SEQUENCE: {action_type.upper()}</span>')
|
| 287 |
+
logs.append(f'<span class="log-system">[SYSTEM] MODEL: {model} // LANGUAGE: {language.upper()}</span>')
|
| 288 |
|
| 289 |
+
# Simulate processing
|
| 290 |
+
time.sleep(random.uniform(0.3, 0.8))
|
| 291 |
|
| 292 |
if action_type == "analyze":
|
| 293 |
+
logs.append('<span class="log-nature">[NATURE] The syntax trees begin to unfurl in the morning light...</span>')
|
| 294 |
+
logs.append('<span class="log-nature">[NATURE] We observe the function \'main\' stalking its prey...</span>')
|
| 295 |
+
time.sleep(0.4)
|
| 296 |
+
logs.append('<span class="log-nature">[NATURE] Structure integrity: 98.4%. The species is cataloged.</span>')
|
|
|
|
| 297 |
result = f"# Analysis Report: The Digital Species\n# Habitat: {language}\n# Observer: {model}\n\n1. Behavior: Predictable yet elegant.\n2. Diet: Consumes memory efficiently.\n3. Status: Thriving in the compiler."
|
| 298 |
+
gr.Info("Analysis complete.")
|
| 299 |
|
| 300 |
elif action_type == "optimize":
|
| 301 |
+
logs.append('<span class="log-prince">[PRINCE] Ooh! I like this code. It\'s got a nasty groove.</span>')
|
| 302 |
+
logs.append('<span class="log-prince">[PRINCE] Let\'s take it to the bridge... refactoring the rhythm...</span>')
|
| 303 |
+
time.sleep(0.6)
|
| 304 |
+
logs.append('<span class="log-prince">[PRINCE] Optimization complete. Doves cry when this runs.</span>')
|
| 305 |
+
result = code + "\n\n# --- THE PURPLE RAIN REMIX ---\n# Optimized for maximum funk."
|
| 306 |
+
gr.Info("The Purple Rain Remix is ready.")
|
|
|
|
| 307 |
|
| 308 |
elif action_type == "secure":
|
| 309 |
+
logs.append('<span class="log-wu">[WU-TANG] PROTECT YA NECK! Scanning for intruders...</span>')
|
| 310 |
+
logs.append('<span class="log-wu">[WU-TANG] Bring the ruckus! Patching vulnerabilities...</span>')
|
| 311 |
+
time.sleep(0.5)
|
| 312 |
+
logs.append('<span class="log-wu">[WU-TANG] C.R.E.A.M. (Code Rules Everything Around Me). System secured.</span>')
|
| 313 |
+
result = code + "\n\n# --- WU-TANG SECURITY PROTOCOL ---\n# 36 Chambers of Defense activated."
|
|
|
|
| 314 |
gr.Info("Protect Ya Neck! Security protocols active.")
|
| 315 |
|
| 316 |
+
log_output = "<br>".join(logs)
|
| 317 |
return log_output, result
|
| 318 |
|
| 319 |
def create_habitat(name: str, framework: str, desc: str):
|
| 320 |
"""Founding a new ecosystem."""
|
| 321 |
if not name:
|
| 322 |
+
return '<div style="text-align: center; padding: 4rem; opacity: 0.5;"><h3>Error</h3><p>Name required for genesis.</p></div>'
|
|
|
|
| 323 |
|
|
|
|
| 324 |
card = f"""
|
| 325 |
+
<div class="cyber-card" style="animation: fadeIn 0.5s ease-out;">
|
| 326 |
+
<div style="position: absolute; top: 0; right: 0; background: var(--wu-gold); color: black; font-size: 0.7rem; padding: 2px 8px; font-weight: bold;">NEW LIFEFORM</div>
|
| 327 |
+
<div style="font-family: var(--font-display); font-size: 1.4rem; color: var(--prince-light); margin-bottom: 0.5rem; text-shadow: 0 0 10px var(--prince-main);">{name}</div>
|
| 328 |
+
<div style="color: #9ca3af; font-size: 0.9rem; margin-bottom: 0.5rem;">Framework: <span style="color: var(--nature-green); font-weight: bold;">{framework}</span></div>
|
| 329 |
+
<div style="font-style: italic; color: #6b7280; font-size: 0.9rem;">"{desc}"</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
</div>
|
| 331 |
"""
|
| 332 |
+
gr.Info(f"Habitat '{name}' established.")
|
|
|
|
| 333 |
return card
|
| 334 |
|
| 335 |
+
# --- THE GRADIO 6 APP ---
|
| 336 |
|
|
|
|
| 337 |
with gr.Blocks() as demo:
|
| 338 |
|
| 339 |
+
# Background Canvas for the "Dreamscape"
|
| 340 |
+
# We place this first so it sits behind everything
|
| 341 |
+
gr.HTML('<canvas id="dreamscape-canvas"></canvas>')
|
| 342 |
+
|
| 343 |
+
# CRT Overlay for retro vibe
|
| 344 |
+
gr.HTML('<div class="crt-overlay"></div>')
|
| 345 |
+
|
| 346 |
+
# HEADER
|
| 347 |
+
gr.HTML(f"""
|
| 348 |
<div class="odyssey-header">
|
| 349 |
<div style="display: flex; flex-direction: column; gap: 0.5rem;">
|
| 350 |
+
<h1 class="glitch-text" data-text="THE ODYSSEY ENGINE" style="font-size: 2.8rem; margin: 0; color: white;">THE ODYSSEY ENGINE</h1>
|
| 351 |
+
<div style="display: flex; gap: 2rem; align-items: center; font-size: 0.9rem;">
|
| 352 |
+
<span style="color: var(--nature-green); font-family: 'Fira Code', monospace; text-shadow: 0 0 5px var(--nature-green);">v4.0 NEURAL DREAMSCAPE</span>
|
| 353 |
+
<span style="color: var(--wu-gold); font-family: var(--font-funk);">REALITY: UNBOUND</span>
|
|
|
|
| 354 |
</div>
|
| 355 |
</div>
|
| 356 |
<div style="text-align: right;">
|
| 357 |
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank"
|
| 358 |
+
style="background: transparent; border: 1px solid var(--prince-pink); color: var(--prince-pink); padding: 0.5rem 1.5rem;
|
| 359 |
text-decoration: none; font-weight: bold; border-radius: 4px;
|
| 360 |
+
font-family: var(--font-display); transition: all 0.3s; text-transform: uppercase; letter-spacing: 1px;"
|
| 361 |
+
onmouseover="this.style.background='var(--prince-pink)'; this.style.color='white'; this.style.boxShadow='var(--glow-purple)'"
|
| 362 |
+
onmouseout="this.style.background='transparent'; this.style.color='var(--prince-pink)'; this.style.boxShadow='none'">
|
| 363 |
Built with anycoder
|
| 364 |
</a>
|
| 365 |
</div>
|
| 366 |
</div>
|
| 367 |
""")
|
| 368 |
|
| 369 |
+
# NAVIGATION
|
| 370 |
with gr.Tabs() as tabs:
|
| 371 |
|
| 372 |
+
# --- CHAMBER 1: THE FORGE ---
|
| 373 |
with gr.Tab("The Forge", id="forge"):
|
| 374 |
with gr.Row():
|
| 375 |
with gr.Column(scale=3):
|
| 376 |
+
gr.Markdown("### **Alchemical Canvas**")
|
| 377 |
+
gr.Markdown("*Paint your logic. Watch it breathe.*")
|
| 378 |
|
| 379 |
code_editor = gr.Code(
|
| 380 |
label="Source Material",
|
|
|
|
| 389 |
lang_select = gr.Dropdown(
|
| 390 |
choices=["python", "javascript", "rust", "typescript", "go"],
|
| 391 |
value="python",
|
| 392 |
+
label="Dialect",
|
| 393 |
scale=1
|
| 394 |
)
|
| 395 |
model_select = gr.Dropdown(
|
| 396 |
choices=["GPT-4 Omni (The Architect)", "Claude 3.5 Sonnet (The Poet)", "Llama 3 (The Rebel)"],
|
| 397 |
value="GPT-4 Omni (The Architect)",
|
| 398 |
+
label="Consciousness",
|
| 399 |
scale=2
|
| 400 |
)
|
| 401 |
|
| 402 |
with gr.Row():
|
| 403 |
btn_analyze = gr.Button("Inspect Species", variant="primary", scale=1, elem_classes=["wu-btn"])
|
| 404 |
+
btn_evolve = gr.Button("Purple Rain Remix", scale=1, elem_classes=["prince-btn"])
|
| 405 |
btn_secure = gr.Button("Protect Ya Neck", scale=1, elem_classes=["wu-btn"])
|
| 406 |
|
| 407 |
with gr.Column(scale=2):
|
| 408 |
+
gr.Markdown("### **Transmission Log**")
|
| 409 |
+
terminal = gr.HTML(
|
| 410 |
+
value='<div class="terminal-log" id="terminal-content"><span class="log-system">[SYSTEM] The Odyssey Engine is online. Awaiting input...</span></div>',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 411 |
)
|
| 412 |
|
| 413 |
artifact = gr.Code(
|
|
|
|
| 419 |
elem_classes=["cyber-card"]
|
| 420 |
)
|
| 421 |
|
| 422 |
+
# --- CHAMBER 2: THE HABITATS ---
|
| 423 |
with gr.Tab("The Habitats", id="habitats"):
|
| 424 |
gr.Markdown("### **Found New Ecosystems**")
|
| 425 |
with gr.Row():
|
|
|
|
| 435 |
with gr.Column(scale=1):
|
| 436 |
gr.Markdown("### **Active Lifeforms**")
|
| 437 |
habitats_display = gr.HTML(
|
| 438 |
+
value='<div style="text-align: center; padding: 4rem; opacity: 0.5;"><h3>The void is empty.</h3><p>Create life to populate this sector.</p></div>'
|
| 439 |
)
|
| 440 |
|
| 441 |
+
# --- CHAMBER 3: C.R.E.A.M. METRICS ---
|
| 442 |
with gr.Tab("C.R.E.A.M. Metrics", id="cream"):
|
| 443 |
gr.HTML("""
|
| 444 |
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin-bottom: 2rem;">
|
| 445 |
<div class="cyber-card" style="border-top: 4px solid var(--prince-main);">
|
| 446 |
+
<div style="color: #9ca3af; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 1px;">Compute Power</div>
|
| 447 |
+
<div style="font-size: 3.5rem; font-weight: 800; color: var(--prince-light); text-shadow: var(--glow-purple);">99.9%</div>
|
| 448 |
+
<div style="font-size: 0.8rem; color: var(--prince-pink);">Efficiency: Transcendent</div>
|
| 449 |
</div>
|
| 450 |
<div class="cyber-card" style="border-top: 4px solid var(--wu-gold);">
|
| 451 |
+
<div style="color: #9ca3af; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 1px;">Cash Flow</div>
|
| 452 |
+
<div style="font-size: 3.5rem; font-weight: 800; color: var(--wu-gold); text-shadow: var(--glow-gold);">∞</div>
|
| 453 |
<div style="font-size: 0.8rem; color: var(--wu-amber);">Dolla dolla bill, y'all</div>
|
| 454 |
</div>
|
| 455 |
<div class="cyber-card" style="border-top: 4px solid var(--nature-green);">
|
| 456 |
+
<div style="color: #9ca3af; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 1px;">System Pulse</div>
|
| 457 |
+
<div style="font-size: 3.5rem; font-weight: 800; color: var(--nature-green); text-shadow: 0 0 10px var(--nature-green);">0.01ms</div>
|
| 458 |
<div style="font-size: 0.8rem; color: var(--nature-glow);">Bioluminescent</div>
|
| 459 |
</div>
|
| 460 |
</div>
|
| 461 |
""")
|
| 462 |
|
| 463 |
+
# --- CHAMBER 4: THE CLAN ---
|
| 464 |
with gr.Tab("The Clan", id="clan"):
|
| 465 |
gr.HTML("""
|
| 466 |
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem;">
|
| 467 |
<div class="cyber-card" style="display: flex; align-items: center; gap: 1rem; border-left: 4px solid var(--prince-main);">
|
| 468 |
+
<div style="width: 50px; height: 50px; border-radius: 50%; background: var(--prince-dark); display: flex; align-items: center; justify-content: center; font-weight: bold; color: var(--prince-pink); font-size: 1.2rem; box-shadow: var(--glow-purple);">P</div>
|
| 469 |
<div>
|
| 470 |
<div style="font-weight: bold; font-family: var(--font-display);">The Architect</div>
|
| 471 |
<div style="font-size: 0.8rem; color: var(--prince-light);">Visionary • Online</div>
|
| 472 |
</div>
|
| 473 |
</div>
|
| 474 |
<div class="cyber-card" style="display: flex; align-items: center; gap: 1rem; border-left: 4px solid var(--wu-gold);">
|
| 475 |
+
<div style="width: 50px; height: 50px; border-radius: 50%; background: #222; display: flex; align-items: center; justify-content: center; font-weight: bold; color: var(--wu-gold); font-size: 1.2rem; box-shadow: var(--glow-gold);">M</div>
|
| 476 |
<div>
|
| 477 |
<div style="font-weight: bold; font-family: var(--font-funk);">Method Man</div>
|
| 478 |
<div style="font-size: 0.8rem; color: var(--wu-amber);">Deployment • Smokin'</div>
|
| 479 |
</div>
|
| 480 |
</div>
|
| 481 |
<div class="cyber-card" style="display: flex; align-items: center; gap: 1rem; border-left: 4px solid var(--nature-green);">
|
| 482 |
+
<div style="width: 50px; height: 50px; border-radius: 50%; background: #022c22; display: flex; align-items: center; justify-content: center; font-weight: bold; color: var(--nature-green); font-size: 1.2rem; box-shadow: 0 0 10px var(--nature-green);">G</div>
|
| 483 |
<div>
|
| 484 |
<div style="font-weight: bold; font-family: var(--font-display);">The Guardian</div>
|
| 485 |
<div style="font-size: 0.8rem; color: var(--nature-glow);">Security • Watchful</div>
|
|
|
|
| 490 |
|
| 491 |
# FOOTER
|
| 492 |
gr.HTML("""
|
| 493 |
+
<div style="margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border-glass); text-align: center; color: #6b7280; font-size: 0.8rem;">
|
| 494 |
<p>© 2026 THE ODYSSEY ENGINE. <span style="color: var(--prince-pink);">Code is the canvas.</span> <span style="color: var(--wu-gold);">Creativity is the color.</span></p>
|
| 495 |
</div>
|
| 496 |
""")
|
| 497 |
|
| 498 |
+
# --- EVENT LISTENERS ---
|
| 499 |
|
| 500 |
# Dynamic Language Switching
|
| 501 |
lang_select.change(lambda l: gr.Code(language=l), lang_select, code_editor)
|
| 502 |
|
| 503 |
# The Forge Actions
|
| 504 |
+
# Note: We return HTML for the terminal now to support the colored logs
|
| 505 |
btn_analyze.click(
|
| 506 |
fn=run_odyssey,
|
| 507 |
inputs=[gr.State("analyze"), code_editor, model_select, lang_select],
|
|
|
|
| 531 |
api_visibility="public"
|
| 532 |
)
|
| 533 |
|
| 534 |
+
# --- JAVASCRIPT: THE NEURAL DREAMSCAPE & SPLASH SCREEN ---
|
| 535 |
+
custom_js = """
|
| 536 |
+
// 1. SPLASH SCREEN LOGIC
|
| 537 |
+
document.addEventListener("DOMContentLoaded", () => {
|
| 538 |
+
// Create splash screen
|
| 539 |
+
const splash = document.createElement('div');
|
| 540 |
+
splash.id = 'splash-screen';
|
| 541 |
+
splash.innerHTML = `
|
| 542 |
+
<h1 style="color: #7c3aed; font-family: 'Cinzel', serif; font-size: 3rem; letter-spacing: 0.2rem; text-transform: uppercase; text-shadow: 0 0 20px #7c3aed;">The Odyssey Engine</h1>
|
| 543 |
+
<div style="color: #fbbf24; font-family: 'Space Grotesk', sans-serif; margin-top: 10px; letter-spacing: 2px;">ESTABLISHING NEURAL LINK...</div>
|
| 544 |
+
<div class="loader-bar"><div class="loader-progress"></div></div>
|
| 545 |
+
`;
|
| 546 |
+
document.body.appendChild(splash);
|
| 547 |
+
|
| 548 |
+
// Remove splash after animation
|
| 549 |
+
setTimeout(() => {
|
| 550 |
+
splash.style.opacity = '0';
|
| 551 |
+
setTimeout(() => {
|
| 552 |
+
splash.remove();
|
| 553 |
+
startDreamscape(); // Start background animation only after load
|
| 554 |
+
}, 1000);
|
| 555 |
+
}, 2500);
|
| 556 |
+
});
|
| 557 |
+
|
| 558 |
+
// 2. NEURAL DREAMSCAPE (PARTICLE SYSTEM)
|
| 559 |
+
function startDreamscape() {
|
| 560 |
+
const canvas = document.getElementById('dreamscape-canvas');
|
| 561 |
+
if (!canvas) return;
|
| 562 |
+
|
| 563 |
+
const ctx = canvas.getContext('2d');
|
| 564 |
+
let width, height;
|
| 565 |
+
let particles = [];
|
| 566 |
+
|
| 567 |
+
// Mouse interaction
|
| 568 |
+
const mouse = { x: null, y: null, radius: 150 };
|
| 569 |
+
|
| 570 |
+
window.addEventListener('mousemove', (e) => {
|
| 571 |
+
mouse.x = e.x;
|
| 572 |
+
mouse.y = e.y;
|
| 573 |
+
});
|
| 574 |
+
|
| 575 |
+
function resize() {
|
| 576 |
+
width = canvas.width = window.innerWidth;
|
| 577 |
+
height = canvas.height = window.innerHeight;
|
| 578 |
+
initParticles();
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
class Particle {
|
| 582 |
+
constructor() {
|
| 583 |
+
this.x = Math.random() * width;
|
| 584 |
+
this.y = Math.random() * height;
|
| 585 |
+
this.vx = (Math.random() - 0.5) * 0.5;
|
| 586 |
+
this.vy = (Math.random() - 0.5) * 0.5;
|
| 587 |
+
this.size = Math.random() * 2;
|
| 588 |
+
this.color = Math.random() > 0.5 ? '#7c3aed' : '#10b981'; // Prince Purple or Attenborough Green
|
| 589 |
+
}
|
| 590 |
+
|
| 591 |
+
update() {
|
| 592 |
+
this.x += this.vx;
|
| 593 |
+
this.y += this.vy;
|
| 594 |
+
|
| 595 |
+
// Bounce off edges
|
| 596 |
+
if (this.x < 0 || this.x > width) this.vx *= -1;
|
| 597 |
+
if (this.y < 0 || this.y > height) this.vy *= -1;
|
| 598 |
+
|
| 599 |
+
// Mouse interaction
|
| 600 |
+
const dx = mouse.x - this.x;
|
| 601 |
+
const dy = mouse.y - this.y;
|
| 602 |
+
const distance = Math.sqrt(dx*dx + dy*dy);
|
| 603 |
+
|
| 604 |
+
if (distance < mouse.radius) {
|
| 605 |
+
const forceDirectionX = dx / distance;
|
| 606 |
+
const forceDirectionY = dy / distance;
|
| 607 |
+
const force = (mouse.radius - distance) / mouse.radius;
|
| 608 |
+
const directionX = forceDirectionX * force * 3; // Push strength
|
| 609 |
+
const directionY = forceDirectionY * force * 3;
|
| 610 |
+
|
| 611 |
+
this.x -= directionX;
|
| 612 |
+
this.y -= directionY;
|
| 613 |
+
}
|
| 614 |
+
}
|
| 615 |
+
|
| 616 |
+
draw() {
|
| 617 |
+
ctx.beginPath();
|
| 618 |
+
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
|
| 619 |
+
ctx.fillStyle = this.color;
|
| 620 |
+
ctx.globalAlpha = 0.6;
|
| 621 |
+
ctx.fill();
|
| 622 |
+
}
|
| 623 |
+
}
|
| 624 |
+
|
| 625 |
+
function initParticles() {
|
| 626 |
+
particles = [];
|
| 627 |
+
const numberOfParticles = (width * height) / 15000; // Density based on screen size
|
| 628 |
+
for (let i = 0; i < numberOfParticles; i++) {
|
| 629 |
+
particles.push(new Particle());
|
| 630 |
+
}
|
| 631 |
+
}
|
| 632 |
+
|
| 633 |
+
function connect() {
|
| 634 |
+
let opacityValue = 1;
|
| 635 |
+
for (let a = 0; a < particles.length; a++) {
|
| 636 |
+
for (let b = a; b < particles.length; b++) {
|
| 637 |
+
const distance = ((particles[a].x - particles[b].x) * (particles[a].x - particles[b].x)) +
|
| 638 |
+
((particles[a].y - particles[b].y) * (particles[a].y - particles[b].y));
|
| 639 |
+
|
| 640 |
+
if (distance < (width/7) * (height/7)) {
|
| 641 |
+
opacityValue = 1 - (distance / 20000);
|
| 642 |
+
ctx.strokeStyle = 'rgba(124, 58, 237,' + opacityValue * 0.2 + ')'; // Purple connections
|
| 643 |
+
ctx.lineWidth = 1;
|
| 644 |
+
ctx.beginPath();
|
| 645 |
+
ctx.moveTo(particles[a].x, particles[a].y);
|
| 646 |
+
ctx.lineTo(particles[b].x, particles[b].y);
|
| 647 |
+
ctx.stroke();
|
| 648 |
+
}
|
| 649 |
+
}
|
| 650 |
+
}
|
| 651 |
+
}
|
| 652 |
+
|
| 653 |
+
function animate() {
|
| 654 |
+
requestAnimationFrame(animate);
|
| 655 |
+
ctx.clearRect(0, 0, width, height);
|
| 656 |
+
|
| 657 |
+
for (let i = 0; i < particles.length; i++) {
|
| 658 |
+
particles[i].update();
|
| 659 |
+
particles[i].draw();
|
| 660 |
+
}
|
| 661 |
+
connect();
|
| 662 |
+
}
|
| 663 |
+
|
| 664 |
+
window.addEventListener('resize', resize);
|
| 665 |
+
resize();
|
| 666 |
+
animate();
|
| 667 |
+
}
|
| 668 |
+
"""
|
| 669 |
+
|
| 670 |
+
# --- LAUNCH ---
|
| 671 |
custom_head = """
|
| 672 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 673 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
|
|
| 675 |
"""
|
| 676 |
|
| 677 |
demo.launch(
|
| 678 |
+
theme=gr.themes.Base(),
|
| 679 |
css=custom_css,
|
| 680 |
+
js=custom_js,
|
| 681 |
head=custom_head,
|
| 682 |
footer_links=[{"label": "Built with anycoder", "url": "https://huggingface.co/spaces/akhaliq/anycoder"}]
|
| 683 |
)
|