mgbam commited on
Commit
67f9d7b
·
verified ·
1 Parent(s): f701c15

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -48
app.py CHANGED
@@ -1,54 +1,42 @@
1
- # app.py
2
-
3
  import gradio as gr
4
- from deployer.gradio_generator import deploy_callback, robot_behavior, download_callback
 
 
 
 
5
 
6
- def launch_gradio_app():
7
- with gr.Blocks() as demo:
8
- gr.Markdown("# 🤖 RoboSage: Your Personal Robot App Generator")
 
 
 
 
 
 
 
9
 
10
  with gr.Row():
11
- with gr.Column():
12
- gr.Markdown("### 🛠️ Generate Your Robot App")
13
- idea_input = gr.Textbox(
14
- label="Enter your robot idea",
15
- placeholder="e.g., A friendly greeting robot.",
16
- lines=2
17
- )
18
- generate_button = gr.Button("Generate App")
19
- status_output = gr.Textbox(label="Status", interactive=False)
20
- generate_button.click(
21
- fn=deploy_callback,
22
- inputs=idea_input,
23
- outputs=status_output
24
- )
25
-
26
- gr.Markdown("### 📦 Download Your App")
27
- download_button = gr.Button("Download App ZIP")
28
- download_output = gr.File(label="Download ZIP")
29
- download_button.click(
30
- fn=download_callback,
31
- inputs=None,
32
- outputs=download_output
33
- )
34
-
35
- with gr.Column():
36
- gr.Markdown("### 🤖 Robot Simulator")
37
- command_input = gr.Textbox(
38
- label="Enter command",
39
- placeholder="e.g., say Hello World!",
40
- lines=1
41
- )
42
- send_button = gr.Button("Send Command")
43
- response_output = gr.Textbox(label="Robot Response", interactive=False)
44
- send_button.click(
45
- fn=robot_behavior,
46
- inputs=command_input,
47
- outputs=response_output
48
- )
49
-
50
- return demo
51
 
52
  if __name__ == "__main__":
53
- app = launch_gradio_app()
54
- app.launch()
 
1
+ import os
2
+ import asyncio
3
  import gradio as gr
4
+ from deployer.gradio_generator import deploy_callback, robot_behavior
5
+
6
+ # Wrapper to run deploy_callback asynchronously
7
+ async def _deploy_async(idea: str):
8
+ return deploy_callback(idea)
9
 
10
+ # Synchronous Gradio callback for app generation
11
+ def generate_app(idea: str):
12
+ status, zip_path = asyncio.run(_deploy_async(idea))
13
+ return status, zip_path
14
+
15
+ # Build and launch the Gradio interface
16
+ def main():
17
+ with gr.Blocks(css=".gradio-container { max-width: 900px; margin: auto; }
18
+ .section { padding: 1rem; }") as demo:
19
+ gr.Markdown("# 🚀 RoboSage\nGenerate your custom robot app and test it live.")
20
 
21
  with gr.Row():
22
+ with gr.Column(scale=1):
23
+ gr.Markdown("## 1️⃣ Generate & Download App")
24
+ idea_input = gr.Textbox(label="Your Robot Idea", placeholder="e.g. A friendly greeting robot.", lines=2)
25
+ gen_btn = gr.Button("Generate App")
26
+ status_out = gr.Textbox(label="Status", interactive=False)
27
+ zip_out = gr.File(label="Download App ZIP")
28
+
29
+ gen_btn.click(fn=generate_app, inputs=[idea_input], outputs=[status_out, zip_out])
30
+
31
+ with gr.Column(scale=1):
32
+ gr.Markdown("## 2️⃣ Robot Simulator")
33
+ cmd_input = gr.Textbox(label="Command", placeholder="hello or say You rock!", lines=1)
34
+ sim_btn = gr.Button("Send Command")
35
+ sim_out = gr.Textbox(label="Robot Response", interactive=False)
36
+
37
+ sim_btn.click(fn=robot_behavior, inputs=[cmd_input], outputs=[sim_out])
38
+
39
+ demo.launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", 7860)), share=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  if __name__ == "__main__":
42
+ main()