Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,38 +10,50 @@ st.title("AI-Powered ATS Screening")
|
|
10 |
|
11 |
# Initialize session state variables
|
12 |
if "resume_data" not in st.session_state:
|
13 |
-
st.session_state.resume_data =
|
14 |
|
15 |
if "jobdescription" not in st.session_state:
|
16 |
st.session_state.jobdescription = ""
|
17 |
|
18 |
-
# Upload
|
19 |
-
st.header("Step 1:
|
20 |
-
pdf = st.file_uploader("Upload your resume (PDF only):", type="pdf")
|
21 |
-
|
22 |
-
if pdf:
|
23 |
-
st.success("Resume uploaded successfully.")
|
24 |
-
st.session_state.resume_data = ExtractPDFText(pdf)
|
25 |
-
|
26 |
-
# Input Job Description
|
27 |
-
st.header("Step 2: Enter the Job Description")
|
28 |
st.session_state.jobdescription = st.text_area("Paste the job description below:")
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
# Submit Button
|
31 |
submit = st.button("Submit")
|
32 |
|
33 |
# Define start function
|
34 |
def start():
|
35 |
if st.session_state.resume_data and st.session_state.jobdescription:
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
46 |
else:
|
47 |
-
st.info("Please upload
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
# Initialize session state variables
|
12 |
if "resume_data" not in st.session_state:
|
13 |
+
st.session_state.resume_data = []
|
14 |
|
15 |
if "jobdescription" not in st.session_state:
|
16 |
st.session_state.jobdescription = ""
|
17 |
|
18 |
+
# Step 1: Upload Resumes (Multiple PDFs)
|
19 |
+
st.header("Step 1: Enter the Job Description")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
st.session_state.jobdescription = st.text_area("Paste the job description below:")
|
21 |
|
22 |
+
# Step 2: Input Job Description
|
23 |
+
st.header("Step 2: Upload Your Resumes")
|
24 |
+
pdf_files = st.file_uploader("Upload your resumes (PDF only):", type="pdf", accept_multiple_files=True)
|
25 |
+
|
26 |
+
if pdf_files:
|
27 |
+
st.session_state.resume_data = [] # Reset to avoid duplication
|
28 |
+
for pdf in pdf_files:
|
29 |
+
extracted_text = ExtractPDFText(pdf)
|
30 |
+
st.session_state.resume_data.append({"name": pdf.name, "text": extracted_text})
|
31 |
+
st.success(f"{len(pdf_files)} resumes uploaded and processed successfully!")
|
32 |
+
|
33 |
# Submit Button
|
34 |
submit = st.button("Submit")
|
35 |
|
36 |
# Define start function
|
37 |
def start():
|
38 |
if st.session_state.resume_data and st.session_state.jobdescription:
|
39 |
+
st.subheader("Results:")
|
40 |
+
for resume in st.session_state.resume_data:
|
41 |
+
with st.spinner(f"Analyzing {resume['name']}..."):
|
42 |
+
# Calculate ATS score
|
43 |
+
ATS_score = calculateATSscore(resume["text"], st.session_state.jobdescription)
|
44 |
+
# Generate feedback from model
|
45 |
+
model_feedback = modelFeedback(ATS_score, resume["text"])
|
46 |
+
time.sleep(1) # Optional: Simulate processing time
|
47 |
+
|
48 |
+
# Display feedback for each resume
|
49 |
+
st.write(f"### Resume: {resume['name']}")
|
50 |
+
st.write(f"**ATS Score:** {ATS_score:.2f}")
|
51 |
+
st.subheader("AI Feedback:")
|
52 |
+
st.write(model_feedback.text)
|
53 |
+
st.write("---")
|
54 |
else:
|
55 |
+
st.info("Please upload resumes and provide a job description.")
|
56 |
+
|
57 |
+
# Process when submit button is clicked
|
58 |
+
if submit:
|
59 |
+
start()
|