Spaces:
Sleeping
Sleeping
added file
Browse files
app.py
CHANGED
|
@@ -77,16 +77,30 @@ def chatbot_ui():
|
|
| 77 |
submit_btn = gr.Button("Submit")
|
| 78 |
clear_btn = gr.Button("Clear")
|
| 79 |
|
| 80 |
-
#
|
| 81 |
-
submit_btn.click(
|
| 82 |
customLLMBot,
|
| 83 |
-
inputs=[user_input
|
| 84 |
-
outputs=[chatbot, audio_output
|
| 85 |
)
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
# Clear button functionality
|
| 88 |
clear_btn.click(
|
| 89 |
-
lambda: ([], "", None),
|
| 90 |
inputs=[],
|
| 91 |
outputs=[chatbot, user_input, audio_output],
|
| 92 |
)
|
|
|
|
| 77 |
submit_btn = gr.Button("Submit")
|
| 78 |
clear_btn = gr.Button("Clear")
|
| 79 |
|
| 80 |
+
# Combine submit button and Enter key functionality
|
| 81 |
+
submit_action = submit_btn.click(
|
| 82 |
customLLMBot,
|
| 83 |
+
inputs=[user_input],
|
| 84 |
+
outputs=[chatbot, audio_output],
|
| 85 |
)
|
| 86 |
|
| 87 |
+
user_input_action = user_input.submit(
|
| 88 |
+
customLLMBot,
|
| 89 |
+
inputs=[user_input],
|
| 90 |
+
outputs=[chatbot, audio_output],
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
# Reset the textbox after submission
|
| 94 |
+
for action in [submit_action, user_input_action]:
|
| 95 |
+
action.then(
|
| 96 |
+
lambda: "", # Clear input box
|
| 97 |
+
inputs=[],
|
| 98 |
+
outputs=user_input,
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
# Clear button functionality
|
| 102 |
clear_btn.click(
|
| 103 |
+
lambda: ([], "", None, [], None),
|
| 104 |
inputs=[],
|
| 105 |
outputs=[chatbot, user_input, audio_output],
|
| 106 |
)
|