Leyo commited on
Commit
f86cfeb
β€’
1 Parent(s): 7d3ba25

fix remove last turn + upload button removed

Browse files
Files changed (1) hide show
  1. app_dialogue.py +3 -33
app_dialogue.py CHANGED
@@ -98,12 +98,7 @@ def pil_to_temp_file(
98
  return filename
99
 
100
 
101
- def add_file(file):
102
- return file.name, gr.update(label="πŸ–ΌοΈ Uploaded!")
103
-
104
-
105
  def add_file_gallery(selected_state: gr.SelectData, gallery_list: List[str]):
106
- gr.update(label="πŸ“ Upload image", interactive=True)
107
  return (
108
  "Write a meme about this image.",
109
  gallery_list[selected_state.index]["name"],
@@ -610,12 +605,6 @@ with gr.Blocks(title="AI Meme Generator", theme=gr.themes.Base(), css=css) as de
610
  regenerate_btn = gr.Button(
611
  value="πŸ”„ Regenerate", visible=True, min_width=120
612
  )
613
- upload_btn = gr.UploadButton(
614
- "πŸ“ Upload image",
615
- file_types=["image"],
616
- visible=False,
617
- min_width=120,
618
- )
619
  with gr.Accordion(
620
  "Advanced settings", open=False, visible=True
621
  ) as parameter_row:
@@ -923,12 +912,12 @@ with gr.Blocks(title="AI Meme Generator", theme=gr.themes.Base(), css=css) as de
923
 
924
  def remove_last_turn(chat_history):
925
  if len(chat_history) == 0:
926
- return gr.update(), gr.update()
927
  last_interaction = chat_history[-1]
928
  chat_history = chat_history[:-1]
929
  last_interaction[0] = re.sub(r"!\[]\(/file=.*?\)", "", last_interaction[0])
930
- chat_update = gr.update(value=chat_history)
931
- text_update = gr.update(value=last_interaction[0])
932
  return chat_update, text_update, ""
933
 
934
  regenerate_btn.click(
@@ -960,25 +949,6 @@ with gr.Blocks(title="AI Meme Generator", theme=gr.themes.Base(), css=css) as de
960
  ],
961
  )
962
 
963
- upload_btn.upload(add_file, [upload_btn], [imagebox, upload_btn], queue=False)
964
- submit_btn.click(
965
- lambda: gr.update(label="πŸ“ Upload image", interactive=True),
966
- [],
967
- upload_btn,
968
- queue=False,
969
- )
970
- textbox.submit(
971
- lambda: gr.update(label="πŸ“ Upload image", interactive=True),
972
- [],
973
- upload_btn,
974
- queue=False,
975
- )
976
- clear_btn.click(
977
- lambda: gr.update(label="πŸ“ Upload image", interactive=True),
978
- [],
979
- upload_btn,
980
- queue=False,
981
- )
982
  gallery_type_choice.change(
983
  fn=choose_gallery,
984
  inputs=[gallery_type_choice],
 
98
  return filename
99
 
100
 
 
 
 
 
101
  def add_file_gallery(selected_state: gr.SelectData, gallery_list: List[str]):
 
102
  return (
103
  "Write a meme about this image.",
104
  gallery_list[selected_state.index]["name"],
 
605
  regenerate_btn = gr.Button(
606
  value="πŸ”„ Regenerate", visible=True, min_width=120
607
  )
 
 
 
 
 
 
608
  with gr.Accordion(
609
  "Advanced settings", open=False, visible=True
610
  ) as parameter_row:
 
912
 
913
  def remove_last_turn(chat_history):
914
  if len(chat_history) == 0:
915
+ return chat_history, "", ""
916
  last_interaction = chat_history[-1]
917
  chat_history = chat_history[:-1]
918
  last_interaction[0] = re.sub(r"!\[]\(/file=.*?\)", "", last_interaction[0])
919
+ chat_update = chat_history
920
+ text_update = last_interaction[0]
921
  return chat_update, text_update, ""
922
 
923
  regenerate_btn.click(
 
949
  ],
950
  )
951
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
952
  gallery_type_choice.change(
953
  fn=choose_gallery,
954
  inputs=[gallery_type_choice],