Update deployer/gradio_generator.py
Browse files- 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.
|
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(
|
21 |
-
|
22 |
-
|
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 |
-
|
29 |
-
|
|
|
30 |
|
31 |
-
|
32 |
|
33 |
-
|
|
|
34 |
|
35 |
-
|
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
|
|
|
|