Spaces:
Sleeping
Sleeping
Update exporter.py
Browse files- exporter.py +10 -14
exporter.py
CHANGED
@@ -7,20 +7,16 @@ from reportlab.lib.styles import getSampleStyleSheet
|
|
7 |
import requests
|
8 |
|
9 |
|
10 |
-
def export_txt(conversation
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
")
|
22 |
-
return filename
|
23 |
-
|
24 |
|
25 |
def export_json(conversation: list, topic: str, turns: int) -> str:
|
26 |
filename = f"discussion_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
|
|
|
7 |
import requests
|
8 |
|
9 |
|
10 |
+
def export_txt(conversation, topic, filename="conversation.txt"):
|
11 |
+
try:
|
12 |
+
with open(filename, "w", encoding="utf-8") as f:
|
13 |
+
f.write(f"Topic: {topic}\n\n")
|
14 |
+
for turn in conversation:
|
15 |
+
f.write(f"{turn['agent']}: {turn['text']}\n")
|
16 |
+
return filename
|
17 |
+
except Exception as e:
|
18 |
+
logging.error(f"[export_txt] Failed to write file: {e}")
|
19 |
+
return None
|
|
|
|
|
|
|
|
|
20 |
|
21 |
def export_json(conversation: list, topic: str, turns: int) -> str:
|
22 |
filename = f"discussion_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
|