Update app.py
Browse files
app.py
CHANGED
|
@@ -364,13 +364,13 @@ label {
|
|
| 364 |
"""
|
| 365 |
|
| 366 |
# Create Gradio interface
|
| 367 |
-
with gr.Blocks(css=custom_css, theme=gr.themes.Soft(), title="๐ฎ
|
| 368 |
|
| 369 |
# Header
|
| 370 |
gr.HTML("""
|
| 371 |
<div class="header-box">
|
| 372 |
-
<h1>๐ฎ
|
| 373 |
-
<p>Generate your Besiege machine designs with AI</p>
|
| 374 |
<span class="badge">โจ Powered by DeepSeek AI</span>
|
| 375 |
</div>
|
| 376 |
""")
|
|
@@ -424,7 +424,9 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft(), title="๐ฎ Besiege Machi
|
|
| 424 |
info="Maximum length of generation"
|
| 425 |
)
|
| 426 |
|
| 427 |
-
|
|
|
|
|
|
|
| 428 |
|
| 429 |
status_output = gr.Markdown(label="Status")
|
| 430 |
|
|
@@ -453,6 +455,96 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft(), title="๐ฎ Besiege Machi
|
|
| 453 |
file_path = save_xml_to_file(xml_str) if xml_str else None
|
| 454 |
return ai_resp, xml_str, status, file_path
|
| 455 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 456 |
generate_btn.click(
|
| 457 |
fn=generate_and_save,
|
| 458 |
inputs=[user_input, temperature, max_tokens],
|
|
|
|
| 364 |
"""
|
| 365 |
|
| 366 |
# Create Gradio interface
|
| 367 |
+
with gr.Blocks(css=custom_css, theme=gr.themes.Soft(), title="๐ฎ BesiegeField Machine Generator") as demo:
|
| 368 |
|
| 369 |
# Header
|
| 370 |
gr.HTML("""
|
| 371 |
<div class="header-box">
|
| 372 |
+
<h1 style="color: white;">๐ฎ BesiegeField Machine Generator</h1>
|
| 373 |
+
<p style="color: white; opacity: 0.9;">Generate your Besiege machine designs with AI</p>
|
| 374 |
<span class="badge">โจ Powered by DeepSeek AI</span>
|
| 375 |
</div>
|
| 376 |
""")
|
|
|
|
| 424 |
info="Maximum length of generation"
|
| 425 |
)
|
| 426 |
|
| 427 |
+
with gr.Row():
|
| 428 |
+
generate_btn = gr.Button("๐ Generate Machine", variant="primary", size="lg")
|
| 429 |
+
help_btn = gr.Button("๐ Help Video", variant="secondary")
|
| 430 |
|
| 431 |
status_output = gr.Markdown(label="Status")
|
| 432 |
|
|
|
|
| 455 |
file_path = save_xml_to_file(xml_str) if xml_str else None
|
| 456 |
return ai_resp, xml_str, status, file_path
|
| 457 |
|
| 458 |
+
# Help Modal
|
| 459 |
+
help_modal = gr.HTML(visible=False, value="""
|
| 460 |
+
<div id="help-modal" style="
|
| 461 |
+
position: fixed;
|
| 462 |
+
z-index: 2000;
|
| 463 |
+
left: 0;
|
| 464 |
+
top: 0;
|
| 465 |
+
width: 100%;
|
| 466 |
+
height: 100%;
|
| 467 |
+
background-color: rgba(0, 0, 0, 0.8);
|
| 468 |
+
display: flex;
|
| 469 |
+
align-items: center;
|
| 470 |
+
justify-content: center;
|
| 471 |
+
">
|
| 472 |
+
<div style="
|
| 473 |
+
background: white;
|
| 474 |
+
border-radius: 15px;
|
| 475 |
+
width: 90%;
|
| 476 |
+
max-width: 900px;
|
| 477 |
+
padding: 30px;
|
| 478 |
+
">
|
| 479 |
+
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
|
| 480 |
+
<h2 style="color: #333; margin: 0;">๐ Help Tutorial</h2>
|
| 481 |
+
<button onclick="this.closest('#help-modal').style.display='none'" style="
|
| 482 |
+
background: none;
|
| 483 |
+
border: none;
|
| 484 |
+
font-size: 30px;
|
| 485 |
+
color: #666;
|
| 486 |
+
cursor: pointer;
|
| 487 |
+
width: 40px;
|
| 488 |
+
height: 40px;
|
| 489 |
+
border-radius: 50%;
|
| 490 |
+
">×</button>
|
| 491 |
+
</div>
|
| 492 |
+
<div style="position: relative; width: 100%; padding-bottom: 56.25%; background: #000; border-radius: 10px; overflow: hidden;">
|
| 493 |
+
<video controls style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">
|
| 494 |
+
<source src="help.mp4" type="video/mp4">
|
| 495 |
+
Your browser does not support video playback.
|
| 496 |
+
</video>
|
| 497 |
+
</div>
|
| 498 |
+
</div>
|
| 499 |
+
</div>
|
| 500 |
+
""")
|
| 501 |
+
|
| 502 |
+
def show_help():
|
| 503 |
+
return gr.HTML(visible=True, value="""
|
| 504 |
+
<div id="help-modal" style="
|
| 505 |
+
position: fixed;
|
| 506 |
+
z-index: 2000;
|
| 507 |
+
left: 0;
|
| 508 |
+
top: 0;
|
| 509 |
+
width: 100%;
|
| 510 |
+
height: 100%;
|
| 511 |
+
background-color: rgba(0, 0, 0, 0.8);
|
| 512 |
+
display: flex;
|
| 513 |
+
align-items: center;
|
| 514 |
+
justify-content: center;
|
| 515 |
+
">
|
| 516 |
+
<div style="
|
| 517 |
+
background: white;
|
| 518 |
+
border-radius: 15px;
|
| 519 |
+
width: 90%;
|
| 520 |
+
max-width: 900px;
|
| 521 |
+
padding: 30px;
|
| 522 |
+
">
|
| 523 |
+
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
|
| 524 |
+
<h2 style="color: #333; margin: 0;">๐ Help Tutorial</h2>
|
| 525 |
+
<button onclick="this.closest('#help-modal').style.display='none'" style="
|
| 526 |
+
background: none;
|
| 527 |
+
border: none;
|
| 528 |
+
font-size: 30px;
|
| 529 |
+
color: #666;
|
| 530 |
+
cursor: pointer;
|
| 531 |
+
width: 40px;
|
| 532 |
+
height: 40px;
|
| 533 |
+
border-radius: 50%;
|
| 534 |
+
">×</button>
|
| 535 |
+
</div>
|
| 536 |
+
<div style="position: relative; width: 100%; padding-bottom: 56.25%; background: #000; border-radius: 10px; overflow: hidden;">
|
| 537 |
+
<video controls autoplay style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">
|
| 538 |
+
<source src="help.mp4" type="video/mp4">
|
| 539 |
+
Your browser does not support video playback.
|
| 540 |
+
</video>
|
| 541 |
+
</div>
|
| 542 |
+
</div>
|
| 543 |
+
</div>
|
| 544 |
+
""")
|
| 545 |
+
|
| 546 |
+
help_btn.click(fn=show_help, outputs=help_modal)
|
| 547 |
+
|
| 548 |
generate_btn.click(
|
| 549 |
fn=generate_and_save,
|
| 550 |
inputs=[user_input, temperature, max_tokens],
|