Update app.py
Browse files
app.py
CHANGED
|
@@ -176,17 +176,18 @@ def clear_all(history, uploaded_file_paths, chats):
|
|
| 176 |
#summary wird gebraucht für die Anfrage beim NN, um eine Überschrift des Eintrages zu generieren
|
| 177 |
summary = "\n\n".join(f'{schluessel}: \n {wert}' for schluessel, wert in dic_history.items())
|
| 178 |
summary_pdf = "\n\n".join(f'Nutzer: {schluessel}: , Assistent: {wert}' for schluessel, wert in dic_history.items())
|
|
|
|
| 179 |
print("start history:")
|
| 180 |
-
print(
|
| 181 |
print("end history:")
|
| 182 |
# um den Chatverlauf für das PDF vorzubereiten:
|
| 183 |
chat_history={}
|
| 184 |
-
for key, value in
|
| 185 |
if key == 'timestamp':
|
| 186 |
chat_history[key] = value
|
| 187 |
-
elif key == '
|
| 188 |
chat_history[key] = value
|
| 189 |
-
elif key == '
|
| 190 |
chat_history[key] = value
|
| 191 |
|
| 192 |
#falls file mit summay für download existiert hat: das zunächst löschen
|
|
@@ -221,20 +222,20 @@ def clear_all(history, uploaded_file_paths, chats):
|
|
| 221 |
# Zeitstempel
|
| 222 |
c.setFillColorRGB(0, 0, 0)
|
| 223 |
c.setFont("Times-Bold", 14)
|
| 224 |
-
c.drawCentredString(TIMESTAMP_X + COLUMN_WIDTH / 2, MARGIN, chat_history["timestamp"])
|
| 225 |
# User und Assistant
|
| 226 |
c.setFont("Courier", 12)
|
| 227 |
-
c.drawString(USER_X, MARGIN + LINE_SPACING, chat_history["
|
| 228 |
c.setFont("Monaco", 14)
|
| 229 |
-
c.drawString(USER_X + COLUMN_WIDTH, MARGIN + LINE_SPACING, chat_history["
|
| 230 |
# Linie trennen
|
| 231 |
c.line(TIMESTAMP_X, MARGIN + LINE_SPACING + ROW_HEIGHT, ASSISTANT_X + COLUMN_WIDTH, MARGIN + LINE_SPACING + ROW_HEIGHT)
|
| 232 |
|
| 233 |
# Setze die Schriftart und -grösse
|
| 234 |
-
c.setFont("Helvetica", 12)
|
| 235 |
# Fülle die Canvas mit dem Inhalt der Textdatei
|
| 236 |
c.drawString(100, 750, summary)
|
| 237 |
-
|
| 238 |
c.save()
|
| 239 |
# Verschiebe den Lesekopf an den Beginn des Bytes IO Streams
|
| 240 |
memoryFile.seek(0)
|
|
|
|
| 176 |
#summary wird gebraucht für die Anfrage beim NN, um eine Überschrift des Eintrages zu generieren
|
| 177 |
summary = "\n\n".join(f'{schluessel}: \n {wert}' for schluessel, wert in dic_history.items())
|
| 178 |
summary_pdf = "\n\n".join(f'Nutzer: {schluessel}: , Assistent: {wert}' for schluessel, wert in dic_history.items())
|
| 179 |
+
dic_pdf= dict(part.split(': ') for part in s.split(', '))
|
| 180 |
print("start history:")
|
| 181 |
+
print(dic_pdf)
|
| 182 |
print("end history:")
|
| 183 |
# um den Chatverlauf für das PDF vorzubereiten:
|
| 184 |
chat_history={}
|
| 185 |
+
for key, value in dic_pdf.items():
|
| 186 |
if key == 'timestamp':
|
| 187 |
chat_history[key] = value
|
| 188 |
+
elif key == 'Nutzer':
|
| 189 |
chat_history[key] = value
|
| 190 |
+
elif key == 'Assistent':
|
| 191 |
chat_history[key] = value
|
| 192 |
|
| 193 |
#falls file mit summay für download existiert hat: das zunächst löschen
|
|
|
|
| 222 |
# Zeitstempel
|
| 223 |
c.setFillColorRGB(0, 0, 0)
|
| 224 |
c.setFont("Times-Bold", 14)
|
| 225 |
+
c.drawCentredString(TIMESTAMP_X + COLUMN_WIDTH / 2, MARGIN, "Datum hier..." ) #chat_history["timestamp"])
|
| 226 |
# User und Assistant
|
| 227 |
c.setFont("Courier", 12)
|
| 228 |
+
c.drawString(USER_X, MARGIN + LINE_SPACING, chat_history["Nutzer"] + ": ")
|
| 229 |
c.setFont("Monaco", 14)
|
| 230 |
+
c.drawString(USER_X + COLUMN_WIDTH, MARGIN + LINE_SPACING, chat_history["Assistent"])
|
| 231 |
# Linie trennen
|
| 232 |
c.line(TIMESTAMP_X, MARGIN + LINE_SPACING + ROW_HEIGHT, ASSISTANT_X + COLUMN_WIDTH, MARGIN + LINE_SPACING + ROW_HEIGHT)
|
| 233 |
|
| 234 |
# Setze die Schriftart und -grösse
|
| 235 |
+
#c.setFont("Helvetica", 12)
|
| 236 |
# Fülle die Canvas mit dem Inhalt der Textdatei
|
| 237 |
c.drawString(100, 750, summary)
|
| 238 |
+
## Schließe das Canvas, um das PDF zu rendern
|
| 239 |
c.save()
|
| 240 |
# Verschiebe den Lesekopf an den Beginn des Bytes IO Streams
|
| 241 |
memoryFile.seek(0)
|