peterpull commited on
Commit
63c93d9
·
1 Parent(s): 1011b73

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
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, time = 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
- file.write(f"{datetime.now()},{chatinput},{chatresponse}\n")
 
 
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