brunhild217 commited on
Commit
212e48a
·
1 Parent(s): 1e94f96

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -61,17 +61,18 @@ def get_tutor_reply(chat_tutor):
61
  return chat_tutor.conversation_memory, chat_tutor
62
 
63
  # history is a list of list [[user_input_str, bot_response_str], ...]
64
- def user(message, history):
65
- return "", history + [[message, None]]
66
 
67
  def bot(history):
68
  user_message = history[-1][0]
69
- tutor_message = "You typed: " + user_message
70
-
 
71
 
72
  with gr.Blocks() as demo:
73
  #initialize tutor (with state)
74
- study_tutor = gr.State(BasicTutor())
75
 
76
  # Chatbot interface
77
  gr.Markdown("""
@@ -85,13 +86,12 @@ with gr.Blocks() as demo:
85
  with gr.Row():
86
  user_chat_input = gr.Textbox(label="User input", scale=9)
87
  user_chat_submit = gr.Button("Ask/answer model", scale=1)
 
 
88
 
89
-
90
- async_response = user_chat_submit.click(add_user_message,
91
- [user_chat_input, study_tutor],
92
- [user_chat_input, chatbot, study_tutor], queue=False) \
93
- .then(get_tutor_reply, [study_tutor], [user_chat_input, chatbot, study_tutor], queue=True)
94
-
95
 
96
  with gr.Blocks():
97
  gr.Markdown("""
 
61
  return chat_tutor.conversation_memory, chat_tutor
62
 
63
  # history is a list of list [[user_input_str, bot_response_str], ...]
64
+ def user(user_message, history):
65
+ return "", history + [[user_message, None]]
66
 
67
  def bot(history):
68
  user_message = history[-1][0]
69
+ bot_message = "You typed: " + user_message
70
+ history[-1][1] = bot_message
71
+ return history
72
 
73
  with gr.Blocks() as demo:
74
  #initialize tutor (with state)
75
+ #study_tutor = gr.State(BasicTutor())
76
 
77
  # Chatbot interface
78
  gr.Markdown("""
 
86
  with gr.Row():
87
  user_chat_input = gr.Textbox(label="User input", scale=9)
88
  user_chat_submit = gr.Button("Ask/answer model", scale=1)
89
+ with gr.Column():
90
+ clear = gr.Button("Clear")
91
 
92
+ user_chat_submit.click(user, [user_chat_input, chatbot], [user_chat_input, chatbot], queue=False).then(
93
+ bot, chatbot, chatbot
94
+ )
 
 
 
95
 
96
  with gr.Blocks():
97
  gr.Markdown("""