KeenWoo commited on
Commit
4e2d48a
·
verified ·
1 Parent(s): 2560483

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -14
app.py CHANGED
@@ -81,26 +81,19 @@ CONFIG = {
81
  "tones": ["warm", "neutral", "formal", "playful"]
82
  }
83
 
84
-
85
  # --- File Management & Vector Store Logic ---
86
- INDEX_BASE = os.getenv('INDEX_BASE', 'data')
 
 
 
87
  UPLOADS_BASE = os.path.join(INDEX_BASE, "uploads")
 
 
88
 
89
- # OPTION A: --- CHANGE THIS LINE ---
90
- PERSONAL_INDEX_PATH = os.path.join(str(Path.home()), "AlzCompanionData", "personal_faiss_index")
91
- # for another space: PERSONAL_INDEX_PATH = os.path.join(str(Path.home()), "AlzPersonalData", "personal_faiss_index")
92
- # changing it from the absolute path (designed for a single local computer) to relative path (perfect for Hugging Face Spaces):
93
- # Does NOT work -> PERSONAL_INDEX_PATH = os.path.join(INDEX_BASE, "personal_faiss_index")
94
- # OPTION A: --- END CHANGE ---
95
- # old code PERSONAL_INDEX_PATH = os.path.join(INDEX_BASE, "personal_faiss_index")
96
  os.makedirs(UPLOADS_BASE, exist_ok=True)
97
- # OPTION A: Also create the parent directory for the personal index
98
  os.makedirs(os.path.dirname(PERSONAL_INDEX_PATH), exist_ok=True)
99
 
100
- # OPTION B: --- Example for macOS or Linux ---
101
- # OPTION B: PERSONAL_INDEX_PATH = "/Users/YourUsername/AlzCompanionData/personal_faiss_index"
102
- # OPTION B: Make sure to create the directory
103
- # OPTION B: os.makedirs(os.path.dirname(PERSONAL_INDEX_PATH), exist_ok=True)
104
 
105
  THEME_PATHS = {t: os.path.join(INDEX_BASE, f"faiss_index_{t.replace(' ', '').lower()}") for t in CONFIG["themes"]}
106
  vectorstores = {}
 
81
  "tones": ["warm", "neutral", "formal", "playful"]
82
  }
83
 
 
84
  # --- File Management & Vector Store Logic ---
85
+ # Use relative paths for all data, making them visible and manageable in HF Spaces
86
+ INDEX_BASE = 'data'
87
+ PERSONAL_DATA_BASE = 'personal_data'
88
+
89
  UPLOADS_BASE = os.path.join(INDEX_BASE, "uploads")
90
+ PERSONAL_INDEX_PATH = os.path.join(PERSONAL_DATA_BASE, "personal_faiss_index")
91
+ THEME_PATHS = {t: os.path.join(INDEX_BASE, f"faiss_index_{t.replace(' ', '').lower()}") for t in CONFIG["themes"]}
92
 
93
+ # Ensure all necessary directories are created on startup
 
 
 
 
 
 
94
  os.makedirs(UPLOADS_BASE, exist_ok=True)
 
95
  os.makedirs(os.path.dirname(PERSONAL_INDEX_PATH), exist_ok=True)
96
 
 
 
 
 
97
 
98
  THEME_PATHS = {t: os.path.join(INDEX_BASE, f"faiss_index_{t.replace(' ', '').lower()}") for t in CONFIG["themes"]}
99
  vectorstores = {}