Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -140,7 +140,7 @@ def main():
|
|
| 140 |
|
| 141 |
# Select Task
|
| 142 |
st.sidebar.header("Select Task")
|
| 143 |
-
selection = st.sidebar.radio("Select option", ("Generate Job Adverstisment", "Resume Analysis","Resume Selection"))
|
| 144 |
|
| 145 |
# Generate Cover Letter
|
| 146 |
if selection == "Generate Job Adverstisment":
|
|
@@ -191,6 +191,21 @@ def main():
|
|
| 191 |
|
| 192 |
st.subheader("Upload Resume")
|
| 193 |
resume_file = st.file_uploader("Choose a file or drag and drop", type=["pdf"],accept_multiple_files=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
#st.header("Job Details")
|
| 196 |
st.subheader('Job Title')
|
|
@@ -200,7 +215,7 @@ def main():
|
|
| 200 |
st.subheader('Preferred Qualification')
|
| 201 |
job_pref = st.text_area("Enter any preferred skills or qualifications here", "")
|
| 202 |
resume_text = None
|
| 203 |
-
|
| 204 |
if selection == "Resume Analysis":
|
| 205 |
btn1=st.button("Generate Resume Analysis")
|
| 206 |
if btn1:
|
|
@@ -215,8 +230,10 @@ def main():
|
|
| 215 |
if st.session_state.input_hash != current_input_hash:
|
| 216 |
# Inputs have changed, generate new analysis
|
| 217 |
st.session_state.input_hash = current_input_hash
|
| 218 |
-
prompt_template = prompts.prompt_template_modern
|
| 219 |
-
|
|
|
|
|
|
|
| 220 |
|
| 221 |
# Cache the result
|
| 222 |
st.session_state.analysis = expand(response)
|
|
@@ -251,11 +268,22 @@ def main():
|
|
| 251 |
if st.session_state.input_hash_sel != current_input_hash:
|
| 252 |
# Inputs have changed, generate new analysis
|
| 253 |
st.session_state.input_hash_sel = current_input_hash
|
| 254 |
-
prompt_template = prompts.prompt_template_resumes_
|
| 255 |
-
|
|
|
|
|
|
|
| 256 |
print('response:',response)
|
| 257 |
-
response_anal=max(response, key=lambda x: x['overall_match_score'])
|
| 258 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
st.session_state.analysis_s = expand(response_anal)
|
| 260 |
st.session_state.analysis_mc_s = table_resp(response)
|
| 261 |
st.session_state.analysis_mc_s_exp = table_resp_exp(response)
|
|
|
|
| 140 |
|
| 141 |
# Select Task
|
| 142 |
st.sidebar.header("Select Task")
|
| 143 |
+
selection = st.sidebar.radio("Select option", ("Generate Job Adverstisment", "Resume Analysis","Resume Selection",'test'))
|
| 144 |
|
| 145 |
# Generate Cover Letter
|
| 146 |
if selection == "Generate Job Adverstisment":
|
|
|
|
| 191 |
|
| 192 |
st.subheader("Upload Resume")
|
| 193 |
resume_file = st.file_uploader("Choose a file or drag and drop", type=["pdf"],accept_multiple_files=True)
|
| 194 |
+
if resume_file:
|
| 195 |
+
# Calculate a hash of the new file selection
|
| 196 |
+
new_file_hash = hash_inputs(str(resume_file), '', '', '')
|
| 197 |
+
if 'last_file_hash' not in st.session_state or st.session_state.last_file_hash != new_file_hash:
|
| 198 |
+
# Clear cached responses because a new file is uploaded
|
| 199 |
+
st.session_state.analysis = None
|
| 200 |
+
st.session_state.analysis_mc = None
|
| 201 |
+
st.session_state.input_hash = None
|
| 202 |
+
st.session_state.analysis_s = None
|
| 203 |
+
st.session_state.input_hash_sel = None
|
| 204 |
+
st.session_state.analysis_mc_s = None
|
| 205 |
+
st.session_state.analysis_mc_s_exp = None
|
| 206 |
+
# Update last file hash
|
| 207 |
+
st.session_state.last_file_hash = new_file_hash
|
| 208 |
+
|
| 209 |
|
| 210 |
#st.header("Job Details")
|
| 211 |
st.subheader('Job Title')
|
|
|
|
| 215 |
st.subheader('Preferred Qualification')
|
| 216 |
job_pref = st.text_area("Enter any preferred skills or qualifications here", "")
|
| 217 |
resume_text = None
|
| 218 |
+
|
| 219 |
if selection == "Resume Analysis":
|
| 220 |
btn1=st.button("Generate Resume Analysis")
|
| 221 |
if btn1:
|
|
|
|
| 230 |
if st.session_state.input_hash != current_input_hash:
|
| 231 |
# Inputs have changed, generate new analysis
|
| 232 |
st.session_state.input_hash = current_input_hash
|
| 233 |
+
#prompt_template = prompts.prompt_template_modern
|
| 234 |
+
prompt_template = prompts.prompt_template_new
|
| 235 |
+
response = generate_analysis_new(resume_text, job_pref, job_title_text, must_have, prompt_template)
|
| 236 |
+
#generate_analysis(resume_text, job_pref, job_title_text, must_have, prompt_template)
|
| 237 |
|
| 238 |
# Cache the result
|
| 239 |
st.session_state.analysis = expand(response)
|
|
|
|
| 268 |
if st.session_state.input_hash_sel != current_input_hash:
|
| 269 |
# Inputs have changed, generate new analysis
|
| 270 |
st.session_state.input_hash_sel = current_input_hash
|
| 271 |
+
#prompt_template = prompts.prompt_template_resumes_
|
| 272 |
+
prompt_template = prompts.prompt_template_new
|
| 273 |
+
response = generate_individual_analysis(resume_text, job_pref, job_title_text, must_have, prompt_template)
|
| 274 |
+
#generate_sel_analysis(resume_text, job_pref, job_title_text, must_have, prompt_template)
|
| 275 |
print('response:',response)
|
| 276 |
+
#response_anal=max(response, key=lambda x: x['overall_match_score'])
|
| 277 |
+
## Prioritize by overall_match_score, then education_certifications_score, and finally skills_keywords_score
|
| 278 |
+
response_anal = max(
|
| 279 |
+
response,
|
| 280 |
+
key=lambda x: (
|
| 281 |
+
x.get('overall_match_score', 0),
|
| 282 |
+
x.get('education_certifications_score', 0), # Secondary criterion
|
| 283 |
+
x.get('skills_keywords_score', 0) # Tertiary criterion
|
| 284 |
+
)
|
| 285 |
+
)
|
| 286 |
+
# Cache the result
|
| 287 |
st.session_state.analysis_s = expand(response_anal)
|
| 288 |
st.session_state.analysis_mc_s = table_resp(response)
|
| 289 |
st.session_state.analysis_mc_s_exp = table_resp_exp(response)
|