VanYsa commited on
Commit
44b21fc
·
1 Parent(s): 51d905f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -128,6 +128,14 @@ def transcribe(audio_filepath):
128
 
129
  return output_text
130
 
 
 
 
 
 
 
 
 
131
  def bot(history, message):
132
  """
133
  Gets the bot's response and places the user and bot messages in the chatbot
@@ -136,8 +144,6 @@ def bot(history, message):
136
  response = bot_response(message, history)
137
  lines = response.split("\n")
138
  complete_lines = '\n'.join(lines[2:])
139
- history.append((message, None))
140
- yield history
141
  answer = ""
142
  for character in complete_lines:
143
  answer += character
@@ -219,10 +225,8 @@ with gr.Blocks(
219
  visible=True
220
  )
221
 
222
- # chat_msg = chat_input.change(add_message, [chatbot, chat_input], [chatbot])
223
- bot_msg = chat_input.change(bot, [chatbot, chat_input], chatbot, api_name="bot_response")
224
- # bot_msg.then(lambda: gr.Textbox(interactive=False), None, [chat_input])
225
-
226
 
227
  submit_button.click(
228
  fn=transcribe,
 
128
 
129
  return output_text
130
 
131
+ def add_message(history, message):
132
+ """
133
+ Adds the input message in the chatbot.
134
+ Returns the updated chatbot history.
135
+ """
136
+ history.append((message, None))
137
+ return history
138
+
139
  def bot(history, message):
140
  """
141
  Gets the bot's response and places the user and bot messages in the chatbot
 
144
  response = bot_response(message, history)
145
  lines = response.split("\n")
146
  complete_lines = '\n'.join(lines[2:])
 
 
147
  answer = ""
148
  for character in complete_lines:
149
  answer += character
 
225
  visible=True
226
  )
227
 
228
+ chat_msg = chat_input.change(add_message, [chatbot, chat_input], [chatbot])
229
+ bot_msg = chat_msg.then(bot, [chatbot, chat_input], chatbot, api_name="bot_response")
 
 
230
 
231
  submit_button.click(
232
  fn=transcribe,