Leonydis137 commited on
Commit
68c2148
·
verified ·
1 Parent(s): 95423f5

Update exporter.py

Browse files
Files changed (1) hide show
  1. 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: list, topic: str, turns: int) -> str:
11
- filename = f"discussion_{datetime.now().strftime('%Y%m%d_%H%M%S')}.txt"
12
- with open(filename, 'w') as f:
13
- f.write(f"Topic: {topic}
14
- Turns: {turns}
15
-
16
- ")
17
- for msg in conversation:
18
- f.write(f"{msg['agent']} (Turn {msg.get('turn')}):
19
- {msg['text']}
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"