Anne31415 commited on
Commit
64e0554
1 Parent(s): 960b433

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -205,14 +205,14 @@ def save_conversation(chat_history, session_id, page_number):
205
  # Check if the log file already exists
206
  existing_data = []
207
  if os.path.exists(filename):
208
- with open(filename, 'r') as file:
209
  existing_data = json.load(file)
210
  st.text(f"Existing data found in file: {filename}")
211
 
212
  # Append the new chat history to the existing data
213
  full_chat_history = existing_data + chat_history
214
 
215
- with open(filename, 'w') as file:
216
  json.dump(full_chat_history, file, indent=4)
217
  st.text(f"Conversation saved/updated in file: {filename}")
218
 
 
205
  # Check if the log file already exists
206
  existing_data = []
207
  if os.path.exists(filename):
208
+ with open(filename, 'r', encoding='utf-8') as file:
209
  existing_data = json.load(file)
210
  st.text(f"Existing data found in file: {filename}")
211
 
212
  # Append the new chat history to the existing data
213
  full_chat_history = existing_data + chat_history
214
 
215
+ with open(filename, 'w', encoding='utf-8') as file:
216
  json.dump(full_chat_history, file, indent=4)
217
  st.text(f"Conversation saved/updated in file: {filename}")
218