Spaces:
Sleeping
Sleeping
Update process_interview.py
Browse files- process_interview.py +73 -34
process_interview.py
CHANGED
|
@@ -597,7 +597,15 @@ def generate_report(analysis_data: Dict) -> str:
|
|
| 597 |
try:
|
| 598 |
voice = analysis_data.get('voice_analysis', {})
|
| 599 |
voice_interpretation = generate_voice_interpretation(voice)
|
| 600 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 601 |
acceptance_prob = analysis_data.get('acceptance_probability', 50.0)
|
| 602 |
acceptance_line = f"\n**Suitability Score: {acceptance_prob:.2f}%**\n"
|
| 603 |
if acceptance_prob >= 80:
|
|
@@ -608,40 +616,71 @@ def generate_report(analysis_data: Dict) -> str:
|
|
| 608 |
acceptance_line += "HR Verdict: Moderate potential, needs additional assessment."
|
| 609 |
else:
|
| 610 |
acceptance_line += "HR Verdict: Limited fit, significant improvement required."
|
| 611 |
-
|
| 612 |
-
# Robust prompt to ensure complete, specific content
|
| 613 |
prompt = f"""
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 645 |
response = gemini_model.generate_content(prompt)
|
| 646 |
clean_text = re.sub(r'[^\x20-\x7E\n]+', '', response.text)
|
| 647 |
return clean_text
|
|
|
|
| 597 |
try:
|
| 598 |
voice = analysis_data.get('voice_analysis', {})
|
| 599 |
voice_interpretation = generate_voice_interpretation(voice)
|
| 600 |
+
|
| 601 |
+
interviewee_responses = [
|
| 602 |
+
f"- {u['text']}"
|
| 603 |
+
for u in analysis_data['transcript']
|
| 604 |
+
if u.get('role') == 'Interviewee'
|
| 605 |
+
] or ["- No interviewee responses available."]
|
| 606 |
+
|
| 607 |
+
full_responses_text = "\n".join([u['text'] for u in analysis_data['transcript'] if u.get('role') == 'Interviewee'])
|
| 608 |
+
|
| 609 |
acceptance_prob = analysis_data.get('acceptance_probability', 50.0)
|
| 610 |
acceptance_line = f"\n**Suitability Score: {acceptance_prob:.2f}%**\n"
|
| 611 |
if acceptance_prob >= 80:
|
|
|
|
| 616 |
acceptance_line += "HR Verdict: Moderate potential, needs additional assessment."
|
| 617 |
else:
|
| 618 |
acceptance_line += "HR Verdict: Limited fit, significant improvement required."
|
| 619 |
+
|
|
|
|
| 620 |
prompt = f"""
|
| 621 |
+
You are EvalBot, a highly experienced senior HR analyst generating a comprehensive interview evaluation report based on both objective metrics and full interviewee responses.
|
| 622 |
+
|
| 623 |
+
Your task:
|
| 624 |
+
|
| 625 |
+
- Analyze deeply based on actual responses provided below. Avoid generic analysis.
|
| 626 |
+
- Use only insights that can be inferred from the answers or provided metrics.
|
| 627 |
+
- Maintain professional, HR-standard language with clear structure and bullet points.
|
| 628 |
+
- Avoid redundancy or overly generic feedback.
|
| 629 |
+
- The responses are real interviewee answers, treat them as high-priority source.
|
| 630 |
+
|
| 631 |
+
{acceptance_line}
|
| 632 |
+
|
| 633 |
+
### Interviewee Full Responses:
|
| 634 |
+
{full_responses_text}
|
| 635 |
+
|
| 636 |
+
### Metrics Summary:
|
| 637 |
+
- Duration: {analysis_data['text_analysis']['total_duration']:.2f} seconds
|
| 638 |
+
- Speaker Turns: {analysis_data['text_analysis']['speaker_turns']}
|
| 639 |
+
- Speaking Rate: {voice.get('speaking_rate', 'N/A')} words/sec
|
| 640 |
+
- Filler Words: {voice.get('filler_ratio', 0) * 100:.1f}%
|
| 641 |
+
- Confidence Level: {voice.get('interpretation', {}).get('confidence_level', 'N/A')}
|
| 642 |
+
- Anxiety Level: {voice.get('interpretation', {}).get('anxiety_level', 'N/A')}
|
| 643 |
+
- Fluency Level: {voice.get('interpretation', {}).get('fluency_level', 'N/A')}
|
| 644 |
+
- Voice Interpretation Summary: {voice_interpretation}
|
| 645 |
+
|
| 646 |
+
### Report Sections to Generate:
|
| 647 |
+
|
| 648 |
+
**1. Executive Summary**
|
| 649 |
+
- 3 bullets summarizing performance, key strengths, and hiring recommendation.
|
| 650 |
+
- Mention relevant metrics when applicable.
|
| 651 |
+
|
| 652 |
+
**2. Communication and Vocal Dynamics**
|
| 653 |
+
- Analyze delivery: speaking rate, filler words, confidence, anxiety, fluency.
|
| 654 |
+
- Provide 3-4 insightful bullets.
|
| 655 |
+
- Give 1 actionable improvement recommendation for workplace communication.
|
| 656 |
+
|
| 657 |
+
**3. Competency and Content**
|
| 658 |
+
- Identify 5-8 strengths (use HR competencies: leadership, teamwork, problem-solving, etc.).
|
| 659 |
+
- For each: provide short explanation + concrete example inferred from responses.
|
| 660 |
+
- Identify 5-10 weaknesses or development areas.
|
| 661 |
+
- For each weakness: provide actionable, practical feedback.
|
| 662 |
+
|
| 663 |
+
**4. Role Fit and Potential**
|
| 664 |
+
- Analyze role fit, cultural fit, growth potential in 3 bullets.
|
| 665 |
+
- Use examples from responses whenever possible.
|
| 666 |
+
|
| 667 |
+
**5. Recommendations**
|
| 668 |
+
- Provide 5 actionable recommendations categorized into:
|
| 669 |
+
- Communication Skills
|
| 670 |
+
- Content Delivery
|
| 671 |
+
- Professional Presentation
|
| 672 |
+
- Each recommendation should include a short improvement strategy/example.
|
| 673 |
+
|
| 674 |
+
**Next Steps for Hiring Managers**
|
| 675 |
+
- Provide 5 clear next steps: next round, training, assessment, mentorship, role fit review.
|
| 676 |
+
|
| 677 |
+
Ensure each section is clearly titled exactly as requested above.
|
| 678 |
+
Avoid repetition between sections.
|
| 679 |
+
Use professional HR tone.
|
| 680 |
+
|
| 681 |
+
Begin the full analysis now.
|
| 682 |
+
"""
|
| 683 |
+
|
| 684 |
response = gemini_model.generate_content(prompt)
|
| 685 |
clean_text = re.sub(r'[^\x20-\x7E\n]+', '', response.text)
|
| 686 |
return clean_text
|