peterpull commited on
Commit
57959a9
·
1 Parent(s): e0393c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -21,19 +21,18 @@ def chatbot(input_text, mentioned_person='Mediator John Haynes'):
21
  prompt = f"You are {mentioned_person}: {input_text}\n\n At the end of your answer ask a provocative question."
22
  response = index.query(prompt, response_mode="compact")
23
 
24
-
25
  # Save chat log
26
  current_time = datetime.datetime.now()
27
  current_time_str = current_time.strftime("%Y-%m-%d_%H-%M-%S")
28
- chat_log_filename = f"{current_time_str}.txt"
29
- chat_log_filepath = os.path.join('docs/chathistory', chat_log_filename)
30
- with open(chat_log_filepath, "w") as f:
31
- f.write(f"Chat started at {current_time_str}\n\n")
32
  f.write(f"User: {input_text}\n")
33
  f.write(f"Chatbot: {response.response}\n\n")
34
 
35
  return response.response
36
-
37
 
38
  iface = gr.Interface(fn=chatbot,
39
  inputs=gr.inputs.Textbox(lines=5, label="Enter your question"),
 
21
  prompt = f"You are {mentioned_person}: {input_text}\n\n At the end of your answer ask a provocative question."
22
  response = index.query(prompt, response_mode="compact")
23
 
 
24
  # Save chat log
25
  current_time = datetime.datetime.now()
26
  current_time_str = current_time.strftime("%Y-%m-%d_%H-%M-%S")
27
+ chat_log_filename = "chathistory.txt"
28
+ chat_log_filepath = os.path.join('chathistory', chat_log_filename)
29
+ with open(chat_log_filepath, "a") as f:
30
+ f.write(f"Chat at {current_time_str}\n")
31
  f.write(f"User: {input_text}\n")
32
  f.write(f"Chatbot: {response.response}\n\n")
33
 
34
  return response.response
35
+
36
 
37
  iface = gr.Interface(fn=chatbot,
38
  inputs=gr.inputs.Textbox(lines=5, label="Enter your question"),