peterpull commited on
Commit
3dc878a
·
1 Parent(s): 308df49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -46,14 +46,13 @@ def generate_html() -> str:
46
  html += "</div>"
47
  return html
48
 
49
-
50
  def store_message(chatinput: str, chatresponse: str):
51
  if chatinput and chatresponse:
52
  with open(DATA_FILE, "a") as csvfile:
53
- writer = csv.DictWriter(csvfile, fieldnames=["chatinput", "chatresponse", "time"])
54
- writer.writerow(
55
- {"chatinput": chatinput, "chatresponse": chatresponse, "time": str(datetime.now())}
56
- )
57
  commit_url = repo.push_to_hub()
58
  print(commit_url)
59
 
 
46
  html += "</div>"
47
  return html
48
 
 
49
  def store_message(chatinput: str, chatresponse: str):
50
  if chatinput and chatresponse:
51
  with open(DATA_FILE, "a") as csvfile:
52
+ writer = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
53
+ if csvfile.tell() == 0:
54
+ writer.writerow(['User input', 'Chatbot response', 'Date and Time'])
55
+ writer.writerow([chatinput, chatresponse, datetime.now().strftime('%Y-%m-%d %H:%M:%S')])
56
  commit_url = repo.push_to_hub()
57
  print(commit_url)
58