Namitg02 commited on
Commit
f17e225
·
verified ·
1 Parent(s): c12c34f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -119,13 +119,22 @@ def talk(prompt, history):
119
 
120
  try:
121
  # write data to file
122
- with open("./file.txt", "a") as data:
 
 
123
  data.write(historylog)
124
- # Read the contents of the file to display it.
125
  print("History log printed:")
126
- with open("./file.txt", "r") as data:
127
  print(data.read())
128
 
 
 
 
 
 
 
 
129
  except IOError as e:
130
  print(f"An error occurred: {e}")
131
 
 
119
 
120
  try:
121
  # write data to file
122
+ timestamp = datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
123
+ filename = f"file_{timestamp}.txt"
124
+ with open(f"./{filename}", "a") as data:
125
  data.write(historylog)
126
+
127
  print("History log printed:")
128
+ with open(f"./{filename}", "r") as data:
129
  print(data.read())
130
 
131
+ # with open("./file.txt", "a") as data:
132
+ # data.write(historylog)
133
+ # Read the contents of the file to display it.
134
+ # print("History log printed:")
135
+ # with open("./file.txt", "r") as data:
136
+ # print(data.read())
137
+
138
  except IOError as e:
139
  print(f"An error occurred: {e}")
140