peterpull commited on
Commit
8149bed
·
1 Parent(s): 6ad247e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -52,10 +52,17 @@ def generate_text() -> str:
52
 
53
  def store_message(chatinput: str, chatresponse: str):
54
  if chatinput and chatresponse:
 
 
 
 
 
 
 
55
  with open(DATA_FILE, "a") as file:
56
- file.write(f"{datetime.now()},{chatinput},{chatresponse}\n")
57
- print(f"Wrote to datafile: {datetime.now()},{chatinput},{chatresponse}\n")
58
-
59
  #need to find a way to push back to dataset repo
60
  HF_WRITE_TOKEN = os.environ.get("WRITE_TOKEN")
61
  api.upload_file(
 
52
 
53
  def store_message(chatinput: str, chatresponse: str):
54
  if chatinput and chatresponse:
55
+
56
+ timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
57
+ user_input = f"User: {chatinput}"
58
+ chatbot_response = f"Chatbot: {chatresponse}"
59
+ separator = "-" * 30
60
+ message = f"{timestamp}\n{user_input}\n{chatbot_response}\n{separator}\n"
61
+
62
  with open(DATA_FILE, "a") as file:
63
+ file.write(message)
64
+ print(f"Wrote to datafile: {message}")
65
+
66
  #need to find a way to push back to dataset repo
67
  HF_WRITE_TOKEN = os.environ.get("WRITE_TOKEN")
68
  api.upload_file(