Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,17 +30,19 @@ def generate_text() -> str:
|
|
| 30 |
with open(DATA_FILE) as file:
|
| 31 |
text = ""
|
| 32 |
for line in file:
|
| 33 |
-
row_parts = line.strip().split("
|
| 34 |
if len(row_parts) != 3:
|
| 35 |
continue
|
| 36 |
-
user, chatbot
|
| 37 |
text += f"Time: {time}\nUser: {user}\nChatbot: {chatbot}\n\n"
|
| 38 |
return text if text else "No messages yet"
|
| 39 |
|
| 40 |
def store_message(chatinput: str, chatresponse: str):
|
| 41 |
if chatinput and chatresponse:
|
| 42 |
with open(DATA_FILE, "a") as file:
|
| 43 |
-
|
|
|
|
|
|
|
| 44 |
|
| 45 |
return generate_text()
|
| 46 |
|
|
|
|
| 30 |
with open(DATA_FILE) as file:
|
| 31 |
text = ""
|
| 32 |
for line in file:
|
| 33 |
+
row_parts = line.strip().split(",")
|
| 34 |
if len(row_parts) != 3:
|
| 35 |
continue
|
| 36 |
+
time, user, chatbot = row_parts
|
| 37 |
text += f"Time: {time}\nUser: {user}\nChatbot: {chatbot}\n\n"
|
| 38 |
return text if text else "No messages yet"
|
| 39 |
|
| 40 |
def store_message(chatinput: str, chatresponse: str):
|
| 41 |
if chatinput and chatresponse:
|
| 42 |
with open(DATA_FILE, "a") as file:
|
| 43 |
+
now = datetime.now()
|
| 44 |
+
timestamp = now.strftime("%Y-%m-%d %H:%M:%S")
|
| 45 |
+
file.write(f"{timestamp},{chatinput},{chatresponse}\n")
|
| 46 |
|
| 47 |
return generate_text()
|
| 48 |
|