chansung commited on
Commit
d527274
·
1 Parent(s): 8af75e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -5
app.py CHANGED
@@ -285,7 +285,7 @@ def gen_art(editor, cover_art_image, gen_cover_art_prompt):
285
  else:
286
  global pipe
287
  pipe = pipe.to("cuda")
288
-
289
  return [
290
  pipe(gen_cover_art_prompt).images[0],
291
  gen_cover_art_prompt
@@ -374,12 +374,24 @@ Answer to questions based on the written stories so far as below
374
  ]
375
 
376
  def chat(editor, chat_txt, chatbot, ppm):
377
- return chat_gen(editor, chat_txt, chatbot, ppm, regen=False)
 
 
 
378
 
379
  def regen_chat(editor, chat_txt, chatbot, ppm):
380
  return chat_gen(editor, chat_txt, chatbot, ppm, regen=True)
381
 
382
 
 
 
 
 
 
 
 
 
 
383
  def get_new_ppm_for_range():
384
  ppm = LLaMA2ChatPPManager()
385
  ppm.ctx = """\
@@ -516,8 +528,8 @@ with gr.Blocks(css=STYLES) as demo:
516
  chat_txt = gr.Textbox(placeholder="enter question", elem_classes=['no-label'])
517
 
518
  with gr.Row():
519
- clear_btn = gr.Button("clear", elem_classes=['control-label-font', 'control-button'])
520
- regen_btn = gr.Button("regenerate", elem_classes=['control-label-font', 'control-button'])
521
 
522
  with gr.Tab("Exporting"):
523
  with gr.Column(elem_classes=['group-border']):
@@ -623,7 +635,7 @@ with gr.Blocks(css=STYLES) as demo:
623
  chat_txt.submit(
624
  fn=chat,
625
  inputs=[editor, chat_txt, chatbot, chat_history],
626
- outputs=[chat_txt, chatbot, chat_history]
627
  )
628
 
629
  regen_btn.click(
@@ -631,5 +643,12 @@ with gr.Blocks(css=STYLES) as demo:
631
  inputs=[editor, chat_txt, chatbot, chat_history],
632
  outputs=[chat_txt, chatbot, chat_history]
633
  )
 
 
 
 
 
 
 
634
 
635
  demo.launch()
 
285
  else:
286
  global pipe
287
  pipe = pipe.to("cuda")
288
+
289
  return [
290
  pipe(gen_cover_art_prompt).images[0],
291
  gen_cover_art_prompt
 
374
  ]
375
 
376
  def chat(editor, chat_txt, chatbot, ppm):
377
+ return chat_gen(editor, chat_txt, chatbot, ppm, regen=False) + [
378
+ gr.update(interactive=True),
379
+ gr.update(interactive=True)
380
+ ]
381
 
382
  def regen_chat(editor, chat_txt, chatbot, ppm):
383
  return chat_gen(editor, chat_txt, chatbot, ppm, regen=True)
384
 
385
 
386
+ def clear_chat():
387
+ return [
388
+ "",
389
+ [],
390
+ get_new_ppm_for_chat(),
391
+ gr.update(interactive=False),
392
+ gr.update(interactive=False)
393
+ ]
394
+
395
  def get_new_ppm_for_range():
396
  ppm = LLaMA2ChatPPManager()
397
  ppm.ctx = """\
 
528
  chat_txt = gr.Textbox(placeholder="enter question", elem_classes=['no-label'])
529
 
530
  with gr.Row():
531
+ clear_btn = gr.Button("clear", interactive=False, elem_classes=['control-label-font', 'control-button'])
532
+ regen_btn = gr.Button("regenerate", interactive=False, elem_classes=['control-label-font', 'control-button'])
533
 
534
  with gr.Tab("Exporting"):
535
  with gr.Column(elem_classes=['group-border']):
 
635
  chat_txt.submit(
636
  fn=chat,
637
  inputs=[editor, chat_txt, chatbot, chat_history],
638
+ outputs=[chat_txt, chatbot, chat_history, clear_btn, regen_btn]
639
  )
640
 
641
  regen_btn.click(
 
643
  inputs=[editor, chat_txt, chatbot, chat_history],
644
  outputs=[chat_txt, chatbot, chat_history]
645
  )
646
+
647
+ clear_btn.click(
648
+ fn=clear_chat,
649
+ inputs=None,
650
+ outputs=[chat_txt, chatbot, chat_history, clear_btn, regen_btn],
651
+ show_progress='minimal'
652
+ )
653
 
654
  demo.launch()