ShubhamD95 commited on
Commit
c6a3b1d
Β·
verified Β·
1 Parent(s): fc823d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -39,8 +39,8 @@ Resume:
39
 
40
  Only list the missing keywords as bullet points.
41
  """
42
- result = summarizer(prompt, max_new_tokens=300, do_sample=True)[0]['generated_text']
43
- return result.strip()
44
 
45
  # πŸ” Prompt for dynamic section classification and feedback
46
  def build_dynamic_prompt(job_desc, resume_text, analyze_with_jd):
@@ -67,13 +67,14 @@ def analyze_resume(job_desc, resume_text, analyze_with_jd):
67
  user_prompt = build_dynamic_prompt(job_desc, resume_text, analyze_with_jd)
68
 
69
  try:
70
- response = summarizer(user_prompt, max_new_tokens=512, do_sample=True)[0]['generated_text']
 
71
  if analyze_with_jd and job_desc:
72
  matched, _ = compare_keywords(resume_text, job_desc)
73
  highlighted_resume = highlight_keywords(resume_text, matched)
74
  llm_missing_keywords = extract_missing_keywords_with_llm(job_desc, resume_text)
75
- return f"### πŸ” Resume with Highlighted Matches\n\n{highlighted_resume}\n\n---\n**βœ… Matched Keywords:** {', '.join(sorted(matched)) or 'None'}\n\n**❌ LLM-Inferred Missing Keywords:**\n{llm_missing_keywords}\n\n---\n{response.strip()}"
76
- return response.strip()
77
  except Exception as e:
78
  return f"❌ Error: {str(e)}"
79
 
@@ -85,13 +86,13 @@ def create_ui():
85
  analyze_checkbox = gr.Checkbox(label="Analyze with Job Description", value=True)
86
  job_desc = gr.Textbox(label="Job Description", lines=6, placeholder="Paste job description here...")
87
  resume_text = gr.Textbox(label="Resume Text", lines=16, placeholder="Paste resume content here...")
 
88
  with gr.Column():
89
  output_analysis = gr.Markdown(label="Resume Analysis and Suggestions")
90
 
91
- resume_text.change(fn=analyze_resume, inputs=[job_desc, resume_text, analyze_checkbox], outputs=output_analysis)
92
- job_desc.change(fn=analyze_resume, inputs=[job_desc, resume_text, analyze_checkbox], outputs=output_analysis)
93
 
94
  return demo
95
 
96
  if __name__ == '__main__':
97
- create_ui().launch()
 
39
 
40
  Only list the missing keywords as bullet points.
41
  """
42
+ result = summarizer(prompt, max_new_tokens=300, do_sample=True, return_full_text=False)[0]
43
+ return result.get('generated_text', result.get('summary_text', str(result))).strip()
44
 
45
  # πŸ” Prompt for dynamic section classification and feedback
46
  def build_dynamic_prompt(job_desc, resume_text, analyze_with_jd):
 
67
  user_prompt = build_dynamic_prompt(job_desc, resume_text, analyze_with_jd)
68
 
69
  try:
70
+ result = summarizer(user_prompt, max_new_tokens=512, do_sample=True, return_full_text=False)[0]
71
+ response_text = result.get('generated_text', result.get('summary_text', str(result))).strip()
72
  if analyze_with_jd and job_desc:
73
  matched, _ = compare_keywords(resume_text, job_desc)
74
  highlighted_resume = highlight_keywords(resume_text, matched)
75
  llm_missing_keywords = extract_missing_keywords_with_llm(job_desc, resume_text)
76
+ return f"### πŸ” Resume with Highlighted Matches\n\n{highlighted_resume}\n\n---\n**βœ… Matched Keywords:** {', '.join(sorted(matched)) or 'None'}\n\n**❌ LLM-Inferred Missing Keywords:**\n{llm_missing_keywords}\n\n---\n{response_text}"
77
+ return response_text
78
  except Exception as e:
79
  return f"❌ Error: {str(e)}"
80
 
 
86
  analyze_checkbox = gr.Checkbox(label="Analyze with Job Description", value=True)
87
  job_desc = gr.Textbox(label="Job Description", lines=6, placeholder="Paste job description here...")
88
  resume_text = gr.Textbox(label="Resume Text", lines=16, placeholder="Paste resume content here...")
89
+ submit_btn = gr.Button("Analyze Resume")
90
  with gr.Column():
91
  output_analysis = gr.Markdown(label="Resume Analysis and Suggestions")
92
 
93
+ submit_btn.click(fn=analyze_resume, inputs=[job_desc, resume_text, analyze_checkbox], outputs=output_analysis)
 
94
 
95
  return demo
96
 
97
  if __name__ == '__main__':
98
+ create_ui().launch()