Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,18 +21,21 @@ 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 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
return response.response
|
| 38 |
|
|
|
|
| 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 |
+
directory_path = "history"
|
| 26 |
+
filename = "chathistory.txt"
|
| 27 |
+
file_path = os.path.join(directory_path, filename)
|
| 28 |
+
|
| 29 |
+
current_time = datetime.datetime.now()
|
| 30 |
+
current_time_str = current_time.strftime("%Y-%m-%d_%H-%M-%S")
|
| 31 |
+
|
| 32 |
+
if not os.path.exists(directory_path):
|
| 33 |
+
os.makedirs(directory_path)
|
| 34 |
+
|
| 35 |
+
with open(file_path, "a") as f:
|
| 36 |
+
f.write(f"Chat at {current_time_str}\n")
|
| 37 |
+
f.write(f"User: {input_text}\n")
|
| 38 |
+
f.write(f"Chatbot: {response.response}\n\n")
|
| 39 |
|
| 40 |
return response.response
|
| 41 |
|