Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,6 +11,7 @@ import base64
|
|
| 11 |
import tempfile
|
| 12 |
from reportlab.pdfgen import canvas
|
| 13 |
from reportlab.lib.pagesizes import letter
|
|
|
|
| 14 |
|
| 15 |
from hugchat import hugchat
|
| 16 |
from hugchat.login import Login
|
|
@@ -192,20 +193,22 @@ def clear_all(history, uploaded_file_paths, chats):
|
|
| 192 |
c.setFont("Helvetica", 12)
|
| 193 |
# Fülle die Canvas mit dem Inhalt der Textdatei
|
| 194 |
c.drawString(100, 750, summary)
|
| 195 |
-
#
|
| 196 |
c.save()
|
| 197 |
-
#
|
| 198 |
memoryFile.seek(0)
|
|
|
|
|
|
|
| 199 |
# Öffne eine neue PDF-Datei und kopiere den Inhalt des Bytestreams hinein
|
| 200 |
with open(file_path_download, 'wb') as outf:
|
| 201 |
-
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
#die session variable in gradio erweitern und alle fliepath neu in das gr.File hochladen
|
| 206 |
uploaded_file_paths= uploaded_file_paths + [file_path_download]
|
| 207 |
|
| 208 |
-
return None, gr.Image(visible=False), uploaded_file_paths, [], gr.File(uploaded_file_paths, label="Download-Chatverläufe", visible=True, file_count="multiple", interactive = False
|
| 209 |
|
| 210 |
|
| 211 |
#wenn löschen Button geklickt
|
|
|
|
| 11 |
import tempfile
|
| 12 |
from reportlab.pdfgen import canvas
|
| 13 |
from reportlab.lib.pagesizes import letter
|
| 14 |
+
from pypdf2 import PdfFileReader
|
| 15 |
|
| 16 |
from hugchat import hugchat
|
| 17 |
from hugchat.login import Login
|
|
|
|
| 193 |
c.setFont("Helvetica", 12)
|
| 194 |
# Fülle die Canvas mit dem Inhalt der Textdatei
|
| 195 |
c.drawString(100, 750, summary)
|
| 196 |
+
# Schließe das Canvas, um das PDF zu rendern
|
| 197 |
c.save()
|
| 198 |
+
# Verschiebe den Lesekopf an den Beginn des Bytes IO Streams
|
| 199 |
memoryFile.seek(0)
|
| 200 |
+
# Erstelle ein PDF-Objekt aus dem Bytes IO Stream
|
| 201 |
+
pdf = PdfFileReader(memoryFile)
|
| 202 |
# Öffne eine neue PDF-Datei und kopiere den Inhalt des Bytestreams hinein
|
| 203 |
with open(file_path_download, 'wb') as outf:
|
| 204 |
+
pdf.write(outf)
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
#die session variable in gradio erweitern und alle fliepath neu in das gr.File hochladen
|
| 209 |
uploaded_file_paths= uploaded_file_paths + [file_path_download]
|
| 210 |
|
| 211 |
+
return None, gr.Image(visible=False), uploaded_file_paths, [], gr.File(uploaded_file_paths, label="Download-Chatverläufe", visible=True, file_count="multiple", interactive = False), chats
|
| 212 |
|
| 213 |
|
| 214 |
#wenn löschen Button geklickt
|