CR7CAD commited on
Commit
17a94ec
·
verified ·
1 Parent(s): 7e915ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -575,13 +575,34 @@ def summarize_resume_text(resume_text, models):
575
  job_position = extract_job_position(resume_text)
576
  skills = extract_skills(resume_text)
577
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
578
  # Format the structured summary with different paragraphs for each critical piece
579
  formatted_summary = f"Name: {name}\n\n"
580
  formatted_summary += f"Age: {age}\n\n"
581
  formatted_summary += f"Expected Industry: {industry}\n\n"
582
  formatted_summary += f"Expected Job Position: {job_position}\n\n"
583
  formatted_summary += f"Skills: {', '.join(skills)}\n\n"
584
-
 
585
  execution_time = time.time() - start_time
586
 
587
  return formatted_summary, execution_time
 
575
  job_position = extract_job_position(resume_text)
576
  skills = extract_skills(resume_text)
577
 
578
+ # Generate overall summary using the pipeline model if available
579
+ try:
580
+ if has_pipeline and 'summarizer' in models:
581
+ # Truncate text to avoid issues with very long resumes
582
+ truncated_text = resume_text[:2000] # Limit input to 2000 chars
583
+
584
+ # Use pipeline model to generate the summary
585
+ model_summary = models['summarizer'](
586
+ truncated_text,
587
+ max_length=100,
588
+ min_length=30,
589
+ do_sample=False
590
+ )[0]['summary_text']
591
+ else:
592
+ # Fallback if pipeline is not available
593
+ model_summary = summarize_text(resume_text, models, max_length=100)
594
+ except Exception as e:
595
+ st.warning(f"Error in resume summarization: {e}")
596
+ model_summary = "Error generating summary. Please check the original resume."
597
+
598
  # Format the structured summary with different paragraphs for each critical piece
599
  formatted_summary = f"Name: {name}\n\n"
600
  formatted_summary += f"Age: {age}\n\n"
601
  formatted_summary += f"Expected Industry: {industry}\n\n"
602
  formatted_summary += f"Expected Job Position: {job_position}\n\n"
603
  formatted_summary += f"Skills: {', '.join(skills)}\n\n"
604
+ formatted_summary += f"Summary: {model_summary}"
605
+
606
  execution_time = time.time() - start_time
607
 
608
  return formatted_summary, execution_time