Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -671,91 +671,93 @@ def analyze_job_fit(resume_summary, job_description, models):
|
|
671 |
models = load_models()
|
672 |
|
673 |
#####################################
|
674 |
-
# Main
|
675 |
#####################################
|
676 |
-
|
677 |
-
|
|
|
|
|
|
|
|
|
678 |
"""
|
679 |
-
|
680 |
-
"""
|
681 |
-
)
|
682 |
|
683 |
-
# Resume upload
|
684 |
-
uploaded_file = st.file_uploader("Upload your resume (.docx, .doc, or .txt)", type=["docx", "doc", "txt"])
|
685 |
|
686 |
-
# Job description input
|
687 |
-
job_description = st.text_area("Enter Job Description", height=200, placeholder="Paste the job description here...")
|
688 |
|
689 |
-
# Process button with optimized flow
|
690 |
-
if uploaded_file is not None and job_description and st.button("Analyze Job Fit"):
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
# Step 1: Extract text
|
696 |
-
status_text.text("Step 1/3: Extracting text from resume...")
|
697 |
-
resume_text = extract_text_from_file(uploaded_file)
|
698 |
-
progress_bar.progress(25)
|
699 |
-
|
700 |
-
if resume_text.startswith("Error") or resume_text == "Unsupported file type. Please upload a .docx, .doc, or .txt file.":
|
701 |
-
st.error(resume_text)
|
702 |
-
else:
|
703 |
-
# Step 2: Generate summary
|
704 |
-
status_text.text("Step 2/3: Analyzing resume and generating summary...")
|
705 |
-
summary, summarization_time = summarize_resume_text(resume_text, models)
|
706 |
-
progress_bar.progress(50)
|
707 |
|
708 |
-
#
|
709 |
-
|
710 |
-
|
|
|
711 |
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
716 |
|
717 |
-
|
718 |
-
|
719 |
|
720 |
-
|
721 |
-
|
722 |
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
|
733 |
-
|
734 |
-
|
735 |
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
|
760 |
if __name__ == "__main__":
|
761 |
main()
|
|
|
671 |
models = load_models()
|
672 |
|
673 |
#####################################
|
674 |
+
# Main Function
|
675 |
#####################################
|
676 |
+
def main():
|
677 |
+
"""Main function for the Streamlit application"""
|
678 |
+
st.title("Resume-Job Fit Analyzer")
|
679 |
+
st.markdown(
|
680 |
+
"""
|
681 |
+
Upload your resume file in **.docx**, **.doc**, or **.txt** format and enter a job description to see how well you match with the job requirements.
|
682 |
"""
|
683 |
+
)
|
|
|
|
|
684 |
|
685 |
+
# Resume upload
|
686 |
+
uploaded_file = st.file_uploader("Upload your resume (.docx, .doc, or .txt)", type=["docx", "doc", "txt"])
|
687 |
|
688 |
+
# Job description input
|
689 |
+
job_description = st.text_area("Enter Job Description", height=200, placeholder="Paste the job description here...")
|
690 |
|
691 |
+
# Process button with optimized flow
|
692 |
+
if uploaded_file is not None and job_description and st.button("Analyze Job Fit"):
|
693 |
+
# Create a placeholder for the progress bar
|
694 |
+
progress_bar = st.progress(0)
|
695 |
+
status_text = st.empty()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
696 |
|
697 |
+
# Step 1: Extract text
|
698 |
+
status_text.text("Step 1/3: Extracting text from resume...")
|
699 |
+
resume_text = extract_text_from_file(uploaded_file)
|
700 |
+
progress_bar.progress(25)
|
701 |
|
702 |
+
if resume_text.startswith("Error") or resume_text == "Unsupported file type. Please upload a .docx, .doc, or .txt file.":
|
703 |
+
st.error(resume_text)
|
704 |
+
else:
|
705 |
+
# Step 2: Generate summary
|
706 |
+
status_text.text("Step 2/3: Analyzing resume and generating summary...")
|
707 |
+
summary, summarization_time = summarize_resume_text(resume_text, models)
|
708 |
+
progress_bar.progress(50)
|
709 |
+
|
710 |
+
# Display summary
|
711 |
+
st.subheader("Your Resume Summary")
|
712 |
+
st.markdown(summary)
|
713 |
+
|
714 |
+
# Step 3: Generate job fit assessment
|
715 |
+
status_text.text("Step 3/3: Evaluating job fit (this will take a moment)...")
|
716 |
+
assessment, fit_score, assessment_time = analyze_job_fit(summary, job_description, models)
|
717 |
+
progress_bar.progress(100)
|
718 |
|
719 |
+
# Clear status messages
|
720 |
+
status_text.empty()
|
721 |
|
722 |
+
# Display job fit results
|
723 |
+
st.subheader("Job Fit Assessment")
|
724 |
|
725 |
+
# Display fit score with label
|
726 |
+
fit_labels = {
|
727 |
+
0: "NOT FIT",
|
728 |
+
1: "POTENTIAL FIT",
|
729 |
+
2: "GOOD FIT"
|
730 |
+
}
|
731 |
+
|
732 |
+
# Show the score prominently
|
733 |
+
st.markdown(f"## {fit_labels[fit_score]}")
|
734 |
|
735 |
+
# Display assessment
|
736 |
+
st.markdown(assessment)
|
737 |
|
738 |
+
st.info(f"Analysis completed in {(summarization_time + assessment_time):.2f} seconds")
|
739 |
+
|
740 |
+
# Add potential next steps based on the fit score
|
741 |
+
st.subheader("Recommended Next Steps")
|
742 |
+
|
743 |
+
if fit_score == 2:
|
744 |
+
st.markdown("""
|
745 |
+
- Apply for this position as you appear to be a good match
|
746 |
+
- Prepare for interviews by focusing on your relevant experience
|
747 |
+
- Highlight your matching skills in your cover letter
|
748 |
+
""")
|
749 |
+
elif fit_score == 1:
|
750 |
+
st.markdown("""
|
751 |
+
- Consider applying but address skill gaps in your cover letter
|
752 |
+
- Emphasize transferable skills and relevant experience
|
753 |
+
- Prepare to discuss how you can quickly develop missing skills
|
754 |
+
""")
|
755 |
+
else:
|
756 |
+
st.markdown("""
|
757 |
+
- Look for positions better aligned with your current skills
|
758 |
+
- If interested in this field, focus on developing the required skills
|
759 |
+
- Consider similar roles with fewer experience requirements
|
760 |
+
""")
|
761 |
|
762 |
if __name__ == "__main__":
|
763 |
main()
|