CR7CAD commited on
Commit
e361b26
·
verified ·
1 Parent(s): 7733908

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +71 -65
app.py CHANGED
@@ -409,68 +409,74 @@ def analyze_google_fit(resume_summary):
409
 
410
  # Create a more specific prompt for T5 that focuses on detailed assessment
411
  prompt = f"""
412
- Generate Google candidate assessment.
413
- Skills detected: {skills_text}.
414
- Experience: {experience_highlights}.
415
- Strongest area: {top_category} ({categories_sorted[0][1]["adjusted_score"]}%).
416
- Weakest area: {weak_category} ({categories_sorted[-1][1]["adjusted_score"]}%).
417
- Overall match: {match_percentage}%.
418
-
419
- Write a detailed 3-4 sentence assessment for this Google applicant.
420
- Start with "This candidate" and include:
421
- 1. Specific strengths relating to Google's needs
422
- 2. Technical skills evaluation
423
- 3. Areas for improvement
424
- 4. Overall Google fit assessment
425
-
426
- This candidate
427
- """
 
 
428
 
429
- try:
430
- # Generate the assessment using T5
431
- assessment_results = models['evaluator'](
432
- prompt,
433
- max_length=300,
434
- do_sample=True,
435
- temperature=0.7,
436
- num_return_sequences=3
437
- )
 
 
 
 
 
438
 
439
- # Find the best response
440
- best_assessment = None
441
- for result in assessment_results:
442
- text = result['generated_text'].strip()
443
-
444
- # Clean up and check if valid
445
- text = re.sub(r'Generate Google candidate assessment.*?Overall match:.*?%\.', '', text, flags=re.DOTALL)
446
- text = re.sub(r'Write a detailed.*?This candidate', 'This candidate', text, flags=re.DOTALL)
447
-
448
- # Check if it's a good response
449
- if text.lower().startswith("this candidate") and len(text) > 100 and "1." not in text and "2." not in text:
450
- best_assessment = text
451
- break
452
 
453
- # Use the best response or the first one if none were ideal
454
- if best_assessment:
455
- assessment = best_assessment
456
- else:
457
- # Use first response but clean it up
458
- text = assessment_results[0]['generated_text']
459
- text = re.sub(r'Generate Google candidate assessment.*?Overall match:.*?%\.', '', text, flags=re.DOTALL)
460
- text = re.sub(r'Write a detailed.*?This candidate', 'This candidate', text, flags=re.DOTALL)
461
-
462
- # Remove numbering if present
463
- text = re.sub(r'\d\.\s', '', text)
464
-
465
- if not text.lower().startswith("this candidate"):
466
- text = "This candidate " + text
467
-
468
- assessment = text
 
 
 
 
 
 
 
469
 
470
- except Exception as e:
471
- # Fall back to manual assessment
472
- print(f"Error in T5 assessment generation: {e}")
473
- assessment = f"""This candidate demonstrates some skills relevant to Google, particularly in {top_category}. Their experience with {skills_text} could be valuable, though they would benefit from strengthening their {weak_category}. Based on the resume analysis, they appear to be a {match_percentage}% match for Google's requirements."""
 
 
474
 
475
  # Final cleanup
476
  # Remove any remaining artifacts or formatting
@@ -669,10 +675,10 @@ if uploaded_file is not None and st.button("Analyze My Google Fit"):
669
  breakdown_data = []
670
  for category, details in category_details.items():
671
  label = {"technical_skills": "Technical Programming Skills",
672
- "advanced_tech": "Advanced Technology Knowledge",
673
- "problem_solving": "Problem Solving Abilities",
674
- "innovation": "Innovation Mindset",
675
- "soft_skills": "Collaboration & Leadership"}[category]
676
 
677
  # Create a visual indicator for the score
678
  score = details["adjusted_score"]
@@ -682,12 +688,12 @@ if uploaded_file is not None and st.button("Analyze My Google Fit"):
682
  "Category": label,
683
  "Score": f"{score}%",
684
  "Matching Skills": ", ".join(details["matching_keywords"][:3]) if details["matching_keywords"] else "None detected"
685
- })
686
 
687
  # Convert to DataFrame and display
688
- import pandas as pd
689
  breakdown_df = pd.DataFrame(breakdown_data)
690
- st.table(breakdown_df)
 
691
 
692
  # Show a note about how scores are calculated
693
  with st.expander("How are these scores calculated?"):
 
409
 
410
  # Create a more specific prompt for T5 that focuses on detailed assessment
