alexkueck commited on
Commit
b96fdf8
1 Parent(s): 86389b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -51,7 +51,8 @@ chats={}
51
 
52
  #############################################
53
  # Allgemeine Konstanten
54
- FILE_PATH = 'data/chatverlauf.txt'
 
55
 
56
  ##################################################
57
  #Für MongoDB statt Chroma als Vektorstore
@@ -149,7 +150,8 @@ def clear_all(history):
149
  id_neu = str(len(chats)+1) + "_" + result
150
  #chats ist ein dictionary
151
  chats[id_neu]= summary
152
-
 
153
  return None, gr.Image(visible=False), [], gr.CheckboxGroup(label="", choices=update_chat_options()), gr.File(visible=False)
154
 
155
 
@@ -165,12 +167,12 @@ def update_chat_options():
165
 
166
  def download_chats(selected_chats):
167
  global chats
 
168
  if chats != {}:
169
  # Diese Funktion bereitet die ausgewählten Chats zum Download vor
170
  data = "\n\n".join(chats[chat] for chat in selected_chats)
171
-
172
- file_path = save_and_download(data)
173
- return gr.File(file_path, label="Download-Chat", visible=True), gr.Button("Cleanup", visible=True)
174
 
175
 
176
  """
@@ -184,7 +186,7 @@ def download_chats(selected_chats):
184
  return gr.File(file_path, label="Download-Chat", visible = True, show_label=True)
185
  """
186
  else:
187
- return gr.File(visible=False), gr.Button("Cleanup", visible=False)
188
 
189
  ##############################################
190
  #History - die Frage oder das File eintragen...
@@ -557,10 +559,8 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
557
  with gr.Tab(label="Chats ..."):
558
  chat_selector = gr.CheckboxGroup(label="", choices=update_chat_options())
559
  download_button = gr.Button("Download ausgewählte Chats")
560
- with gr.Column(scale=4):
561
- file_download = gr.File(label="Download-Chat", visible=False)
562
- with gr.Column(scale=1):
563
- loeschen=gr.Button(visible = False)
564
  with gr.Tab(label="Parameter Einstellung"):
565
  #gr.Markdown("# Parameters")
566
  rag_option = gr.Radio(["Aus", "An"], label="LI Erweiterungen (RAG)", value = "Aus")
@@ -685,8 +685,8 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
685
  emptyBtn.click(clear_all, [history], [attached_file, image_display, history, chat_selector, file_download])
686
  #Bild Anzeige neben dem Button wieder entfernen oder austauschen..
687
  image_display.select(file_loeschen, [], [attached_file, image_display])
688
- download_button.click(fn=download_chats, inputs=chat_selector, outputs=[file_download, loeschen])
689
- #loeschen.click(lambda: cleanup(file_path), inputs=[], outputs=[])
690
 
691
  #Berechnung oder Ausgabe anhalten (kann danach fortgesetzt werden)
692
  cancelBtn.click(cancel_outputing, [], [status_display], cancels=[predict_event1,predict_event2, predict_event3])
 
51
 
52
  #############################################
53
  # Allgemeine Konstanten
54
+ #Filepath zu temp Folder (temp) mit File von ausgewähltem chatverlauf
55
+ file_path_download = None
56
 
57
  ##################################################
58
  #Für MongoDB statt Chroma als Vektorstore
 
150
  id_neu = str(len(chats)+1) + "_" + result
151
  #chats ist ein dictionary
152
  chats[id_neu]= summary
153
+ #falls file mit summay für download existiert hat: das zunächst löschen
154
+ cleanup(file_path_download)
155
  return None, gr.Image(visible=False), [], gr.CheckboxGroup(label="", choices=update_chat_options()), gr.File(visible=False)
156
 
157
 
 
167
 
168
  def download_chats(selected_chats):
169
  global chats
170
+ global file_path_download
171
  if chats != {}:
172
  # Diese Funktion bereitet die ausgewählten Chats zum Download vor
173
  data = "\n\n".join(chats[chat] for chat in selected_chats)
174
+ file_path_download = save_and_download(data)
175
+ return gr.File(file_path, label="Download-Chat", visible=True)
 
176
 
177
 
178
  """
 
186
  return gr.File(file_path, label="Download-Chat", visible = True, show_label=True)
187
  """
188
  else:
189
+ return gr.File(visible=False)
190
 
191
  ##############################################
192
  #History - die Frage oder das File eintragen...
 
559
  with gr.Tab(label="Chats ..."):
560
  chat_selector = gr.CheckboxGroup(label="", choices=update_chat_options())
561
  download_button = gr.Button("Download ausgewählte Chats")
562
+ file_download = gr.File(label="Download-Chat", visible=False)
563
+
 
 
564
  with gr.Tab(label="Parameter Einstellung"):
565
  #gr.Markdown("# Parameters")
566
  rag_option = gr.Radio(["Aus", "An"], label="LI Erweiterungen (RAG)", value = "Aus")
 
685
  emptyBtn.click(clear_all, [history], [attached_file, image_display, history, chat_selector, file_download])
686
  #Bild Anzeige neben dem Button wieder entfernen oder austauschen..
687
  image_display.select(file_loeschen, [], [attached_file, image_display])
688
+ download_button.click(fn=download_chats, inputs=chat_selector, outputs=[file_download])
689
+
690
 
691
  #Berechnung oder Ausgabe anhalten (kann danach fortgesetzt werden)
692
  cancelBtn.click(cancel_outputing, [], [status_display], cancels=[predict_event1,predict_event2, predict_event3])