Sa-m commited on
Commit
af55524
·
verified ·
1 Parent(s): 579e9d9

Update interview_logic.py

Browse files
Files changed (1) hide show
  1. interview_logic.py +95 -13
interview_logic.py CHANGED
@@ -469,17 +469,85 @@ def process_resume_logic(file_obj):
469
  }
470
  }
471
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
472
  def start_interview_logic(roles, processed_resume_data, text_model):
473
  """Starts the interview process logic."""
474
  if not roles or (isinstance(roles, list) and not any(roles)) or not processed_resume_data or not processed_resume_data.strip():
475
  return {
476
  "status": "Please select a role and ensure resume is processed.",
477
  "initial_question": "",
 
478
  "interview_state": {},
479
  "ui_updates": {
480
- "audio_input": "gr_show", # show recording for Q1
481
- "submit_answer_btn": "gr_show", # show submit for Q1
482
- "next_question_btn": "gr_hide", # hidden — must submit first
483
  "submit_interview_btn": "gr_hide",
484
  "feedback_display": "gr_hide",
485
  "metrics_display": "gr_hide",
@@ -500,7 +568,10 @@ def start_interview_logic(roles, processed_resume_data, text_model):
500
  questions.append(default_questions[len(questions)])
501
  questions = questions[:5] # cap at 5
502
 
 
 
503
  initial_question = questions[0]
 
504
  interview_state = {
505
  "questions": questions,
506
  "current_q_index": 0,
@@ -509,16 +580,22 @@ def start_interview_logic(roles, processed_resume_data, text_model):
509
  "interactions": {},
510
  "metrics_list": [],
511
  "resume_data": processed_resume_data,
512
- "selected_roles": roles # Store roles for history
513
  }
514
  return {
515
- "status": "Interview started. Please answer the first question.",
516
- "initial_question": initial_question,
 
517
  "interview_state": interview_state,
518
  "ui_updates": {
519
- "audio_input": "gr_show", "submit_answer_btn": "gr_show", "next_question_btn": "gr_hide",
520
- "submit_interview_btn": "gr_hide", "feedback_display": "gr_hide", "metrics_display": "gr_hide",
521
- "question_display": "gr_show", "answer_instructions": "gr_show"
 
 
 
 
 
522
  }
523
  }
524
  except Exception as e:
@@ -527,14 +604,19 @@ def start_interview_logic(roles, processed_resume_data, text_model):
527
  return {
528
  "status": error_msg,
529
  "initial_question": "",
 
530
  "interview_state": {},
531
  "ui_updates": {
532
- "audio_input": "gr_hide", "submit_answer_btn": "gr_hide", "next_question_btn": "gr_hide",
533
- "submit_interview_btn": "gr_hide", "feedback_display": "gr_hide", "metrics_display": "gr_hide",
534
- "question_display": "gr_hide", "answer_instructions": "gr_hide"
 
 
 
 
 
535
  }
536
  }
537
-
538
  def submit_answer_logic(audio, interview_state, text_model):
539
  """Handles submitting an answer via audio logic."""
540
  if not audio or not interview_state:
 
469
  }
470
  }
471
 
