alexkueck commited on
Commit
a37f519
1 Parent(s): 52f9816

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -9,11 +9,13 @@ import io
9
  from PIL import Image, ImageDraw, ImageOps, ImageFont
10
  import base64
11
  import tempfile
12
- from reportlab.pdfgen import canvas
13
- from reportlab.lib.pagesizes import letter
14
- from reportlab.pdfbase import pdfmetrics
15
- from reportlab.lib.styles import getSampleStyleSheet
16
- from reportlab.platypus import SimpleDocTemplate, Paragraph
 
 
17
 
18
  from PyPDF2 import PdfReader, PdfWriter
19
 
@@ -200,6 +202,9 @@ def clear_all(history, uploaded_file_paths, chats):
200
  else:
201
  file_path_download = "data/" + str(len(chats)) + "_" + result + ".pdf"
202
 
 
 
 
203
  #chat_history in ein File laden
204
  # Erzeuge einen Bytestream
205
  memoryFile = io.BytesIO()
@@ -208,7 +213,7 @@ def clear_all(history, uploaded_file_paths, chats):
208
  # Zeitstempel
209
  c.setFillColorRGB(0, 0, 0)
210
  c.setFont("Times-Bold", 14)
211
- c.drawCentredString(TIMESTAMP_X + COLUMN_WIDTH / 2, MARGIN, "Datum hier..." ) #chat_history["timestamp"])
212
  # User und Assistant
213
  i=1
214
  for key, value in dic_history.items():
@@ -238,6 +243,8 @@ def clear_all(history, uploaded_file_paths, chats):
238
  # Speichere das PDF-Objekt in einer neuen Datei
239
  with open(file_path_download, "wb") as fp:
240
  pdf_writer.write(fp)
 
 
241
 
242
  #die session variable in gradio erweitern und alle fliepath neu in das gr.File hochladen
243
  uploaded_file_paths= uploaded_file_paths + [file_path_download]
 
9
  from PIL import Image, ImageDraw, ImageOps, ImageFont
10
  import base64
11
  import tempfile
12
+ from reportlab.lib.pagesizes import inch, A4
13
+ from reportlab.platypus import SimpleDocTemplate, Frame, Spacer
14
+ from reportlab.lib import colors
15
+ from reportlab.lib.units import mm
16
+ from reportlab.platypus import Paragraph, SimpleDocTemplate, Frame, Image, Table
17
+ from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
18
+ from reportlab.lib.units import cm
19
 
20
  from PyPDF2 import PdfReader, PdfWriter
21
 
 
202
  else:
203
  file_path_download = "data/" + str(len(chats)) + "_" + result + ".pdf"
204
 
205
+ erstellePdf(file_path_download, result, dic_history)
206
+
207
+ """
208
  #chat_history in ein File laden
209
  # Erzeuge einen Bytestream
210
  memoryFile = io.BytesIO()
 
213
  # Zeitstempel
214
  c.setFillColorRGB(0, 0, 0)
215
  c.setFont("Times-Bold", 14)
216
+ c.drawString(TIMESTAMP_X + COLUMN_WIDTH / 2, MARGIN, "Datum hier..." ) #chat_history["timestamp"])
217
  # User und Assistant
218
  i=1
219
  for key, value in dic_history.items():
 
243
  # Speichere das PDF-Objekt in einer neuen Datei
244
  with open(file_path_download, "wb") as fp:
245
  pdf_writer.write(fp)
246
+ """
247
+
248
 
249
  #die session variable in gradio erweitern und alle fliepath neu in das gr.File hochladen
250
  uploaded_file_paths= uploaded_file_paths + [file_path_download]