Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
|
|
|
| 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 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
repo2.git_add(
|
| 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 |
|