Update app.py
Browse files
app.py
CHANGED
|
@@ -141,7 +141,7 @@ def clear_all(history):
|
|
| 141 |
#chats ist ein dictionary
|
| 142 |
chats[id_neu]= summary
|
| 143 |
|
| 144 |
-
return None, gr.Image(visible=False), [], gr.CheckboxGroup(
|
| 145 |
|
| 146 |
|
| 147 |
#########################################
|
|
@@ -159,11 +159,22 @@ def download_chats(selected_chats):
|
|
| 159 |
if chats != {}:
|
| 160 |
# Diese Funktion bereitet die ausgewählten Chats zum Download vor
|
| 161 |
data = "\n\n".join(chats[chat] for chat in selected_chats)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
# Erstelle eine temporäre Datei mit den Chat-Daten
|
| 163 |
with tempfile.NamedTemporaryFile(delete=False, mode='w', suffix='.txt') as tmp:
|
| 164 |
tmp.write(data)
|
| 165 |
tmp_path = tmp.name
|
| 166 |
return gr.File(tmp_path, label="Download-Chat", visible = True)
|
|
|
|
| 167 |
else:
|
| 168 |
return gr.File(visible=False)
|
| 169 |
|
|
|
|
| 141 |
#chats ist ein dictionary
|
| 142 |
chats[id_neu]= summary
|
| 143 |
|
| 144 |
+
return None, gr.Image(visible=False), [], gr.CheckboxGroup( choices=update_chat_options())
|
| 145 |
|
| 146 |
|
| 147 |
#########################################
|
|
|
|
| 159 |
if chats != {}:
|
| 160 |
# Diese Funktion bereitet die ausgewählten Chats zum Download vor
|
| 161 |
data = "\n\n".join(chats[chat] for chat in selected_chats)
|
| 162 |
+
# Dateipfad festlegen (hier wird die Datei im aktuellen Verzeichnis gespeichert)
|
| 163 |
+
file_path = '/data/chatverlauf.txt'
|
| 164 |
+
|
| 165 |
+
# Datei im Schreibmodus öffnen (erstellt die Datei, wenn sie nicht existiert)
|
| 166 |
+
with open(file_path, 'w') as file:
|
| 167 |
+
# String in die Datei schreiben
|
| 168 |
+
file.write(data)
|
| 169 |
+
return gr.File(file_path, label="Download-Chat", visible = True)
|
| 170 |
+
|
| 171 |
+
"""
|
| 172 |
# Erstelle eine temporäre Datei mit den Chat-Daten
|
| 173 |
with tempfile.NamedTemporaryFile(delete=False, mode='w', suffix='.txt') as tmp:
|
| 174 |
tmp.write(data)
|
| 175 |
tmp_path = tmp.name
|
| 176 |
return gr.File(tmp_path, label="Download-Chat", visible = True)
|
| 177 |
+
"""
|
| 178 |
else:
|
| 179 |
return gr.File(visible=False)
|
| 180 |
|