Update app.py
Browse files
app.py
CHANGED
|
@@ -119,13 +119,22 @@ def talk(prompt, history):
|
|
| 119 |
|
| 120 |
try:
|
| 121 |
# write data to file
|
| 122 |
-
|
|
|
|
|
|
|
| 123 |
data.write(historylog)
|
| 124 |
-
|
| 125 |
print("History log printed:")
|
| 126 |
-
with open("./
|
| 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 |
|