mgbam commited on
Commit
6b0956e
Β·
verified Β·
1 Parent(s): ea3d5fc

Update deployer/gradio_generator.py

Browse files
Files changed (1) hide show
  1. deployer/gradio_generator.py +25 -36
deployer/gradio_generator.py CHANGED
@@ -1,53 +1,42 @@
1
- # gradio_generator.py - Gradio interface for voice-to-robot app generation
2
 
3
  import gradio as gr
4
  from core_creator.voice_to_app import VoiceToAppCreator
5
 
6
- def deploy_callback(voice_input: str) -> dict:
7
  """
8
- Processes the user's voice input to generate a robot app package.
9
  """
10
  creator = VoiceToAppCreator(voice_input)
11
  app_package = creator.run_pipeline()
12
  return app_package
13
 
14
- def robot_behavior(voice_input: str) -> str:
15
  """
16
- Generates a summary of the robot's behavior based on the voice input.
17
  """
18
- creator = VoiceToAppCreator(voice_input)
19
- app_package = creator.run_pipeline()
20
- return app_package["blueprint"].get("description", "No description available.")
21
-
22
- # Gradio Interface
23
- with gr.Blocks() as demo:
24
- gr.Markdown("# πŸ€– Voice-to-Robot App Generator")
25
- gr.Markdown("Describe your robot idea, and we'll generate an app blueprint for you.")
26
-
27
- with gr.Row():
28
- voice_input = gr.Textbox(label="πŸ—£οΈ Your Robot Idea", placeholder="e.g., A robot that helps with home cleaning tasks.")
29
- submit_btn = gr.Button("Generate App")
30
-
31
- with gr.Row():
32
- intent_output = gr.Textbox(label="πŸ” Detected Intent")
33
- description_output = gr.Textbox(label="πŸ“„ App Description")
34
- code_output = gr.Code(label="πŸ’» Generated Code", language="python")
35
- assets_output = gr.JSON(label="🎨 Visual/Audio Assets")
36
-
37
- def process_input(user_input):
38
- app_package = deploy_callback(user_input)
39
- return (
40
- app_package.get("intent", ""),
41
- app_package["blueprint"].get("description", ""),
42
- app_package.get("code", ""),
43
- app_package.get("assets", {})
44
  )
45
 
46
- submit_btn.click(
47
- fn=process_input,
48
- inputs=voice_input,
49
- outputs=[intent_output, description_output, code_output, assets_output]
50
- )
51
 
52
  if __name__ == "__main__":
 
53
  demo.launch()
 
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()