ahanbose commited on
Commit
40cd131
Β·
verified Β·
1 Parent(s): 2b42f8b

Update src/app.py

Browse files
Files changed (1) hide show
  1. src/app.py +10 -3
src/app.py CHANGED
@@ -30,8 +30,14 @@ if str(ROOT) not in sys.path:
30
  sys.path.insert(0, str(ROOT))
31
 
32
  # ── Create required directories ────────────────────────────────────────────────
33
- for d in ["data/uploads", "data/faiss_index"]:
34
- Path(d).mkdir(parents=True, exist_ok=True)
 
 
 
 
 
 
35
 
36
  # Heavy deps imported lazily inside @st.cache_resource to avoid blocking startup
37
  @st.cache_resource(show_spinner="⏳ Loading ESG engine…")
@@ -326,7 +332,8 @@ def page_ingestion():
326
  st.markdown("# πŸ“€ Data Ingestion")
327
  st.markdown("Upload campus sustainability files to build the local RAG knowledge base.")
328
 
329
- processor = DocumentProcessor(upload_dir="data/uploads")
 
330
 
331
  col1, col2 = st.columns([3, 2], gap="large")
332
 
 
30
  sys.path.insert(0, str(ROOT))
31
 
32
  # ── Create required directories ────────────────────────────────────────────────
33
+ # for d in ["data/uploads", "data/faiss_index"]:
34
+ # Path(d).mkdir(parents=True, exist_ok=True)
35
+
36
+ # REPLACE WITH:
37
+ _IS_HF = os.getenv("SPACE_ID") is not None
38
+ _DATA_ROOT = Path("/tmp") if _IS_HF else Path("data")
39
+ for d in [_DATA_ROOT / "uploads", _DATA_ROOT / "faiss_index"]:
40
+ d.mkdir(parents=True, exist_ok=True)
41
 
42
  # Heavy deps imported lazily inside @st.cache_resource to avoid blocking startup
43
  @st.cache_resource(show_spinner="⏳ Loading ESG engine…")
 
332
  st.markdown("# πŸ“€ Data Ingestion")
333
  st.markdown("Upload campus sustainability files to build the local RAG knowledge base.")
334
 
335
+ # processor = DocumentProcessor(upload_dir="data/uploads")
336
+ processor = DocumentProcessor(upload_dir=str(_DATA_ROOT / "uploads"))
337
 
338
  col1, col2 = st.columns([3, 2], gap="large")
339