mgbam commited on
Commit
b4299eb
Β·
verified Β·
1 Parent(s): 96fba25

Update deployer/gradio_generator.py

Browse files
Files changed (1) hide show
  1. deployer/gradio_generator.py +30 -36
deployer/gradio_generator.py CHANGED
@@ -1,38 +1,38 @@
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()
 
 
14
  title = assets.get("blueprint", {}).get("title", "<unknown>")
 
 
15
  zip_path = package_artifacts(assets)
 
 
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
 
@@ -43,36 +43,30 @@ def launch_gradio_app():
43
  # β€” Generate & Download App β€”
44
  with gr.Column():
45
  gr.Markdown("## 1️⃣ Generate & Download App")
46
- idea_input = gr.Textbox(
47
- label="Your Robot Idea",
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,
57
- inputs=[idea_input],
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
- )
69
- sim_btn = gr.Button("Send")
70
  sim_out = gr.Textbox(label="Robot Response", lines=4, interactive=False)
71
 
72
- sim_btn.click(
73
- fn=robot_behavior,
74
- inputs=[cmd_input],
75
- outputs=[sim_out]
76
- )
77
 
78
  return demo
 
 
1
  import gradio as gr
2
  from core_creator.voice_to_app import VoiceToAppCreator
3
  from deployer.simulator_interface import VirtualRobot
4
  from deployer.revenue_tracker import package_artifacts
5
 
6
+ def deploy_callback(idea: str):
7
  """
8
+ Generate the app from the user idea, package artifacts into a ZIP,
9
+ and return a (status_message, zip_path) tuple.
10
  """
11
+ # 1. Run the core pipeline
12
  creator = VoiceToAppCreator(idea)
13
  assets = creator.run_pipeline()
14
+
15
+ # 2. Extract a title for status display
16
  title = assets.get("blueprint", {}).get("title", "<unknown>")
17
+
18
+ # 3. Package everything into app_package.zip
19
  zip_path = package_artifacts(assets)
20
+
21
+ # 4. Return status message and ZIP filepath
22
  status = f"βœ… Generated app: {title}"
23
  return status, zip_path
24
 
 
 
 
 
 
 
25
  def robot_behavior(command: str) -> str:
26
  """
27
+ Simulate robot action based on a 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
+ - Left column: generate & download
35
+ - Right column: robot simulator
36
  """
37
  demo = gr.Blocks()
38
 
 
43
  # β€” Generate & Download App β€”
44
  with gr.Column():
45
  gr.Markdown("## 1️⃣ Generate & Download App")
46
+ idea_in = gr.Textbox(label="Your Robot Idea",
47
+ placeholder="e.g. A friendly greeting robot.",
48
+ lines=2)
 
 
49
  gen_btn = gr.Button("Generate App")
50
+ status_out= gr.Textbox(label="Status", interactive=False)
51
+ zip_out = gr.File(label="Download App ZIP")
52
 
53
+ # Wire up generation β†’ status + ZIP
54
+ gen_btn.click(fn=deploy_callback,
55
+ inputs=[idea_in],
56
+ outputs=[status_out, zip_out])
 
57
 
58
  # β€” Robot Simulator β€”
59
  with gr.Column():
60
  gr.Markdown("## πŸ€– Robot Simulator")
61
+ cmd_in = gr.Textbox(label="Command",
62
+ placeholder="hello or say You rock!",
63
+ lines=1)
64
+ sim_btn = gr.Button("Send Command")
 
 
65
  sim_out = gr.Textbox(label="Robot Response", lines=4, interactive=False)
66
 
67
+ # Wire up simulator
68
+ sim_btn.click(fn=robot_behavior,
69
+ inputs=[cmd_in],
70
+ outputs=[sim_out])
 
71
 
72
  return demo