Update deployer/gradio_generator.py
Browse files- deployer/gradio_generator.py +19 -17
deployer/gradio_generator.py
CHANGED
@@ -12,35 +12,37 @@ def robot_behavior(user_input: str):
|
|
12 |
return bot.perform_action(text)
|
13 |
return bot.perform_action("say I didn't understand that. Try again!")
|
14 |
|
15 |
-
def
|
16 |
-
"""Create
|
17 |
with gr.Blocks() as demo:
|
18 |
-
gr.Markdown(
|
19 |
|
20 |
-
# Input/Output components
|
21 |
with gr.Row():
|
22 |
-
|
23 |
-
|
24 |
|
25 |
-
|
26 |
|
27 |
-
# Event
|
28 |
-
|
29 |
fn=robot_behavior,
|
30 |
-
inputs=
|
31 |
-
outputs=
|
32 |
-
api_name="process_command"
|
33 |
)
|
34 |
|
35 |
-
|
36 |
-
inp.submit(
|
37 |
fn=robot_behavior,
|
38 |
-
inputs=
|
39 |
-
outputs=
|
40 |
)
|
41 |
-
|
42 |
return demo
|
43 |
|
|
|
|
|
|
|
|
|
|
|
44 |
if __name__ == "__main__":
|
45 |
app = launch_gradio_app()
|
46 |
app.launch(
|
|
|
12 |
return bot.perform_action(text)
|
13 |
return bot.perform_action("say I didn't understand that. Try again!")
|
14 |
|
15 |
+
def create_interface():
|
16 |
+
"""Create the Gradio interface components"""
|
17 |
with gr.Blocks() as demo:
|
18 |
+
gr.Markdown("# 🤖 RoboSage App\n\nYour robot, your voice.")
|
19 |
|
|
|
20 |
with gr.Row():
|
21 |
+
input_text = gr.Textbox(label="Speak or Type", lines=1)
|
22 |
+
send_button = gr.Button("Send", variant="primary")
|
23 |
|
24 |
+
output_text = gr.Textbox(label="Robot Response", interactive=False)
|
25 |
|
26 |
+
# Event handlers
|
27 |
+
send_button.click(
|
28 |
fn=robot_behavior,
|
29 |
+
inputs=input_text,
|
30 |
+
outputs=output_text
|
|
|
31 |
)
|
32 |
|
33 |
+
input_text.submit(
|
|
|
34 |
fn=robot_behavior,
|
35 |
+
inputs=input_text,
|
36 |
+
outputs=output_text
|
37 |
)
|
38 |
+
|
39 |
return demo
|
40 |
|
41 |
+
def launch_gradio_app(title="RoboSage App", description="Your robot, your voice."):
|
42 |
+
"""Launch the Gradio application"""
|
43 |
+
interface = create_interface()
|
44 |
+
return interface
|
45 |
+
|
46 |
if __name__ == "__main__":
|
47 |
app = launch_gradio_app()
|
48 |
app.launch(
|