472
+ # def start_interview_logic(roles, processed_resume_data, text_model):
473
+ # """Starts the interview process logic."""
474
+ # if not roles or (isinstance(roles, list) and not any(roles)) or not processed_resume_data or not processed_resume_data.strip():
475
+ # return {
476
+ # "status": "Please select a role and ensure resume is processed.",
477
+ # "initial_question": "",
478
+ # "interview_state": {},
479
+ # "ui_updates": {
480
+ # "audio_input": "gr_show", # show recording for Q1
481
+ # "submit_answer_btn": "gr_show", # show submit for Q1
482
+ # "next_question_btn": "gr_hide", # hidden — must submit first
483
+ # "submit_interview_btn": "gr_hide",
484
+ # "feedback_display": "gr_hide",
485
+ # "metrics_display": "gr_hide",
486
+ # "question_display": "gr_show",
487
+ # "answer_instructions": "gr_show"
488
+ # }
489
+ # }
490
+ # try:
491
+ # questions = generate_questions(roles, processed_resume_data, text_model)
492
+ # default_questions = [
493
+ # "Could you please introduce yourself based on your resume?",
494
+ # "What are your key technical skills relevant to this role?",
495
+ # "Describe a challenging project you've worked on and how you handled it.",
496
+ # "Where do you see yourself in 5 years?",
497
+ # "Do you have any questions for us?"
498
+ # ]
499
+ # while len(questions) < 5:
500
+ # questions.append(default_questions[len(questions)])
501
+ # questions = questions[:5] # cap at 5
502
+
503
+ # initial_question = questions[0]
504
+ # interview_state = {
505
+ # "questions": questions,
506
+ # "current_q_index": 0,
507
+ # "answers": [],
508
+ # "feedback": [],
509
+ # "interactions": {},
510
+ # "metrics_list": [],
511
+ # "resume_data": processed_resume_data,
512
+ # "selected_roles": roles # Store roles for history
513
+ # }
514
+ # return {
515
+ # "status": "Interview started. Please answer the first question.",
516
+ # "initial_question": initial_question,
517
+ # "interview_state": interview_state,
518
+ # "ui_updates": {
519
+ # "audio_input": "gr_show", "submit_answer_btn": "gr_show", "next_question_btn": "gr_hide",
520
+ # "submit_interview_btn": "gr_hide", "feedback_display": "gr_hide", "metrics_display": "gr_hide",
521
+ # "question_display": "gr_show", "answer_instructions": "gr_show"
522
+ # }
523
+ # }
524
+ # except Exception as e:
525
+ # error_msg = f"Error starting interview in interview_logic: {str(e)}"
526
+ # print(error_msg)
527
+ # return {
528
+ # "status": error_msg,
529
+ # "initial_question": "",
530
+ # "interview_state": {},
531
+ # "ui_updates": {
532
+ # "audio_input": "gr_hide", "submit_answer_btn": "gr_hide", "next_question_btn": "gr_hide",
533
+ # "submit_interview_btn": "gr_hide", "feedback_display": "gr_hide", "metrics_display": "gr_hide",
534
+ # "question_display": "gr_hide", "answer_instructions": "gr_hide"
535
+ # }
536
+ # }
537
+
538
+
539
  def start_interview_logic(roles, processed_resume_data, text_model):
540
  """Starts the interview process logic."""
541
  if not roles or (isinstance(roles, list) and not any(roles)) or not processed_resume_data or not processed_resume_data.strip():
542
  return {
543
  "status": "Please select a role and ensure resume is processed.",
544
  "initial_question": "",
545
+ "all_questions": "", # New field for all questions
546
  "interview_state": {},
547
  "ui_updates": {
548
+ "audio_input": "gr_show",
549
+ "submit_answer_btn": "gr_show",
550
+ "next_question_btn": "gr_hide",
551
  "submit_interview_btn": "gr_hide",
552
  "feedback_display": "gr_hide",
553
  "metrics_display": "gr_hide",
 
568
  questions.append(default_questions[len(questions)])
569
  questions = questions[:5] # cap at 5
570
 
571
+ # Display all 5 questions at once
572
+ all_questions_text = "\n\n".join([f"**Question {i+1}:** {q}" for i, q in enumerate(questions)])
573
  initial_question = questions[0]
574
+
575
  interview_state = {
576
  "questions": questions,
577
  "current_q_index": 0,
 
580
  "interactions": {},
581
  "metrics_list": [],
582
  "resume_data": processed_resume_data,
583
+ "selected_roles": roles
584
  }
585
  return {
586
+ "status": "Interview started. All 5 questions are displayed below. Answer them one by one.",
587
+ "initial_question": all_questions_text, # Show all questions
588
+ "all_questions": all_questions_text,
589
  "interview_state": interview_state,
590
  "ui_updates": {
591
+ "audio_input": "gr_show",
592
+ "submit_answer_btn": "gr_show",
593
+ "next_question_btn": "gr_hide",
594
+ "submit_interview_btn": "gr_hide",
595
+ "feedback_display": "gr_hide",
596
+ "metrics_display": "gr_hide",
597
+ "question_display": "gr_show",
598
+ "answer_instructions": "gr_show"
599
  }
600
  }
601
  except Exception as e:
 
604
  return {
605
  "status": error_msg,
606
  "initial_question": "",
607
+ "all_questions": "",
608
  "interview_state": {},
609
  "ui_updates": {
610
+ "audio_input": "gr_hide",
611
+ "submit_answer_btn": "gr_hide",
612
+ "next_question_btn": "gr_hide",
613
+ "submit_interview_btn": "gr_hide",
614
+ "feedback_display": "gr_hide",
615
+ "metrics_display": "gr_hide",
616
+ "question_display": "gr_hide",
617
+ "answer_instructions": "gr_hide"
618
  }
619
  }
 
620
  def submit_answer_logic(audio, interview_state, text_model):
621
  """Handles submitting an answer via audio logic."""
622
  if not audio or not interview_state: