peterpull commited on
Commit
82fa02f
·
1 Parent(s): c7cdf77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -40,8 +40,8 @@ def generate_html() -> str:
40
  html = "<div class='chatbot'>"
41
  for row in rows:
42
  html += "<div>"
43
- html += f"<span>{row['chatinput']}</span>"
44
- html += f"<span class='message'>{row['chatresponse']}</span>"
45
  html += f"<span class='time'>{row['time']}</span>"
46
  html += "</div>"
47
  html += "</div>"
@@ -50,10 +50,10 @@ def generate_html() -> str:
50
  def store_message(chatinput: str, chatresponse: str):
51
  if chatinput and chatresponse:
52
  with open(DATA_FILE, "a") as csvfile:
53
- writer = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
54
- if csvfile.tell() == 0:
55
- writer.writerow(['User input', 'Chatbot response', 'Date and Time'])
56
- writer.writerow([chatinput, chatresponse, datetime.now().strftime('%Y-%m-%d %H:%M:%S')])
57
  commit_url = repo.push_to_hub()
58
  print(commit_url)
59
 
 
40
  html = "<div class='chatbot'>"
41
  for row in rows:
42
  html += "<div>"
43
+ html += f"<span>{row['User']}</span>"
44
+ html += f"<span class='message'>{row['Chatbot']}</span>"
45
  html += f"<span class='time'>{row['time']}</span>"
46
  html += "</div>"
47
  html += "</div>"
 
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=["User", "Chatbot", "time"])
54
+ writer.writerow(
55
+ {"User": chatinput, "Chatbot": chatresponse, "time": str(datetime.now())}
56
+ )
57
  commit_url = repo.push_to_hub()
58
  print(commit_url)
59