mgbam commited on
Commit
839548e
·
verified ·
1 Parent(s): a294fd3

Update deployer/gradio_generator.py

Browse files
Files changed (1) hide show
  1. deployer/gradio_generator.py +19 -17
deployer/gradio_generator.py CHANGED
@@ -12,35 +12,37 @@ def robot_behavior(user_input: str):
12
  return bot.perform_action(text)
13
  return bot.perform_action("say I didn't understand that. Try again!")
14
 
15
- def launch_gradio_app(title="RoboSage App", description="Your robot, your voice."):
16
- """Create and configure the Gradio interface"""
17
  with gr.Blocks() as demo:
18
- gr.Markdown(f"# 🤖 {title}\n\n{description}")
19
 
20
- # Input/Output components
21
  with gr.Row():
22
- inp = gr.Textbox(label="Speak or Type", lines=1)
23
- btn = gr.Button("Send", variant="primary")
24
 
25
- out = gr.Textbox(label="Robot Response", interactive=False)
26
 
27
- # Event handling
28
- btn.click(
29
  fn=robot_behavior,
30
- inputs=inp,
31
- outputs=out,
32
- api_name="process_command"
33
  )
34
 
35
- # Additional UX improvements
36
- inp.submit(
37
  fn=robot_behavior,
38
- inputs=inp,
39
- outputs=out
40
  )
41
-
42
  return demo
43
 
 
 
 
 
 
44
  if __name__ == "__main__":
45
  app = launch_gradio_app()
46
  app.launch(
 
12
  return bot.perform_action(text)
13
  return bot.perform_action("say I didn't understand that. Try again!")
14
 
15
+ def create_interface():
16
+ """Create the Gradio interface components"""
17
  with gr.Blocks() as demo:
18
+ gr.Markdown("# 🤖 RoboSage App\n\nYour robot, your voice.")
19
 
 
20
  with gr.Row():
21
+ input_text = gr.Textbox(label="Speak or Type", lines=1)
22
+ send_button = gr.Button("Send", variant="primary")
23
 
24
+ output_text = gr.Textbox(label="Robot Response", interactive=False)
25
 
26
+ # Event handlers
27
+ send_button.click(
28
  fn=robot_behavior,
29
+ inputs=input_text,
30
+ outputs=output_text
 
31
  )
32
 
33
+ input_text.submit(
 
34
  fn=robot_behavior,
35
+ inputs=input_text,
36
+ outputs=output_text
37
  )
38
+
39
  return demo
40
 
41
+ def launch_gradio_app(title="RoboSage App", description="Your robot, your voice."):
42
+ """Launch the Gradio application"""
43
+ interface = create_interface()
44
+ return interface
45
+
46
  if __name__ == "__main__":
47
  app = launch_gradio_app()
48
  app.launch(