Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,7 @@ import tempfile
|
|
| 6 |
from datetime import datetime
|
| 7 |
from typing import List, Dict, Any, Optional
|
| 8 |
from pytube import YouTube
|
|
|
|
| 9 |
|
| 10 |
# --- Agent Imports & Safe Fallbacks ---
|
| 11 |
try:
|
|
@@ -54,12 +55,25 @@ CONFIG = {
|
|
| 54 |
# --- File Management & Vector Store Logic ---
|
| 55 |
INDEX_BASE = os.getenv('INDEX_BASE', 'data')
|
| 56 |
UPLOADS_BASE = os.path.join(INDEX_BASE, "uploads")
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
os.makedirs(UPLOADS_BASE, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
THEME_PATHS = {t: os.path.join(INDEX_BASE, f"faiss_index_{t.replace(' ', '').lower()}") for t in CONFIG["themes"]}
|
| 60 |
vectorstores = {}
|
| 61 |
personal_vectorstore = None
|
| 62 |
|
|
|
|
| 63 |
def canonical_theme(tk: str) -> str: return tk if tk in CONFIG["themes"] else "All"
|
| 64 |
def theme_upload_dir(theme: str) -> str:
|
| 65 |
p = os.path.join(UPLOADS_BASE, f"theme_{canonical_theme(theme).replace(' ', '').lower()}")
|
|
|
|
| 6 |
from datetime import datetime
|
| 7 |
from typing import List, Dict, Any, Optional
|
| 8 |
from pytube import YouTube
|
| 9 |
+
from pathlib import Path # <-- Add this import at the top of your file with the other imports
|
| 10 |
|
| 11 |
# --- Agent Imports & Safe Fallbacks ---
|
| 12 |
try:
|
|
|
|
| 55 |
# --- File Management & Vector Store Logic ---
|
| 56 |
INDEX_BASE = os.getenv('INDEX_BASE', 'data')
|
| 57 |
UPLOADS_BASE = os.path.join(INDEX_BASE, "uploads")
|
| 58 |
+
|
| 59 |
+
# OPTION A: --- CHANGE THIS LINE ---
|
| 60 |
+
PERSONAL_INDEX_PATH = os.path.join(str(Path.home()), "AlzCompanionData", "personal_faiss_index")
|
| 61 |
+
# OPTION A: --- END CHANGE ---
|
| 62 |
+
# old code PERSONAL_INDEX_PATH = os.path.join(INDEX_BASE, "personal_faiss_index")
|
| 63 |
os.makedirs(UPLOADS_BASE, exist_ok=True)
|
| 64 |
+
# OPTION A: Also create the parent directory for the personal index
|
| 65 |
+
os.makedirs(os.path.dirname(PERSONAL_INDEX_PATH), exist_ok=True)
|
| 66 |
+
|
| 67 |
+
# OPTION B: --- Example for macOS or Linux ---
|
| 68 |
+
# OPTION B: PERSONAL_INDEX_PATH = "/Users/YourUsername/AlzCompanionData/personal_faiss_index"
|
| 69 |
+
# OPTION B: Make sure to create the directory
|
| 70 |
+
# OPTION B: os.makedirs(os.path.dirname(PERSONAL_INDEX_PATH), exist_ok=True)
|
| 71 |
+
|
| 72 |
THEME_PATHS = {t: os.path.join(INDEX_BASE, f"faiss_index_{t.replace(' ', '').lower()}") for t in CONFIG["themes"]}
|
| 73 |
vectorstores = {}
|
| 74 |
personal_vectorstore = None
|
| 75 |
|
| 76 |
+
|
| 77 |
def canonical_theme(tk: str) -> str: return tk if tk in CONFIG["themes"] else "All"
|
| 78 |
def theme_upload_dir(theme: str) -> str:
|
| 79 |
p = os.path.join(UPLOADS_BASE, f"theme_{canonical_theme(theme).replace(' ', '').lower()}")
|