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

Update deployer/gradio_generator.py

Browse files
Files changed (1) hide show
  1. deployer/gradio_generator.py +11 -31
deployer/gradio_generator.py CHANGED
@@ -1,37 +1,17 @@
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
5
-
6
- # Robot behavior logic
7
- def robot_behavior(user_input: str):
8
- bot = VirtualRobot()
9
- user_input = user_input.lower().strip()
10
-
11
- if any(greet in user_input for greet in ["hello", "hi", "hey", "welcome"]):
12
- return bot.perform_action("wave") + "\n" + bot.perform_action("say Hello there!")
13
- elif user_input.startswith("say"):
14
- return bot.perform_action(user_input)
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()
37
- app.launch()
 
 
 
1
  import gradio as gr
2
+ from deployer.real_robot_bridge import robot_behavior
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
+ def launch_gradio_app():
5
+ with gr.Blocks() as demo:
6
+ gr.Markdown("## 🤖 Robot App Control Panel")
 
 
 
 
7
 
8
+ with gr.Row():
9
+ inp = gr.Textbox(label="Give your robot a task...")
10
+ out = gr.Textbox(label="Robot response", interactive=False)
11
 
12
+ btn = gr.Button("🟢 Run Robot")
13
 
14
+ # IMPORTANT: attach callback inside the same gr.Blocks() context
15
+ btn.click(fn=robot_behavior, inputs=[inp], outputs=[out])
16
 
17
+ return demo