jdesiree commited on
Commit
c4c901c
·
verified ·
1 Parent(s): a992b0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -14
app.py CHANGED
@@ -187,7 +187,7 @@ with gr.Blocks(theme=theme, css="""
187
  flex-shrink: 0;
188
  margin-top: 0.5rem;
189
  display: flex;
190
- justify-content: center;
191
  align-items: flex-end;
192
  gap: 10px;
193
  max-width: 700px;
@@ -227,13 +227,14 @@ with gr.Blocks(theme=theme, css="""
227
  }
228
 
229
  .send-button {
230
- border-radius: 50% !important;
231
- width: 50px !important;
232
- height: 50px !important;
233
- display: flex !important;
234
- align-items: center !important;
235
- justify-content: center !important;
236
- flex-shrink: 0 !important;
 
237
  }
238
 
239
  @media (max-width: 768px) {
@@ -297,12 +298,20 @@ with gr.Blocks(theme=theme, css="""
297
  send_btn = gr.Button("📤", variant="primary", elem_classes=["send-button"])
298
 
299
  def respond_and_update(message, history):
300
- for response in respond_with_enhanced_streaming(message, history):
301
- history.append([message, response])
302
- yield history, ""
303
-
304
- msg.submit(respond_and_update, [msg, chatbot], [chatbot, msg])
305
- send_btn.click(respond_and_update, [msg, chatbot], [chatbot, msg])
 
 
 
 
 
 
 
 
306
 
307
  if __name__ == "__main__":
308
  logger.info("Starting EduBot...")
 
187
  flex-shrink: 0;
188
  margin-top: 0.5rem;
189
  display: flex;
190
+ justify-content: stretch;
191
  align-items: flex-end;
192
  gap: 10px;
193
  max-width: 700px;
 
227
  }
228
 
229
  .send-button {
230
+ border-radius: 50% !important;
231
+ width: 50px !important;
232
+ height: 50px !important;
233
+ display: flex !important;
234
+ align-items: center !important;
235
+ justify-content: center !important;
236
+ flex-shrink: 0 !important;
237
+ align-self: flex-end !important;
238
  }
239
 
240
  @media (max-width: 768px) {
 
298
  send_btn = gr.Button("📤", variant="primary", elem_classes=["send-button"])
299
 
300
  def respond_and_update(message, history):
301
+ # Add the user's message to history with a placeholder for the bot's response
302
+ history.append([message, None])
303
+
304
+ # This first yield makes the user's message appear immediately
305
+ yield history, ""
306
+
307
+ full_response = ""
308
+ # Stream the bot's full response
309
+ for response_chunk in respond_with_enhanced_streaming(message, history):
310
+ full_response = response_chunk
311
+ # Continuously update the bot's message in the last row of history
312
+ history[-1][1] = full_response
313
+ # Yield the updated history and clear the input textbox
314
+ yield history, ""
315
 
316
  if __name__ == "__main__":
317
  logger.info("Starting EduBot...")