Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -742,52 +742,52 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), css=custom_css) as ifac
|
|
| 742 |
user_id_state = gr.State(value="")
|
| 743 |
|
| 744 |
with gr.Row():
|
| 745 |
-
|
| 746 |
|
| 747 |
# ----- Click on Send button -----
|
| 748 |
-
|
| 749 |
-
|
| 750 |
-
|
| 751 |
-
|
| 752 |
-
|
| 753 |
-
|
| 754 |
-
|
| 755 |
-
|
| 756 |
-
|
| 757 |
-
|
| 758 |
-
|
| 759 |
-
|
| 760 |
-
|
| 761 |
-
|
| 762 |
# keep default queue=True here if you want streaming
|
| 763 |
-
|
| 764 |
-
|
| 765 |
-
|
| 766 |
-
|
| 767 |
-
|
| 768 |
-
|
| 769 |
|
| 770 |
# ----- Pressing Enter in the textbox -----
|
| 771 |
-
|
| 772 |
-
|
| 773 |
-
|
| 774 |
-
|
| 775 |
-
|
| 776 |
-
|
| 777 |
-
|
| 778 |
-
|
| 779 |
-
|
| 780 |
-
|
| 781 |
-
|
| 782 |
-
|
| 783 |
-
|
| 784 |
-
|
| 785 |
-
|
| 786 |
-
|
| 787 |
-
|
| 788 |
-
|
| 789 |
-
|
| 790 |
-
|
| 791 |
|
| 792 |
# Updated chatbot with type="messages" for streaming support
|
| 793 |
chatbot = gr.Chatbot(
|
|
|
|
| 742 |
user_id_state = gr.State(value="")
|
| 743 |
|
| 744 |
with gr.Row():
|
| 745 |
+
submit_btn = gr.Button(translations["Deutsch"]["submit_btn"], variant="primary")
|
| 746 |
|
| 747 |
# ----- Click on Send button -----
|
| 748 |
+
submit_btn.click(
|
| 749 |
+
fn=disable_input_components,
|
| 750 |
+
inputs=[],
|
| 751 |
+
outputs=[msg_input, submit_btn],
|
| 752 |
+
queue=False
|
| 753 |
+
).then(
|
| 754 |
+
fn=user_message_handler,
|
| 755 |
+
inputs=[msg_input, chatbot, user_id_input, user_id_state],
|
| 756 |
+
outputs=[msg_input, chatbot, user_id_input, user_id_state],
|
| 757 |
+
queue=False
|
| 758 |
+
).then(
|
| 759 |
+
fn=bot_response_handler,
|
| 760 |
+
inputs=[chatbot, user_id_input, user_id_state],
|
| 761 |
+
outputs=[chatbot, user_id_state],
|
| 762 |
# keep default queue=True here if you want streaming
|
| 763 |
+
).then(
|
| 764 |
+
fn=enable_input_components,
|
| 765 |
+
inputs=[],
|
| 766 |
+
outputs=[msg_input, submit_btn],
|
| 767 |
+
queue=False
|
| 768 |
+
)
|
| 769 |
|
| 770 |
# ----- Pressing Enter in the textbox -----
|
| 771 |
+
msg_input.submit(
|
| 772 |
+
fn=disable_input_components,
|
| 773 |
+
inputs=[],
|
| 774 |
+
outputs=[msg_input, submit_btn],
|
| 775 |
+
queue=False
|
| 776 |
+
).then(
|
| 777 |
+
fn=user_message_handler,
|
| 778 |
+
inputs=[msg_input, chatbot, user_id_input, user_id_state],
|
| 779 |
+
outputs=[msg_input, chatbot, user_id_input, user_id_state],
|
| 780 |
+
queue=False
|
| 781 |
+
).then(
|
| 782 |
+
fn=bot_response_handler,
|
| 783 |
+
inputs=[chatbot, user_id_input, user_id_state],
|
| 784 |
+
outputs=[chatbot, user_id_state],
|
| 785 |
+
).then(
|
| 786 |
+
fn=enable_input_components,
|
| 787 |
+
inputs=[],
|
| 788 |
+
outputs=[msg_input, submit_btn],
|
| 789 |
+
queue=False
|
| 790 |
+
)
|
| 791 |
|
| 792 |
# Updated chatbot with type="messages" for streaming support
|
| 793 |
chatbot = gr.Chatbot(
|