mgbam commited on
Commit
e8ee41e
Β·
verified Β·
1 Parent(s): f69fdac

Update deployer/gradio_generator.py

Browse files
Files changed (1) hide show
  1. deployer/gradio_generator.py +36 -67
deployer/gradio_generator.py CHANGED
@@ -1,97 +1,66 @@
1
- # deployer/gradio_generator.py
2
-
3
- import asyncio
4
  import gradio as gr
5
-
6
  from core_creator.voice_to_app import VoiceToAppCreator
7
  from deployer.simulator_interface import VirtualRobot
8
  from deployer.revenue_tracker import package_artifacts
9
 
10
- async def _run_pipeline(idea: str) -> str:
11
  """
12
- Asynchronously run the voice→app pipeline and return a status message.
 
13
  """
14
  creator = VoiceToAppCreator(idea)
15
  assets = creator.run_pipeline()
16
  title = assets.get("blueprint", {}).get("title", "<unknown>")
17
- return f"βœ… Generated app: {title}"
18
-
19
- def deploy_callback(idea: str) -> str:
20
- """
21
- Synchronous wrapper for Gradio: generate the app.
22
- """
23
- return asyncio.run(_run_pipeline(idea))
24
-
25
- def robot_behavior(user_input: str) -> str:
26
- """
27
- Simulate robot action based on a user command.
28
- """
29
- return VirtualRobot().perform_action(user_input)
30
 
31
- def download_callback() -> str:
32
  """
33
- Package all generated app artifacts into a ZIP and return its file path.
34
  """
35
- zip_path = package_artifacts()
36
- return zip_path
37
 
38
- def launch_gradio_app() -> gr.Blocks:
39
  """
40
- Build and return the Gradio interface.
41
  """
42
- demo = gr.Blocks()
43
- with demo:
44
- gr.Markdown(
45
- "## πŸš€ RoboSage \n"
46
- "Generate your custom robot app and test it live."
47
- )
48
 
49
  with gr.Row():
50
- # β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
51
- # 1️⃣ Generate App + Download ZIP
52
- # β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
53
- with gr.Column(scale=1):
54
- gr.Markdown("### 1️⃣ Generate App")
55
  idea_input = gr.Textbox(
56
- label="Your Robot Idea",
57
- placeholder="e.g. A friendly greeting robot."
 
58
  )
59
- gen_btn = gr.Button("Generate App")
60
- status_out = gr.Textbox(label="Status", interactive=False)
 
61
 
62
- gen_btn.click(
63
  fn=deploy_callback,
64
- inputs=[idea_input],
65
- outputs=[status_out]
66
- )
67
-
68
- download_btn = gr.Button("πŸ“¦ Download App ZIP")
69
- zip_out = gr.File(label="Your App ZIP")
70
-
71
- download_btn.click(
72
- fn=download_callback,
73
- outputs=[zip_out]
74
  )
75
 
76
- # β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
77
- # 2️⃣ Robot Simulator
78
- # β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
79
- with gr.Column(scale=1):
80
- gr.Markdown("### 2️⃣ Robot Simulator")
81
- cmd_input = gr.Textbox(
82
- label="Speak or Type Command",
83
- placeholder="hello or say You rock!"
84
  )
85
- send_btn = gr.Button("Send")
86
- resp_out = gr.Textbox(label="Robot Response", lines=4, interactive=False)
87
 
88
- send_btn.click(
89
  fn=robot_behavior,
90
- inputs=[cmd_input],
91
- outputs=[resp_out]
92
  )
93
 
94
  return demo
95
-
96
- if __name__ == "__main__":
97
- launch_gradio_app().launch()
 
1
+ import os
 
 
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
+ def deploy_callback(idea: str):
8
  """
9
+ Generates the app based on the provided idea and packages it into a ZIP file.
10
+ Returns a status message and the path to the ZIP file.
11
  """
12
  creator = VoiceToAppCreator(idea)
13
  assets = creator.run_pipeline()
14
  title = assets.get("blueprint", {}).get("title", "<unknown>")
15
+ zip_path = package_artifacts(assets)
16
+ status_msg = f"βœ… Generated app: {title}"
17
+ return status_msg, zip_path
 
 
 
 
 
 
 
 
 
 
18
 
19
+ def robot_behavior(command: str) -> str:
20
  """
21
+ Simulates robot action based on a text command.
22
  """
23
+ return VirtualRobot().perform_action(command)
 
24
 
25
+ def launch_gradio_app():
26
  """
27
+ Builds and returns the Gradio Blocks UI for the RoboSage app.
28
  """
29
+ with gr.Blocks() as demo:
30
+ gr.Markdown("# πŸ€– RoboSage: Your Personal Robot App Generator")
 
 
 
 
31
 
32
  with gr.Row():
33
+ with gr.Column():
34
+ gr.Markdown("### πŸ› οΈ Generate Your Robot App")
 
 
 
35
  idea_input = gr.Textbox(
36
+ label="Enter your robot idea",
37
+ placeholder="e.g., A friendly greeting robot.",
38
+ lines=2
39
  )
40
+ generate_button = gr.Button("Generate App")
41
+ status_output = gr.Textbox(label="Status", interactive=False)
42
+ download_output = gr.File(label="Download App ZIP")
43
 
44
+ generate_button.click(
45
  fn=deploy_callback,
46
+ inputs=idea_input,
47
+ outputs=[status_output, download_output]
 
 
 
 
 
 
 
 
48
  )
49
 
50
+ with gr.Column():
51
+ gr.Markdown("### πŸ€– Robot Simulator")
52
+ command_input = gr.Textbox(
53
+ label="Enter command",
54
+ placeholder="e.g., say Hello World!",
55
+ lines=1
 
 
56
  )
57
+ send_button = gr.Button("Send Command")
58
+ response_output = gr.Textbox(label="Robot Response", interactive=False)
59
 
60
+ send_button.click(
61
  fn=robot_behavior,
62
+ inputs=command_input,
63
+ outputs=response_output
64
  )
65
 
66
  return demo