Update deployer/gradio_generator.py
Browse files
deployer/gradio_generator.py
CHANGED
|
@@ -11,17 +11,17 @@ def robot_behavior(user_input: str):
|
|
| 11 |
return bot.perform_action(text)
|
| 12 |
return bot.perform_action("say I didn't understand that. Try again!")
|
| 13 |
|
| 14 |
-
# Build Gradio app with
|
| 15 |
def launch_gradio_app(title="RoboSage App", description="Your robot, your voice."):
|
| 16 |
with gr.Blocks() as demo:
|
| 17 |
gr.Markdown(f"# 🤖 {title}\n\n{description}")
|
| 18 |
|
| 19 |
-
# Define components
|
| 20 |
inp = gr.Textbox(label="Speak or Type", lines=1)
|
| 21 |
out = gr.Textbox(label="Robot Response")
|
| 22 |
btn = gr.Button("Send", key="send-btn")
|
| 23 |
|
| 24 |
-
# Wire event inside the same Blocks context
|
| 25 |
btn.click(fn=robot_behavior, inputs=[inp], outputs=[out])
|
| 26 |
|
| 27 |
return demo
|
|
|
|
| 11 |
return bot.perform_action(text)
|
| 12 |
return bot.perform_action("say I didn't understand that. Try again!")
|
| 13 |
|
| 14 |
+
# Build Gradio app with correct Blocks context
|
| 15 |
def launch_gradio_app(title="RoboSage App", description="Your robot, your voice."):
|
| 16 |
with gr.Blocks() as demo:
|
| 17 |
gr.Markdown(f"# 🤖 {title}\n\n{description}")
|
| 18 |
|
| 19 |
+
# Define components without trailing commas
|
| 20 |
inp = gr.Textbox(label="Speak or Type", lines=1)
|
| 21 |
out = gr.Textbox(label="Robot Response")
|
| 22 |
btn = gr.Button("Send", key="send-btn")
|
| 23 |
|
| 24 |
+
# Wire the click event inside the same Blocks context
|
| 25 |
btn.click(fn=robot_behavior, inputs=[inp], outputs=[out])
|
| 26 |
|
| 27 |
return demo
|