melk2025 commited on
Commit
3fe8688
·
verified ·
1 Parent(s): e008b5f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -261,20 +261,19 @@ def ask(user_message, chat_history):
261
  return chat_history
262
 
263
  # Initialize chat history with a welcome messageinitial_message = (None, "Hello, how can I help you with Moodle?")
 
264
 
265
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
266
  chat_history = gr.State([initial_message])
267
 
268
- chatbot_ui = gr.Chatbot()
269
  question = gr.Textbox(placeholder="Ask me anything about Moodle...", show_label=False)
270
  clear_button = gr.Button("Clear")
271
  save_button = gr.Button("Save Chat")
272
 
273
- question.submit(ask, [question, chat_history], [chatbot_ui, chat_history])
274
- clear_button.click(
275
- lambda: ([initial_message], [initial_message], ""),
276
- None,
277
- [chatbot_ui, chat_history, question],
278
- queue=False
279
- )
280
  save_button.click(save_chat_to_file, [chat_history], gr.File(label="Download your chat history"))
 
 
 
 
261
  return chat_history
262
 
263
  # Initialize chat history with a welcome messageinitial_message = (None, "Hello, how can I help you with Moodle?")
264
+ initial_message = (None, "Hello, how can I help you with Moodle?")
265
 
266
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
267
  chat_history = gr.State([initial_message])
268
 
269
+ chatbot_ui = gr.Chatbot(value=[initial_message])
270
  question = gr.Textbox(placeholder="Ask me anything about Moodle...", show_label=False)
271
  clear_button = gr.Button("Clear")
272
  save_button = gr.Button("Save Chat")
273
 
274
+ question.submit(ask, [question, chat_history], [chatbot_ui, chat_history, question])
275
+ clear_button.click(lambda: ([initial_message], [initial_message], ""), None, [chatbot_ui, chat_history, question], queue=False)
 
 
 
 
 
276
  save_button.click(save_chat_to_file, [chat_history], gr.File(label="Download your chat history"))
277
+
278
+ demo.queue()
279
+ demo.launch(share=False)