mgbam commited on
Commit
a8f1886
·
verified ·
1 Parent(s): 6607bd7

Update deployer/gradio_generator.py

Browse files
Files changed (1) hide show
  1. deployer/gradio_generator.py +16 -31
deployer/gradio_generator.py CHANGED
@@ -1,42 +1,27 @@
1
- # gradio_generator.py - Gradio UI for Voice-to-App Creator
2
 
3
  import gradio as gr
4
  from core_creator.voice_to_app import VoiceToAppCreator
5
 
6
- def deploy_callback(voice_input):
7
- """
8
- Callback function to process voice input and generate the robot app package.
9
- """
10
- creator = VoiceToAppCreator(voice_input)
11
- app_package = creator.run_pipeline()
12
- return app_package
13
 
14
- def robot_behavior():
15
- """
16
- Defines the Gradio interface for the Voice-to-App Creator.
17
- """
18
- with gr.Blocks() as demo:
19
- gr.Markdown("# 🤖 Voice-to-App Creator")
20
- gr.Markdown("Describe your robot idea, and we'll generate an app for it!")
21
 
 
 
 
22
  with gr.Row():
23
- voice_input = gr.Textbox(
24
- label="Your Robot Idea",
25
- placeholder="e.g., Build a robot that teaches kids to brush their teeth with fun animations.",
26
- lines=3
27
- )
28
- submit_button = gr.Button("Generate App")
29
-
30
- output = gr.JSON(label="Generated App Package")
31
 
32
- submit_button.click(
33
- fn=deploy_callback,
34
- inputs=voice_input,
35
- outputs=output
36
- )
37
 
38
- return demo
39
 
40
  if __name__ == "__main__":
41
- demo = robot_behavior()
42
- demo.launch()
 
1
+ # gradio_generator.py - Launches the Gradio UI for robot app deployment
2
 
3
  import gradio as gr
4
  from core_creator.voice_to_app import VoiceToAppCreator
5
 
6
+ def deploy_callback(user_input: str) -> dict:
7
+ creator = VoiceToAppCreator(user_input)
8
+ return creator.run_pipeline()
 
 
 
 
9
 
10
+ def robot_behavior(user_input: str) -> str:
11
+ result = deploy_callback(user_input)
12
+ return result.get("code", "No code generated.")
 
 
 
 
13
 
14
+ def launch_gradio_interface():
15
+ with gr.Blocks() as demo:
16
+ gr.Markdown("# 🤖 Voice-to-Robot App Generator")
17
  with gr.Row():
18
+ input_box = gr.Textbox(label="Describe your robot idea", placeholder="e.g., A robot that helps kids brush their teeth.")
19
+ output_box = gr.Code(label="Generated Code", language="python")
20
+ submit_btn = gr.Button("Generate App")
 
 
 
 
 
21
 
22
+ submit_btn.click(fn=robot_behavior, inputs=input_box, outputs=output_box)
 
 
 
 
23
 
24
+ demo.launch()
25
 
26
  if __name__ == "__main__":
27
+ launch_gradio_interface()