Update app.py
Browse files
app.py
CHANGED
|
@@ -168,6 +168,14 @@ def download_chats(selected_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 |
# Dateipfad festlegen (hier wird die Datei im aktuellen Verzeichnis gespeichert)
|
| 172 |
file_path = FILE_PATH #'data/chatverlauf.txt'
|
| 173 |
|
|
@@ -176,8 +184,9 @@ def download_chats(selected_chats):
|
|
| 176 |
# String in die Datei schreiben
|
| 177 |
file.write(data)
|
| 178 |
return gr.File(file_path, label="Download-Chat", visible = True, show_label=True)
|
|
|
|
| 179 |
else:
|
| 180 |
-
return gr.File(visible=False)
|
| 181 |
|
| 182 |
##############################################
|
| 183 |
#History - die Frage oder das File eintragen...
|
|
@@ -550,7 +559,10 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
|
|
| 550 |
with gr.Tab(label="Chats ..."):
|
| 551 |
chat_selector = gr.CheckboxGroup(label="", choices=update_chat_options())
|
| 552 |
download_button = gr.Button("Download ausgewählte Chats")
|
| 553 |
-
|
|
|
|
|
|
|
|
|
|
| 554 |
with gr.Tab(label="Parameter Einstellung"):
|
| 555 |
#gr.Markdown("# Parameters")
|
| 556 |
rag_option = gr.Radio(["Aus", "An"], label="LI Erweiterungen (RAG)", value = "Aus")
|
|
@@ -675,7 +687,7 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
|
|
| 675 |
emptyBtn.click(clear_all, [history], [attached_file, image_display, history, chat_selector, file_download])
|
| 676 |
#Bild Anzeige neben dem Button wieder entfernen oder austauschen..
|
| 677 |
image_display.select(file_loeschen, [], [attached_file, image_display])
|
| 678 |
-
download_button.click(fn=download_chats, inputs=chat_selector, outputs=file_download)
|
| 679 |
|
| 680 |
#Berechnung oder Ausgabe anhalten (kann danach fortgesetzt werden)
|
| 681 |
cancelBtn.click(cancel_outputing, [], [status_display], cancels=[predict_event1,predict_event2, predict_event3])
|
|
|
|
| 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 |
+
cleanup_button = gr.Button("Cleanup")
|
| 174 |
+
cleanup_button.click(lambda: cleanup(file_path), inputs=[], outputs=[])
|
| 175 |
+
return gr.File(file_path, label="Download-Chat"), cleanup_button
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
"""
|
| 179 |
# Dateipfad festlegen (hier wird die Datei im aktuellen Verzeichnis gespeichert)
|
| 180 |
file_path = FILE_PATH #'data/chatverlauf.txt'
|
| 181 |
|
|
|
|
| 184 |
# String in die Datei schreiben
|
| 185 |
file.write(data)
|
| 186 |
return gr.File(file_path, label="Download-Chat", visible = True, show_label=True)
|
| 187 |
+
"""
|
| 188 |
else:
|
| 189 |
+
return gr.File(visible=False), gr.Button("Cleanup", 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 |
+
with gr.Column(scale=4):
|
| 563 |
+
file_download = gr.File(label="Download-Chat", visible=False)
|
| 564 |
+
with gr.Column(scale=1):
|
| 565 |
+
loeschen=gr.Button(visible = False)
|
| 566 |
with gr.Tab(label="Parameter Einstellung"):
|
| 567 |
#gr.Markdown("# Parameters")
|
| 568 |
rag_option = gr.Radio(["Aus", "An"], label="LI Erweiterungen (RAG)", value = "Aus")
|
|
|
|
| 687 |
emptyBtn.click(clear_all, [history], [attached_file, image_display, history, chat_selector, file_download])
|
| 688 |
#Bild Anzeige neben dem Button wieder entfernen oder austauschen..
|
| 689 |
image_display.select(file_loeschen, [], [attached_file, image_display])
|
| 690 |
+
download_button.click(fn=download_chats, inputs=chat_selector, outputs=[file_download, loeschen])
|
| 691 |
|
| 692 |
#Berechnung oder Ausgabe anhalten (kann danach fortgesetzt werden)
|
| 693 |
cancelBtn.click(cancel_outputing, [], [status_display], cancels=[predict_event1,predict_event2, predict_event3])
|