Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
413 |
-
Skills detected: {skills_text}.
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
|
|
|
|
428 |
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
|
|
|
|
|
|
|
|
|
|
438 |
|
439 |
-
|
440 |
-
|
441 |
-
|
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 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
text =
|
467 |
-
|
468 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
469 |
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
|
|
|
|
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 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
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 |
-
|
|
|
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?"):
|