fCola commited on
Commit
28862d9
·
verified ·
1 Parent(s): ba46254

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -518,7 +518,7 @@ database = {k.lower(): v for k, v in database.items()}
518
 
519
  def send_message(message, history):
520
  history.append({"role": "user", "content": message})
521
-
522
  # Recupera contesto extra se esiste
523
  if message.lower() in database:
524
  context = random.choice(database[message.lower()])
@@ -528,7 +528,7 @@ def send_message(message, history):
528
  partial = ""
529
  idx = 0
530
  cleared = False
531
-
532
  for t in response_generator:
533
  if idx <= 3:
534
  idx += 1
@@ -538,9 +538,9 @@ def send_message(message, history):
538
  # Quando arriva il primo token utile, svuota la textbox
539
  if not cleared:
540
  cleared = True
541
- yield gr.update(value=""), history + [{"role": "assistant", "content": partial}]
542
  else:
543
- yield "", history + [{"role": "assistant", "content": partial}]
544
 
545
 
546
  # Create the dashboard
@@ -618,13 +618,13 @@ with gr.Blocks(theme=ArtemisiaTheme(), css=custom_css) as demo:
618
  send_button.click(
619
  fn=send_message,
620
  inputs=[chat_input, chatbot],
621
- outputs=[chat_input, chatbot] # la textbox viene aggiornata qui dentro
622
  )
623
 
624
  chat_input.submit(
625
  fn=send_message,
626
  inputs=[chat_input, chatbot],
627
- outputs=[chat_input, chatbot]
628
  )
629
  # JavaScript for UI enhancements
630
  gr.HTML("""
 
518
 
519
  def send_message(message, history):
520
  history.append({"role": "user", "content": message})
521
+ context = ""
522
  # Recupera contesto extra se esiste
523
  if message.lower() in database:
524
  context = random.choice(database[message.lower()])
 
528
  partial = ""
529
  idx = 0
530
  cleared = False
531
+
532
  for t in response_generator:
533
  if idx <= 3:
534
  idx += 1
 
538
  # Quando arriva il primo token utile, svuota la textbox
539
  if not cleared:
540
  cleared = True
541
+ yield gr.update(value=""), history + [{"role": "assistant", "content": partial}], context
542
  else:
543
+ yield "", history + [{"role": "assistant", "content": partial}], context
544
 
545
 
546
  # Create the dashboard
 
618
  send_button.click(
619
  fn=send_message,
620
  inputs=[chat_input, chatbot],
621
+ outputs=[chat_input, chatbot, results_placeholder]
622
  )
623
 
624
  chat_input.submit(
625
  fn=send_message,
626
  inputs=[chat_input, chatbot],
627
+ outputs=[chat_input, chatbot, results_placeholder]
628
  )
629
  # JavaScript for UI enhancements
630
  gr.HTML("""