Update app.py
Browse files
app.py
CHANGED
|
@@ -1,59 +1,55 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
-
from deployer.gradio_generator import deploy_callback, robot_behavior
|
| 4 |
|
| 5 |
-
|
| 6 |
-
"""
|
| 7 |
-
Gradio callback: returns (status_message, path_to_zip).
|
| 8 |
-
Gradio's File component will serve the zip.
|
| 9 |
-
"""
|
| 10 |
-
return deploy_callback(idea)
|
| 11 |
|
| 12 |
def main():
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
gr.Markdown("# 🚀 RoboSage\nGenerate & download a simple robot app, then test it live.")
|
| 15 |
|
| 16 |
-
with gr.
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 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 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
)
|
| 51 |
-
|
| 52 |
-
# Launch on Hugging Face Spaces or locally
|
| 53 |
demo.launch(
|
| 54 |
server_name="0.0.0.0",
|
| 55 |
server_port=int(os.environ.get("PORT", 7860)),
|
| 56 |
-
share=False
|
| 57 |
)
|
| 58 |
|
| 59 |
if __name__ == "__main__":
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
|
| 4 |
+
from deployer.gradio_generator import deploy_callback, robot_behavior
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
def main():
|
| 7 |
+
# Build Gradio interface
|
| 8 |
+
with gr.Blocks(css="""
|
| 9 |
+
.gradio-container { max-width: 900px; margin: auto; }
|
| 10 |
+
.generate-section, .simulate-section { padding: 1rem; }
|
| 11 |
+
""") as demo:
|
| 12 |
+
|
| 13 |
gr.Markdown("# 🚀 RoboSage\nGenerate & download a simple robot app, then test it live.")
|
| 14 |
|
| 15 |
+
with gr.Column(elem_id="generate-section"):
|
| 16 |
+
gr.Markdown("## 1️⃣ Generate & Download App")
|
| 17 |
+
idea_input = gr.Textbox(
|
| 18 |
+
label="Your Robot Idea",
|
| 19 |
+
placeholder="e.g. A friendly greeting robot.",
|
| 20 |
+
lines=2
|
| 21 |
+
)
|
| 22 |
+
gen_btn = gr.Button("Generate App & ZIP")
|
| 23 |
+
status_out = gr.Textbox(label="Status", interactive=False)
|
| 24 |
+
zip_out = gr.File(label="Download App ZIP")
|
| 25 |
+
|
| 26 |
+
gen_btn.click(
|
| 27 |
+
fn=deploy_callback,
|
| 28 |
+
inputs=[idea_input],
|
| 29 |
+
outputs=[status_out, zip_out]
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
with gr.Column(elem_id="simulate-section"):
|
| 33 |
+
gr.Markdown("## 2️⃣ Robot Simulator")
|
| 34 |
+
cmd_input = gr.Textbox(
|
| 35 |
+
label="Command",
|
| 36 |
+
placeholder="say 'hello' or 'You rock!'",
|
| 37 |
+
lines=1
|
| 38 |
+
)
|
| 39 |
+
sim_btn = gr.Button("Send Command")
|
| 40 |
+
sim_out = gr.Textbox(label="Robot Response", interactive=False)
|
| 41 |
+
|
| 42 |
+
sim_btn.click(
|
| 43 |
+
fn=robot_behavior,
|
| 44 |
+
inputs=[cmd_input],
|
| 45 |
+
outputs=[sim_out]
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
# Launch
|
|
|
|
|
|
|
|
|
|
| 49 |
demo.launch(
|
| 50 |
server_name="0.0.0.0",
|
| 51 |
server_port=int(os.environ.get("PORT", 7860)),
|
| 52 |
+
share=False
|
| 53 |
)
|
| 54 |
|
| 55 |
if __name__ == "__main__":
|