mgbam commited on
Commit
1cb22ca
·
verified ·
1 Parent(s): 134db29

Update deployer/gradio_generator.py

Browse files
Files changed (1) hide show
  1. deployer/gradio_generator.py +5 -4
deployer/gradio_generator.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import gradio as gr
2
  from deployer.simulator_interface import VirtualRobot
3
 
@@ -13,7 +15,7 @@ def robot_behavior(user_input: str):
13
  else:
14
  return bot.perform_action("say I didn't understand that. Try again!")
15
 
16
- # Build Gradio app (correct order)
17
  def launch_gradio_app(title="RoboSage App", description="Your robot, your voice."):
18
  with gr.Blocks() as demo:
19
  gr.Markdown(f"# 🤖 {title}\n{description}")
@@ -22,12 +24,11 @@ def launch_gradio_app(title="RoboSage App", description="Your robot, your voice.
22
  out = gr.Textbox(label="Robot Response")
23
  btn = gr.Button("Send")
24
 
25
- # 🔧 Must be called after all are inside the Blocks layout
26
- btn.click(fn=robot_behavior, inputs=inp, outputs=out)
27
 
28
  return demo
29
 
30
- # For local testing
31
  if __name__ == "__main__":
32
  app = launch_gradio_app()
33
  app.launch()
 
1
+ # gradio_generator.py - FINAL version for Gradio Spaces and v4.17+
2
+
3
  import gradio as gr
4
  from deployer.simulator_interface import VirtualRobot
5
 
 
15
  else:
16
  return bot.perform_action("say I didn't understand that. Try again!")
17
 
18
+ # Build Gradio app properly
19
  def launch_gradio_app(title="RoboSage App", description="Your robot, your voice."):
20
  with gr.Blocks() as demo:
21
  gr.Markdown(f"# 🤖 {title}\n{description}")
 
24
  out = gr.Textbox(label="Robot Response")
25
  btn = gr.Button("Send")
26
 
27
+ # Must wire after all elements are declared and rendered
28
+ btn.click(fn=robot_behavior, inputs=[inp], outputs=[out])
29
 
30
  return demo
31
 
 
32
  if __name__ == "__main__":
33
  app = launch_gradio_app()
34
  app.launch()