akshat1409 commited on
Commit
01b910a
Β·
verified Β·
1 Parent(s): c8b8760

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +14 -0
main.py CHANGED
@@ -22,6 +22,20 @@ from fastapi import FastAPI, HTTPException, Request
22
  from fastapi.middleware.cors import CORSMiddleware
23
  from pydantic import BaseModel, Field
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  import rag_chain # Importing this triggers model/DB load at startup
26
 
27
  # ─── App state ────────────────────────────────────────────────────────────────
 
22
  from fastapi.middleware.cors import CORSMiddleware
23
  from pydantic import BaseModel, Field
24
 
25
+ import os
26
+ import zipfile
27
+
28
+ # ─── Ensure Database is Unzipped BEFORE loading RAG pipeline ──────────────────
29
+ ZIP_PATH = "chroma_db.zip"
30
+ EXTRACT_PATH = "."
31
+ DB_FOLDER = "chroma_db"
32
+
33
+ if os.path.exists(ZIP_PATH) and not os.path.exists(DB_FOLDER):
34
+ print(f"πŸ“¦ Unzipping {ZIP_PATH}...")
35
+ with zipfile.ZipFile(ZIP_PATH, 'r') as zip_ref:
36
+ zip_ref.extractall(EXTRACT_PATH)
37
+ print("βœ… Unzipping complete.")
38
+
39
  import rag_chain # Importing this triggers model/DB load at startup
40
 
41
  # ─── App state ────────────────────────────────────────────────────────────────