Ansh99 commited on
Commit
7792bfc
·
verified ·
1 Parent(s): 6ecde1c

Update rag.py

Browse files
Files changed (1) hide show
  1. rag.py +4 -3
rag.py CHANGED
@@ -14,7 +14,7 @@ from langchain_chroma import Chroma
14
  from langchain_core.tools import tool
15
  from langchain.embeddings import SentenceTransformerEmbeddings
16
 
17
- # Load environment variables from .env file for local development
18
  load_dotenv()
19
 
20
  # ===========================
@@ -22,7 +22,8 @@ load_dotenv()
22
  # ===========================
23
  GROQ_API_KEY = os.getenv("GROQ_API_KEY")
24
 
25
- PDF_PATH = os.path.join(os.path.dirname(__file__), "data", "D:\\Projects\\Portfolio-Assistant-main\\hh\\ansh_resume.pdf")
 
26
  PERSIST_DIRECTORY = os.path.join(os.path.dirname(__file__), "portfolio_agent_db")
27
 
28
  if not GROQ_API_KEY:
@@ -39,7 +40,7 @@ if not os.path.exists(os.path.join(PERSIST_DIRECTORY, "chroma.sqlite3")):
39
 
40
  # Validate PDF exists before trying to load it
41
  if not os.path.exists(PDF_PATH):
42
- raise FileNotFoundError(f"❌ PDF not found at relative path: {PDF_PATH}")
43
 
44
  print("📖 Loading resume...")
45
  pdf_loader = PyPDFLoader(PDF_PATH)
 
14
  from langchain_core.tools import tool
15
  from langchain.embeddings import SentenceTransformerEmbeddings
16
 
17
+ # Load environment variables from .env file for local development and Spaces secrets
18
  load_dotenv()
19
 
20
  # ===========================
 
22
  # ===========================
23
  GROQ_API_KEY = os.getenv("GROQ_API_KEY")
24
 
25
+ # Use correct relative path (works on Hugging Face!)
26
+ PDF_PATH = os.path.join(os.path.dirname(__file__), "ansh_resume.pdf")
27
  PERSIST_DIRECTORY = os.path.join(os.path.dirname(__file__), "portfolio_agent_db")
28
 
29
  if not GROQ_API_KEY:
 
40
 
41
  # Validate PDF exists before trying to load it
42
  if not os.path.exists(PDF_PATH):
43
+ raise FileNotFoundError(f"❌ PDF not found at path: {PDF_PATH}")
44
 
45
  print("📖 Loading resume...")
46
  pdf_loader = PyPDFLoader(PDF_PATH)