mgbam commited on
Commit
2e90048
Β·
verified Β·
1 Parent(s): 6277242

Update deployer/gradio_generator.py

Browse files
Files changed (1) hide show
  1. deployer/gradio_generator.py +17 -22
deployer/gradio_generator.py CHANGED
@@ -1,13 +1,13 @@
1
- import os
2
  import asyncio
3
  import gradio as gr
4
  from core_creator.voice_to_app import VoiceToAppCreator
5
  from deployer.simulator_interface import VirtualRobot
6
  from deployer.revenue_tracker import package_artifacts
7
 
8
- async def generate_app_async(idea: str):
9
  """
10
- Runs the voice-to-app pipeline, packages the app into a ZIP, and returns status and ZIP path.
 
11
  """
12
  creator = VoiceToAppCreator(idea)
13
  assets = creator.run_pipeline()
@@ -16,30 +16,31 @@ async def generate_app_async(idea: str):
16
  status = f"βœ… Generated app: {title}"
17
  return status, zip_path
18
 
19
-
20
  def deploy_callback(idea: str):
21
  """
22
- Synchronous wrapper for Gradio: generate app and get ZIP.
23
  """
24
- return asyncio.run(generate_app_async(idea))
25
-
26
 
27
  def robot_behavior(command: str) -> str:
28
  """
29
- Simulate robot action based on a text command.
30
  """
31
  return VirtualRobot().perform_action(command)
32
 
33
-
34
- def main():
35
  """
36
- Builds and launches the Gradio UI for RoboSage.
 
 
37
  """
38
  demo = gr.Blocks()
 
39
  with demo:
40
  gr.Markdown("# πŸš€ RoboSage\nGenerate your custom robot app and test it live.")
41
 
42
  with gr.Row():
 
43
  with gr.Column():
44
  gr.Markdown("## 1️⃣ Generate & Download App")
45
  idea_input = gr.Textbox(
@@ -47,9 +48,9 @@ def main():
47
  placeholder="e.g. A friendly greeting robot.",
48
  lines=2
49
  )
50
- gen_btn = gr.Button("Generate App")
51
  status_out = gr.Textbox(label="Status", interactive=False)
52
- zip_out = gr.File(label="Download App ZIP")
53
 
54
  gen_btn.click(
55
  fn=deploy_callback,
@@ -57,10 +58,11 @@ def main():
57
  outputs=[status_out, zip_out]
58
  )
59
 
 
60
  with gr.Column():
61
  gr.Markdown("## πŸ€– Robot Simulator")
62
  cmd_input = gr.Textbox(
63
- label="Command",
64
  placeholder="hello or say You rock!",
65
  lines=1
66
  )
@@ -73,11 +75,4 @@ def main():
73
  outputs=[sim_out]
74
  )
75
 
76
- demo.launch(
77
- server_name="0.0.0.0",
78
- server_port=int(os.environ.get("PORT", "7860")),
79
- share=False
80
- )
81
-
82
- if __name__ == "__main__":
83
- main()
 
 
1
  import asyncio
2
  import gradio as gr
3
  from core_creator.voice_to_app import VoiceToAppCreator
4
  from deployer.simulator_interface import VirtualRobot
5
  from deployer.revenue_tracker import package_artifacts
6
 
7
+ async def _run_pipeline(idea: str):
8
  """
9
+ Run the voice-to-app pipeline, package artifacts into a ZIP,
10
+ and return (status_message, zip_path).
11
  """
12
  creator = VoiceToAppCreator(idea)
13
  assets = creator.run_pipeline()
 
16
  status = f"βœ… Generated app: {title}"
17
  return status, zip_path
18
 
 
19
  def deploy_callback(idea: str):
20
  """
21
+ Gradio callback: generate the app and return status + ZIP path.
22
  """
23
+ return asyncio.run(_run_pipeline(idea))
 
24
 
25
  def robot_behavior(command: str) -> str:
26
  """
27
+ Gradio callback: simulate robot action from text command.
28
  """
29
  return VirtualRobot().perform_action(command)
30
 
31
+ def launch_gradio_app():
 
32
  """
33
+ Build and return the Gradio Blocks UI:
34
+ - Generate & Download App (left)
35
+ - Robot Simulator (right)
36
  """
37
  demo = gr.Blocks()
38
+
39
  with demo:
40
  gr.Markdown("# πŸš€ RoboSage\nGenerate your custom robot app and test it live.")
41
 
42
  with gr.Row():
43
+ # β€” Generate & Download App β€”
44
  with gr.Column():
45
  gr.Markdown("## 1️⃣ Generate & Download App")
46
  idea_input = gr.Textbox(
 
48
  placeholder="e.g. A friendly greeting robot.",
49
  lines=2
50
  )
51
+ gen_btn = gr.Button("Generate App")
52
  status_out = gr.Textbox(label="Status", interactive=False)
53
+ zip_out = gr.File(label="Download App ZIP")
54
 
55
  gen_btn.click(
56
  fn=deploy_callback,
 
58
  outputs=[status_out, zip_out]
59
  )
60
 
61
+ # β€” Robot Simulator β€”
62
  with gr.Column():
63
  gr.Markdown("## πŸ€– Robot Simulator")
64
  cmd_input = gr.Textbox(
65
+ label="Speak or Type Command",
66
  placeholder="hello or say You rock!",
67
  lines=1
68
  )
 
75
  outputs=[sim_out]
76
  )
77
 
78
+ return demo