SuhasGholkar commited on
Commit
dfb2a3c
·
verified ·
1 Parent(s): e91c7ca

Update src/chat.py

Browse files
Files changed (1) hide show
  1. src/chat.py +8 -2
src/chat.py CHANGED
@@ -828,7 +828,13 @@ def render_user_export_tab(conn, user_id: int):
828
  st.info("No chats to export yet.")
829
  return
830
  csv_bytes = df.to_csv(index=False).encode("utf-8")
831
- st.download_button("Download CSV", csv_bytes, file_name="my_chats.csv", mime="text/csv")
 
 
 
 
 
 
832
 
833
  lines = []
834
  for _, r in df.iterrows():
@@ -836,4 +842,4 @@ def render_user_export_tab(conn, user_id: int):
836
  lines.append(f"Bot: {r['bot_reply']}")
837
  lines.append("---")
838
  txt_bytes = "\n".join(lines).encode("utf-8")
839
- st.download_button("Download TXT", txt_bytes, file_name="my_chats.txt", mime="text/plain")
 
828
  st.info("No chats to export yet.")
829
  return
830
  csv_bytes = df.to_csv(index=False).encode("utf-8")
831
+ timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
832
+
833
+ # Create dynamic file name
834
+ file_name_csv = f"my_chats_{timestamp}.csv"
835
+ file_name_txt = f"my_chats_{timestamp}.txt"
836
+
837
+ st.download_button("Download CSV", csv_bytes, file_name=file_name_csv, mime="text/csv")
838
 
839
  lines = []
840
  for _, r in df.iterrows():
 
842
  lines.append(f"Bot: {r['bot_reply']}")
843
  lines.append("---")
844
  txt_bytes = "\n".join(lines).encode("utf-8")
845
+ st.download_button("Download TXT", txt_bytes, file_name=file_name_txt, mime="text/plain")