Update app.py
Browse files
app.py
CHANGED
|
@@ -83,11 +83,11 @@ def chatbot_with_error_handling(user_input, history, chat_session):
|
|
| 83 |
gradio_history = [[msg["role"], msg["content"]] for msg in history]
|
| 84 |
return gradio_history, history, chat_session
|
| 85 |
|
| 86 |
-
#interface
|
| 87 |
with gr.Blocks() as demo:
|
| 88 |
-
gr.Markdown("# Chatbot de Estadística \nInteractúa con un tutor experto en estadística básica.
|
| 89 |
-
|
| 90 |
-
chatbot_interface = gr.Chatbot(
|
| 91 |
state = gr.State([]) # For chat history
|
| 92 |
chat_session = gr.State(None) # For the chat session
|
| 93 |
|
|
@@ -95,11 +95,10 @@ with gr.Blocks() as demo:
|
|
| 95 |
txt = gr.Textbox(show_label=False, placeholder="Escribe tu pregunta aquí...")
|
| 96 |
send_button = gr.Button("Enviar")
|
| 97 |
|
| 98 |
-
# Add functionality to reset the text input after submission
|
| 99 |
txt.submit(chatbot_with_error_handling, [txt, state, chat_session], [chatbot_interface, state, chat_session])
|
| 100 |
-
txt.submit(lambda: "", None, txt) # Clear
|
| 101 |
|
| 102 |
send_button.click(chatbot_with_error_handling, [txt, state, chat_session], [chatbot_interface, state, chat_session])
|
| 103 |
-
send_button.click(lambda: "", None, txt)
|
| 104 |
|
| 105 |
demo.launch()
|
|
|
|
| 83 |
gradio_history = [[msg["role"], msg["content"]] for msg in history]
|
| 84 |
return gradio_history, history, chat_session
|
| 85 |
|
| 86 |
+
# User interface
|
| 87 |
with gr.Blocks() as demo:
|
| 88 |
+
gr.Markdown("# Chatbot de Estadística 📊\\nInteractúa con un tutor experto en estadística básica.")
|
| 89 |
+
|
| 90 |
+
chatbot_interface = gr.Chatbot() # Gradio's Chatbot element, customized with rendering
|
| 91 |
state = gr.State([]) # For chat history
|
| 92 |
chat_session = gr.State(None) # For the chat session
|
| 93 |
|
|
|
|
| 95 |
txt = gr.Textbox(show_label=False, placeholder="Escribe tu pregunta aquí...")
|
| 96 |
send_button = gr.Button("Enviar")
|
| 97 |
|
|
|
|
| 98 |
txt.submit(chatbot_with_error_handling, [txt, state, chat_session], [chatbot_interface, state, chat_session])
|
| 99 |
+
txt.submit(lambda: "", None, txt) # Clear input box
|
| 100 |
|
| 101 |
send_button.click(chatbot_with_error_handling, [txt, state, chat_session], [chatbot_interface, state, chat_session])
|
| 102 |
+
send_button.click(lambda: "", None, txt)
|
| 103 |
|
| 104 |
demo.launch()
|