Update app.py
Browse files
app.py
CHANGED
@@ -1,58 +1,56 @@
|
|
1 |
import os
|
2 |
-
import shutil
|
3 |
-
from deployer.gradio_generator import deploy_and_package, robot_behavior
|
4 |
import gradio as gr
|
|
|
5 |
|
6 |
-
def
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
10 |
"""
|
11 |
-
status, zip_path = deploy_and_package(idea)
|
12 |
-
# Gradio File component needs a Path or file-like
|
13 |
-
return status, zip_path
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
.gradio-container { max-width: 900px; margin: auto; }
|
18 |
-
.section { padding: 1rem; }
|
19 |
-
""") as demo:
|
20 |
-
gr.Markdown("# π RoboSage\nGenerate your custom robot app and download it, then test it live.")
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
with gr.Row():
|
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 |
-
sim_btn = gr.Button("Send Command")
|
48 |
-
sim_out = gr.Textbox(label="Robot Response", interactive=False)
|
49 |
-
|
50 |
-
sim_btn.click(
|
51 |
-
fn=robot_behavior,
|
52 |
-
inputs=[cmd_input],
|
53 |
-
outputs=[sim_out]
|
54 |
-
)
|
55 |
|
|
|
56 |
demo.launch(
|
57 |
server_name="0.0.0.0",
|
58 |
server_port=int(os.environ.get("PORT", 7860)),
|
|
|
1 |
import os
|
|
|
|
|
2 |
import gradio as gr
|
3 |
+
from deployer.gradio_generator import deploy_callback, robot_behavior
|
4 |
|
5 |
+
def main():
|
6 |
+
# simple CSS to center the UI and style sections
|
7 |
+
custom_css = """
|
8 |
+
.gradio-container { max-width: 900px; margin: auto; }
|
9 |
+
.section-header { margin-top: 1.5em; }
|
10 |
"""
|
|
|
|
|
|
|
11 |
|
12 |
+
with gr.Blocks(css=custom_css) as demo:
|
13 |
+
gr.Markdown("# π RoboSage\nGenerate your custom robot app, download it, then test it live.")
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
# βββ SECTION 1: Generate & Download App βββββββββββββββββββββββββββββββββββββββββ
|
16 |
+
gr.Markdown("## 1οΈβ£ Generate & Download App", elem_classes="section-header")
|
17 |
+
with gr.Row():
|
18 |
+
idea_in = gr.Textbox(
|
19 |
+
label="Your Robot Idea",
|
20 |
+
placeholder="e.g. A friendly greeting robot.",
|
21 |
+
lines=2,
|
22 |
+
)
|
23 |
+
with gr.Row():
|
24 |
+
gen_btn = gr.Button("Generate App & ZIP")
|
25 |
+
with gr.Row():
|
26 |
+
status_out = gr.Textbox(label="Status", interactive=False)
|
27 |
with gr.Row():
|
28 |
+
zip_out = gr.File(label="Download App ZIP")
|
29 |
+
|
30 |
+
# hook up
|
31 |
+
gen_btn.click(
|
32 |
+
fn=deploy_callback,
|
33 |
+
inputs=[idea_in],
|
34 |
+
outputs=[status_out, zip_out],
|
35 |
+
)
|
36 |
+
|
37 |
+
# βββ SECTION 2: Robot Simulator ββββββββββββββββββββββββββββββββββββββββββββββββ
|
38 |
+
gr.Markdown("## 2οΈβ£ Robot Simulator", elem_classes="section-header")
|
39 |
+
cmd_in = gr.Textbox(
|
40 |
+
label="Speak or Type Command",
|
41 |
+
placeholder="hello or say You rock!",
|
42 |
+
lines=1,
|
43 |
+
)
|
44 |
+
sim_btn = gr.Button("Send Command")
|
45 |
+
sim_out = gr.Textbox(label="Robot Response", interactive=False, lines=4)
|
46 |
+
|
47 |
+
sim_btn.click(
|
48 |
+
fn=robot_behavior,
|
49 |
+
inputs=[cmd_in],
|
50 |
+
outputs=[sim_out],
|
51 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
+
# launch parameters
|
54 |
demo.launch(
|
55 |
server_name="0.0.0.0",
|
56 |
server_port=int(os.environ.get("PORT", 7860)),
|