Anne31415 commited on
Commit
ed3f96e
1 Parent(s): 1b4370e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -216,23 +216,22 @@ def save_conversation(chat_history, session_id, page_number):
216
  json.dump(full_chat_history, file, indent=4)
217
  st.text(f"Conversation saved/updated in file: {filename}")
218
 
219
- # Git operations
 
220
  try:
221
  # Change directory to Chat_Store for Git operations
222
  original_dir = os.getcwd()
223
- st.text(f"Original directory: {original_dir}")
224
  os.chdir('Chat_Store')
225
-
226
- st.text(f"Current working directory (after change): {os.getcwd()}")
227
- st.text(f"Files in current directory: {os.listdir()}")
228
-
229
- repo2.git_add(filename)
230
  repo2.git_commit(f"Add/update conversation log for session {session_id}")
231
  repo2.git_push()
232
-
233
  # Change back to the original directory
234
  os.chdir(original_dir)
235
- st.text(f"Changed back to original directory: {original_dir}")
236
  except Exception as e:
237
  st.error(f"Error during Git operations: {e}")
238
 
 
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()
 
224
  os.chdir('Chat_Store')
225
+
226
+ # Correct file path relative to the Git repository's root
227
+ git_file_path = f"conversation_logs/{session_id}_page{page_number}.json"
228
+
229
+ repo2.git_add(git_file_path)
230
  repo2.git_commit(f"Add/update conversation log for session {session_id}")
231
  repo2.git_push()
232
+
233
  # Change back to the original directory
234
  os.chdir(original_dir)
 
235
  except Exception as e:
236
  st.error(f"Error during Git operations: {e}")
237