Update app.py
Browse files
app.py
CHANGED
@@ -3,12 +3,22 @@ import pdfplumber
|
|
3 |
import spacy
|
4 |
import openai
|
5 |
import os
|
|
|
|
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
|
10 |
-
#
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
def extract_text_from_pdf(pdf_file):
|
14 |
"""Extracts text from an uploaded PDF resume."""
|
@@ -75,3 +85,4 @@ if uploaded_file is not None:
|
|
75 |
st.success("✅ Resume analyzed successfully!")
|
76 |
else:
|
77 |
st.error("Could not extract text from the PDF. Please try another file.")
|
|
|
|
3 |
import spacy
|
4 |
import openai
|
5 |
import os
|
6 |
+
from dotenv import load_dotenv
|
7 |
+
import subprocess
|
8 |
|
9 |
+
# Load environment variables from .env file
|
10 |
+
load_dotenv()
|
11 |
|
12 |
+
# Set OpenAI API key
|
13 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
14 |
+
|
15 |
+
# Load spaCy model with error handling
|
16 |
+
try:
|
17 |
+
nlp = spacy.load("en_core_web_sm")
|
18 |
+
except OSError:
|
19 |
+
st.warning("Downloading 'en_core_web_sm' model. Please wait...")
|
20 |
+
subprocess.run(["python", "-m", "spacy", "download", "en_core_web_sm"])
|
21 |
+
nlp = spacy.load("en_core_web_sm")
|
22 |
|
23 |
def extract_text_from_pdf(pdf_file):
|
24 |
"""Extracts text from an uploaded PDF resume."""
|
|
|
85 |
st.success("✅ Resume analyzed successfully!")
|
86 |
else:
|
87 |
st.error("Could not extract text from the PDF. Please try another file.")
|
88 |
+
|