Anne31415 commited on
Commit
7244e04
1 Parent(s): 64e0554

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -7
app.py CHANGED
@@ -197,27 +197,22 @@ def save_conversation(chat_history, session_id, page_number):
197
  base_path = "Chat_Store/conversation_logs"
198
  if not os.path.exists(base_path):
199
  os.makedirs(base_path)
200
- st.text(f"Created directory: {base_path}")
201
 
202
  filename = f"{base_path}/{session_id}_page{page_number}.json"
203
- st.text(f"Filename for conversation log: {filename}")
204
 
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
 
219
-
220
- # Git operations
221
  try:
222
  # Change directory to Chat_Store for Git operations
223
  original_dir = os.getcwd()
 
197
  base_path = "Chat_Store/conversation_logs"
198
  if not os.path.exists(base_path):
199
  os.makedirs(base_path)
 
200
 
201
  filename = f"{base_path}/{session_id}_page{page_number}.json"
 
202
 
203
  # Check if the log file already exists
204
  existing_data = []
205
  if os.path.exists(filename):
206
  with open(filename, 'r', encoding='utf-8') as file:
207
  existing_data = json.load(file)
 
208
 
209
  # Append the new chat history to the existing data
210
  full_chat_history = existing_data + chat_history
211
 
212
  with open(filename, 'w', encoding='utf-8') as file:
213
+ json.dump(full_chat_history, file, indent=4, ensure_ascii=False)
 
214
 
215
+ # Git operations
 
216
  try:
217
  # Change directory to Chat_Store for Git operations
218
  original_dir = os.getcwd()