peterpull commited on
Commit
1b10a40
·
1 Parent(s): 53e90e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -25,13 +25,26 @@ repo = Repository(
25
  clone_from=DATASET_REPO_URL,
26
  use_auth_token=HF_TOKEN)
27
 
28
- #appends to data.txt in the dataset repo
 
 
 
 
 
 
 
 
 
 
29
  def store_message(chatinput: str, chatresponse: str):
30
  if chatinput and chatresponse:
31
  with open(DATA_FILE, "a") as file:
32
  now = datetime.now()
33
  timestamp = now.strftime("%Y-%m-%d %H:%M:%S")
34
  file.write(f"{timestamp},{chatinput},{chatresponse}\n")
 
 
 
35
 
36
 
37
  #gets the index file which is the context data
 
25
  clone_from=DATASET_REPO_URL,
26
  use_auth_token=HF_TOKEN)
27
 
28
+ def generate_text() -> str:
29
+ with open(DATA_FILE) as file:
30
+ text = ""
31
+ for line in file:
32
+ row_parts = line.strip().split(",")
33
+ if len(row_parts) != 3:
34
+ continue
35
+ time, user, chatbot = row_parts
36
+ text += f"Time: {time}\nUser: {user}\nChatbot: {chatbot}\n\n"
37
+ return text if text else "No messages yet"
38
+
39
  def store_message(chatinput: str, chatresponse: str):
40
  if chatinput and chatresponse:
41
  with open(DATA_FILE, "a") as file:
42
  now = datetime.now()
43
  timestamp = now.strftime("%Y-%m-%d %H:%M:%S")
44
  file.write(f"{timestamp},{chatinput},{chatresponse}\n")
45
+ print(f"Stored message: {timestamp},{chatinput},{chatresponse}")
46
+
47
+ return generate_text()
48
 
49
 
50
  #gets the index file which is the context data