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