aliabid94 HF staff commited on
Commit
53b7e6c
1 Parent(s): def772d

Update app_dialogue.py

Browse files
Files changed (1) hide show
  1. app_dialogue.py +11 -4
app_dialogue.py CHANGED
@@ -523,7 +523,9 @@ with gr.Blocks(title="IDEFICS Playground", theme=gr.themes.Base()) as demo:
523
  stream = client.generate_stream(prompt=query, **generation_args)
524
 
525
  acc_text = ""
 
526
  for idx, response in enumerate(stream):
 
527
  text_token = response.token.text
528
 
529
  if response.details:
@@ -541,11 +543,13 @@ with gr.Blocks(title="IDEFICS Playground", theme=gr.themes.Base()) as demo:
541
  last_turn = chat_history.pop(-1)
542
  last_turn[-1] += acc_text
543
  chat_history.append(last_turn)
 
544
  yield "", None, chat_history
545
  acc_text = ""
546
 
547
  def process_example(message, image):
548
- clear_msg, image_value, chat = model_inference(
 
549
  model_selector="HuggingFaceM4/idefics-80b-instruct",
550
  user_prompt_str=message,
551
  chat_history=[],
@@ -559,7 +563,8 @@ with gr.Blocks(title="IDEFICS Playground", theme=gr.themes.Base()) as demo:
559
  return clear_msg, image_value, chat
560
 
561
  textbox.submit(
562
- fn=model_inference,
 
563
  inputs=[
564
  model_selector,
565
  textbox,
@@ -574,7 +579,8 @@ with gr.Blocks(title="IDEFICS Playground", theme=gr.themes.Base()) as demo:
574
  outputs=[textbox, imagebox, chatbot],
575
  )
576
  submit_btn.click(
577
- fn=model_inference,
 
578
  inputs=[
579
  model_selector,
580
  textbox,
@@ -603,7 +609,8 @@ with gr.Blocks(title="IDEFICS Playground", theme=gr.themes.Base()) as demo:
603
  return chat_update, text_update
604
 
605
  regenerate_btn.click(fn=remove_last_turn, inputs=chatbot, outputs=[chatbot, textbox]).then(
606
- fn=model_inference,
 
607
  inputs=[
608
  model_selector,
609
  textbox,
 
523
  stream = client.generate_stream(prompt=query, **generation_args)
524
 
525
  acc_text = ""
526
+ import time
527
  for idx, response in enumerate(stream):
528
+ start = time.time()
529
  text_token = response.token.text
530
 
531
  if response.details:
 
543
  last_turn = chat_history.pop(-1)
544
  last_turn[-1] += acc_text
545
  chat_history.append(last_turn)
546
+ print(">", time.time() - start)
547
  yield "", None, chat_history
548
  acc_text = ""
549
 
550
  def process_example(message, image):
551
+ clear_msg, image_value, chat =
552
+ (
553
  model_selector="HuggingFaceM4/idefics-80b-instruct",
554
  user_prompt_str=message,
555
  chat_history=[],
 
563
  return clear_msg, image_value, chat
564
 
565
  textbox.submit(
566
+ fn=
567
+ ,
568
  inputs=[
569
  model_selector,
570
  textbox,
 
579
  outputs=[textbox, imagebox, chatbot],
580
  )
581
  submit_btn.click(
582
+ fn=
583
+ ,
584
  inputs=[
585
  model_selector,
586
  textbox,
 
609
  return chat_update, text_update
610
 
611
  regenerate_btn.click(fn=remove_last_turn, inputs=chatbot, outputs=[chatbot, textbox]).then(
612
+ fn=
613
+ ,
614
  inputs=[
615
  model_selector,
616
  textbox,