Update pages/model.py
Browse files- pages/model.py +31 -13
pages/model.py
CHANGED
|
@@ -32,26 +32,34 @@ def extract_text_from_pdf(uploaded_file):
|
|
| 32 |
loader = UnstructuredPDFLoader(tmp_path)
|
| 33 |
return loader.load()[0].page_content
|
| 34 |
except Exception as e:
|
| 35 |
-
st.error(f"Error reading PDF file: {e}")
|
| 36 |
return ""
|
| 37 |
|
| 38 |
def extract_text_from_txt(uploaded_file):
|
| 39 |
try:
|
| 40 |
return uploaded_file.read().decode("utf-8")
|
| 41 |
except Exception as e:
|
| 42 |
-
st.error(f"Error reading text file: {e}")
|
| 43 |
return ""
|
| 44 |
|
| 45 |
-
st.set_page_config(page_title="Resume & JD
|
| 46 |
-
st.
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
|
|
|
|
| 53 |
if not resume_file and not (jd_file or jd_text):
|
| 54 |
-
st.warning("Please upload at least one
|
| 55 |
else:
|
| 56 |
if resume_file:
|
| 57 |
resume_text = extract_text_from_pdf(resume_file)
|
|
@@ -62,8 +70,13 @@ if st.button("π Extract Data"):
|
|
| 62 |
f"Resume:\n{resume_text}"
|
| 63 |
)
|
| 64 |
resume_data = llm.invoke(resume_prompt)
|
| 65 |
-
st.
|
| 66 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
jd_text_extracted = ""
|
| 69 |
if jd_file:
|
|
@@ -82,5 +95,10 @@ if st.button("π Extract Data"):
|
|
| 82 |
f"Job Description:\n{jd_text_extracted}"
|
| 83 |
)
|
| 84 |
jd_data = llm.invoke(jd_prompt)
|
| 85 |
-
st.
|
| 86 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
loader = UnstructuredPDFLoader(tmp_path)
|
| 33 |
return loader.load()[0].page_content
|
| 34 |
except Exception as e:
|
| 35 |
+
st.error(f"β οΈ Error reading PDF file: {e}")
|
| 36 |
return ""
|
| 37 |
|
| 38 |
def extract_text_from_txt(uploaded_file):
|
| 39 |
try:
|
| 40 |
return uploaded_file.read().decode("utf-8")
|
| 41 |
except Exception as e:
|
| 42 |
+
st.error(f"β οΈ Error reading text file: {e}")
|
| 43 |
return ""
|
| 44 |
|
| 45 |
+
st.set_page_config(page_title="SmartHire AI β Resume & JD Analyzer", layout="centered")
|
| 46 |
+
st.markdown("<h1 style='text-align:center;'>π€ SmartHire AI</h1>", unsafe_allow_html=True)
|
| 47 |
+
st.markdown("<h4 style='text-align:center;color:gray;'>AI-powered Resume & Job Description Analyzer</h4><br>", unsafe_allow_html=True)
|
| 48 |
|
| 49 |
+
with st.container():
|
| 50 |
+
st.markdown("### π Upload Center")
|
| 51 |
+
col1, col2 = st.columns(2)
|
| 52 |
+
with col1:
|
| 53 |
+
resume_file = st.file_uploader("Upload Candidate Resume (PDF)", type=["pdf"])
|
| 54 |
+
with col2:
|
| 55 |
+
jd_file = st.file_uploader("Upload Job Description (PDF or TXT)", type=["pdf", "txt"])
|
| 56 |
+
|
| 57 |
+
jd_text = st.text_area("π Or paste the Job Description text below", height=150)
|
| 58 |
|
| 59 |
+
|
| 60 |
+
if st.button("π Analyze Now"):
|
| 61 |
if not resume_file and not (jd_file or jd_text):
|
| 62 |
+
st.warning("β οΈ Please upload at least one resume or job description.")
|
| 63 |
else:
|
| 64 |
if resume_file:
|
| 65 |
resume_text = extract_text_from_pdf(resume_file)
|
|
|
|
| 70 |
f"Resume:\n{resume_text}"
|
| 71 |
)
|
| 72 |
resume_data = llm.invoke(resume_prompt)
|
| 73 |
+
st.markdown("---")
|
| 74 |
+
st.subheader("π Candidate Summary")
|
| 75 |
+
st.markdown(f"""
|
| 76 |
+
<div style='background-color:#eef6fb;padding:15px;border-left:5px solid #0099cc;border-radius:6px'>
|
| 77 |
+
{resume_data}
|
| 78 |
+
</div>
|
| 79 |
+
""", unsafe_allow_html=True)
|
| 80 |
|
| 81 |
jd_text_extracted = ""
|
| 82 |
if jd_file:
|
|
|
|
| 95 |
f"Job Description:\n{jd_text_extracted}"
|
| 96 |
)
|
| 97 |
jd_data = llm.invoke(jd_prompt)
|
| 98 |
+
st.markdown("---")
|
| 99 |
+
st.subheader("π Job Role Breakdown")
|
| 100 |
+
st.markdown(f"""
|
| 101 |
+
<div style='background-color:#fff7e6;padding:15px;border-left:5px solid #ffaa00;border-radius:6px'>
|
| 102 |
+
{jd_data}
|
| 103 |
+
</div>
|
| 104 |
+
""", unsafe_allow_html=True)
|