norhan12 commited on
Commit
63f7d5b
·
verified ·
1 Parent(s): 545eb49

Update process_interview.py

Browse files
Files changed (1) hide show
  1. 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
- interviewee_responses = [f"- {u['text']}" for u in analysis_data['transcript'] if u.get('role') == 'Interviewee'][:5] or ["- No interviewee responses available."]
 
 
 
 
 
 
 
 
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
- You are EvalBot, a senior HR consultant delivering a comprehensive, professional interview analysis report.
615
- Use clear section headings and bullet points, and concise, HR-focused language.
616
- Ensure text is clean, professional, and free of special characters that could break formatting.
617
- The interview involves two roles: Interviewer and Interviewee, assigned alternately to utterances.
618
- If data is sparse, infer meaningful insights from metrics or responses.
619
- {acceptance_line}
620
- **1. Executive Summary**
621
- - Provide 3 bullets summarizing the candidate's performance, strengths, and hiring potential.
622
- - Include metrics: Duration ({analysis_data['text_analysis']['total_duration']:.2f} seconds), Speaker Turns ({analysis_data['text_analysis']['speaker_turns']}).
623
- - Mention roles: Interviewer and Interviewee.
624
- - **Example**: Strong leadership shown in project coordination; confidence score {voice.get('composite_scores', {}).get('confidence', 'N/A')}; ideal for team-oriented roles.
625
- **2. Communication and Vocal Dynamics**
626
- - Evaluate vocal delivery (speaking rate: {voice.get('speaking_rate', 'N/A')} words/sec, filler words: {voice.get('filler_ratio', 0) * 100:.1f}%, confidence: {voice.get('interpretation', {}).get('confidence_level', 'N/A')}, anxiety: {voice.get('interpretation', {}).get('anxiety_level', 'N/A')}, fluency: {voice.get('interpretation', {}).get('fluency_level', 'N/A')}) in 3-4 bullets.
627
- - Provide one actionable HR insight for workplace communication alignment.
628
- - Voice Analysis: {voice_interpretation}
629
- **3. Competency and Content**
630
- - List 3-5 strengths (e.g., leadership, problem-solving, teamwork) with specific examples from responses or inferred from transcript.
631
- - List 2-3 weaknesses (growth areas) with actionable feedback.
632
- - Sample responses:
633
- {chr(10).join(interviewee_responses)}
634
- **4. Role Fit and Potential**
635
- - Analyze cultural fit, role readiness, and growth potential in 3 bullets, inferred from strengths or metrics if needed.
636
- - **Example**: Team collaboration skills align with dynamic cultures; high confidence suggests leadership potential.
637
- **5. Recommendations**
638
- - Provide 4 specific recommendations for:
639
- - Communication skills (e.g., clarity, reducing filler words).
640
- - Content delivery (e.g., structured responses, key points).
641
- - Professional presentation (e.g., confidence, tone).
642
- - Include a strategy/example for each.
643
- - Suggest 3 next steps for hiring managers (e.g., advance, train, assess).
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