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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -42
app.py CHANGED
@@ -428,55 +428,55 @@ def analyze_google_fit(resume_summary):
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
 
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