akryldigital commited on
Commit
6493c82
·
verified ·
1 Parent(s): 973ca8b

fix folder permissions

Browse files
Files changed (1) hide show
  1. multi_agent_chatbot.py +8 -2
multi_agent_chatbot.py CHANGED
@@ -142,13 +142,14 @@ class MultiAgentRAGChatbot:
142
  # Conversations directory - use absolute path in /app to ensure writability
143
  self.conversations_dir = Path("/app/conversations")
144
  try:
145
- self.conversations_dir.mkdir(mode=0o755, exist_ok=True)
 
146
  except (PermissionError, OSError) as e:
147
  logger.warning(f"Could not create conversations directory at {self.conversations_dir}: {e}")
148
  # Fallback to a relative path (current directory)
149
  self.conversations_dir = Path("conversations")
150
  try:
151
- self.conversations_dir.mkdir(mode=0o755, exist_ok=True)
152
  except (PermissionError, OSError) as e2:
153
  logger.error(f"Could not create conversations directory at {self.conversations_dir}: {e2}")
154
  raise RuntimeError(f"Failed to create conversations directory: {e2}")
@@ -1154,6 +1155,9 @@ Generate a conversational response based on your knowledge:""")
1154
  def _save_conversation(self, conversation_file: Path, conversation: Dict[str, Any]):
1155
  """Save conversation to file"""
1156
  try:
 
 
 
1157
  # Convert messages to serializable format
1158
  messages_data = []
1159
  for msg in conversation["messages"]:
@@ -1174,6 +1178,8 @@ Generate a conversational response based on your knowledge:""")
1174
 
1175
  except Exception as e:
1176
  logger.error(f"Could not save conversation: {e}")
 
 
1177
 
1178
 
1179
  def get_multi_agent_chatbot():
 
142
  # Conversations directory - use absolute path in /app to ensure writability
143
  self.conversations_dir = Path("/app/conversations")
144
  try:
145
+ # Use 777 permissions for maximum compatibility (HF Spaces runs as different user)
146
+ self.conversations_dir.mkdir(parents=True, mode=0o777, exist_ok=True)
147
  except (PermissionError, OSError) as e:
148
  logger.warning(f"Could not create conversations directory at {self.conversations_dir}: {e}")
149
  # Fallback to a relative path (current directory)
150
  self.conversations_dir = Path("conversations")
151
  try:
152
+ self.conversations_dir.mkdir(parents=True, mode=0o777, exist_ok=True)
153
  except (PermissionError, OSError) as e2:
154
  logger.error(f"Could not create conversations directory at {self.conversations_dir}: {e2}")
155
  raise RuntimeError(f"Failed to create conversations directory: {e2}")
 
1155
  def _save_conversation(self, conversation_file: Path, conversation: Dict[str, Any]):
1156
  """Save conversation to file"""
1157
  try:
1158
+ # Ensure the conversations directory exists with proper permissions
1159
+ conversation_file.parent.mkdir(parents=True, mode=0o777, exist_ok=True)
1160
+
1161
  # Convert messages to serializable format
1162
  messages_data = []
1163
  for msg in conversation["messages"]:
 
1178
 
1179
  except Exception as e:
1180
  logger.error(f"Could not save conversation: {e}")
1181
+ import traceback
1182
+ logger.error(f"Traceback: {traceback.format_exc()}")
1183
 
1184
 
1185
  def get_multi_agent_chatbot():