mgbam commited on
Commit
376658d
·
verified ·
1 Parent(s): 1cb22ca

Update deployer/gradio_generator.py

Browse files
Files changed (1) hide show
  1. deployer/gradio_generator.py +13 -10
deployer/gradio_generator.py CHANGED
@@ -1,4 +1,4 @@
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
@@ -15,19 +15,22 @@ def robot_behavior(user_input: str):
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}")
 
 
 
 
22
 
23
- inp = gr.Textbox(label="Speak or Type", lines=1)
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()
 
1
+ # gradio_generator.py - FINAL FIXED FOR CPU + SPACES (No _id bug)
2
 
3
  import gradio as gr
4
  from deployer.simulator_interface import VirtualRobot
 
15
  else:
16
  return bot.perform_action("say I didn't understand that. Try again!")
17
 
18
+ # Build Gradio app
19
+
20
  def launch_gradio_app(title="RoboSage App", description="Your robot, your voice."):
21
+ def build():
22
+ with gr.Blocks() as demo:
23
+ gr.Markdown(f"# 🤖 {title}\n{description}")
24
+ inp = gr.Textbox(label="Speak or Type", lines=1)
25
+ out = gr.Textbox(label="Robot Response")
26
+ btn = gr.Button("Send")
27
 
28
+ # Attach event inside context
29
+ btn.click(fn=robot_behavior, inputs=inp, outputs=out)
 
30
 
31
+ return demo
 
32
 
33
+ return build()
34
 
35
  if __name__ == "__main__":
36
  app = launch_gradio_app()