Update app.py
Browse files
app.py
CHANGED
@@ -196,47 +196,6 @@ def clear_all(history, uploaded_file_paths, chats):
|
|
196 |
file_path_download = "data/" + str(len(chats)) + "_" + result + ".pdf"
|
197 |
|
198 |
erstellePdf(file_path_download, result, dic_history)
|
199 |
-
|
200 |
-
"""
|
201 |
-
#chat_history in ein File laden
|
202 |
-
# Erzeuge einen Bytestream
|
203 |
-
memoryFile = io.BytesIO()
|
204 |
-
# Erstelle eine Canvas-Instanz im Bytestream
|
205 |
-
c = canvas.Canvas(memoryFile, pagesize=letter) #oder letter
|
206 |
-
# Zeitstempel
|
207 |
-
c.setFillColorRGB(0, 0, 0)
|
208 |
-
c.setFont("Times-Bold", 14)
|
209 |
-
c.drawString(TIMESTAMP_X + COLUMN_WIDTH / 2, MARGIN, "Datum hier..." ) #chat_history["timestamp"])
|
210 |
-
# User und Assistant
|
211 |
-
i=1
|
212 |
-
for key, value in dic_history.items():
|
213 |
-
c.setFont("Courier", 12)
|
214 |
-
c.drawString(USER_X, MARGIN + i*LINE_SPACING, "Nutzer: " + key)
|
215 |
-
c.setFont("Helvetica", 12)
|
216 |
-
c.drawString(USER_X + COLUMN_WIDTH, MARGIN + (i+1)*LINE_SPACING, "Assistent: " + value)
|
217 |
-
# Linie trennen
|
218 |
-
#c.line(TIMESTAMP_X, MARGIN + LINE_SPACING + ROW_HEIGHT, ASSISTANT_X + COLUMN_WIDTH, MARGIN + LINE_SPACING + ROW_HEIGHT)
|
219 |
-
i=i+2
|
220 |
-
|
221 |
-
# Setze die Schriftart und -grösse
|
222 |
-
#c.setFont("Helvetica", 12)
|
223 |
-
# Fülle die Canvas mit dem Inhalt der Textdatei
|
224 |
-
#c.drawString(100, 750, summary)
|
225 |
-
## Schließe das Canvas, um das PDF zu rendern
|
226 |
-
c.save()
|
227 |
-
# Verschiebe den Lesekopf an den Beginn des Bytes IO Streams
|
228 |
-
memoryFile.seek(0)
|
229 |
-
|
230 |
-
# Erstelle ein PdfFileWriter-Objekt aus dem BytesIO-Stream
|
231 |
-
pdf_writer = PdfWriter()
|
232 |
-
pdf_reader = PdfReader(memoryFile)
|
233 |
-
# Gib das PDF-Objekt an PdfFileWriter weiter
|
234 |
-
for page in range(len(pdf_reader.pages)):
|
235 |
-
pdf_writer.add_page(pdf_reader.pages[page])
|
236 |
-
# Speichere das PDF-Objekt in einer neuen Datei
|
237 |
-
with open(file_path_download, "wb") as fp:
|
238 |
-
pdf_writer.write(fp)
|
239 |
-
"""
|
240 |
|
241 |
|
242 |
#die session variable in gradio erweitern und alle fliepath neu in das gr.File hochladen
|
|
|
196 |
file_path_download = "data/" + str(len(chats)) + "_" + result + ".pdf"
|
197 |
|
198 |
erstellePdf(file_path_download, result, dic_history)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
|
200 |
|
201 |
#die session variable in gradio erweitern und alle fliepath neu in das gr.File hochladen
|