Katieearl1513 commited on
Commit
8d49874
·
verified ·
1 Parent(s): a68799b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
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. Tus preguntas deben ser en castellano o catalán.")
89
-
90
- chatbot_interface = gr.Chatbot(label="Asistente de Estadística")
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 the input box
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) # Clear the input box
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()