Update deployer/gradio_generator.py
Browse files- deployer/gradio_generator.py +13 -10
deployer/gradio_generator.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
# gradio_generator.py - FINAL
|
| 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
|
|
|
|
| 19 |
def launch_gradio_app(title="RoboSage App", description="Your robot, your voice."):
|
| 20 |
-
|
| 21 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
btn = gr.Button("Send")
|
| 26 |
|
| 27 |
-
|
| 28 |
-
btn.click(fn=robot_behavior, inputs=[inp], outputs=[out])
|
| 29 |
|
| 30 |
-
return
|
| 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()
|