411
  prompt = f"""
412
+ Generate a professional expert assessment for a Google job candidate.
413
+ Skills detected: {skills_text}.
414
+ Strongest area: {top_category} ({categories_sorted[0][1]["adjusted_score"]}%).
415
+ Weakest area: {weak_category} ({categories_sorted[-1][1]["adjusted_score"]}%).
416
+ Overall match: {match_percentage}%.
417
+
418
+ Write an evaluative assessment that analyzes the candidate's fit for Google.
419
+ Start with "This candidate" and:
420
+ - Evaluate their technical skills in relation to Google's standards
421
+ - Assess their strengths and potential contributions
422
+ - Provide specific areas where improvement is needed
423
+ - Give an overall evaluation of their Google fit
424
+
425
+ Your assessment should be an expert evaluation, not a summary of their resume.
426
+ Include specific actionable advice for improvement.
427
+
428
+ This candidate
429
+ """
430
 
431
+ try:
432
+ # Generate the assessment using T5
433
+ assessment_results = models['evaluator'](
434
+ prompt,
435
+ max_length=300,
436
+ do_sample=True,
437
+ temperature=0.75, # Slightly higher temperature for more evaluative content
438
+ num_return_sequences=3
439
+ )
440
+
441
+ # Find the best response
442
+ best_assessment = None
443
+ for result in assessment_results:
444
+ text = result['generated_text'].strip()
445
 
446
+ # Clean up and check if valid
447
+ text = re.sub(r'Generate a professional expert assessment.*?Overall match:.*?%\.', '', text, flags=re.DOTALL)
448
+ text = re.sub(r'Write an evaluative assessment.*?This candidate', 'This candidate', text, flags=re.DOTALL)
 
 
 
 
 
 
 
 
 
 
449
 
450
+ # Check if it's a good response - looking for evaluative language
451
+ if (text.lower().startswith("this candidate") and
452
+ len(text) > 100 and
453
+ ("would" in text.lower() or "could" in text.lower() or "should" in text.lower() or
454
+ "needs" in text.lower() or "requires" in text.lower() or "lacks" in text.lower())):
455
+ best_assessment = text
456
+ break
457
+
458
+ # Use the best response or the first one if none were ideal
459
+ if best_assessment:
460
+ assessment = best_assessment
461
+ else:
462
+ # Use first response but clean it up
463
+ text = assessment_results[0]['generated_text']
464
+ text = re.sub(r'Generate a professional expert assessment.*?Overall match:.*?%\.', '', text, flags=re.DOTALL)
465
+ text = re.sub(r'Write an evaluative assessment.*?This candidate', 'This candidate', text, flags=re.DOTALL)
466
+
467
+ # Remove numbering or bullets if present
468
+ text = re.sub(r'[-•]\s', '', text)
469
+ text = re.sub(r'\d\.\s', '', text)
470
+
471
+ if not text.lower().startswith("this candidate"):
472
+ text = "This candidate " + text
473
 
474
+ assessment = text
475
+
476
+ except Exception as e:
477
+ # Fall back to manual assessment - making this more evaluative
478
+ print(f"Error in T5 assessment generation: {e}")
479
+ assessment = f"""This candidate shows promise in {top_category} but would need significant development in {weak_category} to meet Google's standards. Their technical skills in {skills_text} align with Google's engineering needs, but they would benefit from developing stronger problem-solving capabilities and a more innovative approach to complex challenges. At {match_percentage}%, they could become a more competitive candidate with targeted improvement in these areas."""
480
 
481
  # Final cleanup
482
  # Remove any remaining artifacts or formatting
 
675
  breakdown_data = []
676
  for category, details in category_details.items():
677
  label = {"technical_skills": "Technical Programming Skills",
678
+ "advanced_tech": "Advanced Technology Knowledge",
679
+ "problem_solving": "Problem Solving Abilities",
680
+ "innovation": "Innovation Mindset",
681
+ "soft_skills": "Collaboration & Leadership"}[category]
682
 
683
  # Create a visual indicator for the score
684
  score = details["adjusted_score"]
 
688
  "Category": label,
689
  "Score": f"{score}%",
690
  "Matching Skills": ", ".join(details["matching_keywords"][:3]) if details["matching_keywords"] else "None detected"
691
+ })
692
 
693
  # Convert to DataFrame and display
 
694
  breakdown_df = pd.DataFrame(breakdown_data)
695
+ # Remove the index column entirely
696
+ st.table(breakdown_df.set_index('Category').reset_index()) # This removes the numerical index
697
 
698
  # Show a note about how scores are calculated
699
  with st.expander("How are these scores calculated?"):