Update interview_logic.py
Browse files- interview_logic.py +38 -13
interview_logic.py
CHANGED
|
@@ -433,14 +433,30 @@ def start_interview_logic(roles, processed_resume_data, text_model):
|
|
| 433 |
"initial_question": "",
|
| 434 |
"interview_state": {},
|
| 435 |
"ui_updates": {
|
| 436 |
-
"audio_input": "
|
| 437 |
-
"
|
| 438 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
}
|
| 440 |
}
|
| 441 |
try:
|
| 442 |
questions = generate_questions(roles, processed_resume_data, text_model)
|
| 443 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 444 |
interview_state = {
|
| 445 |
"questions": questions,
|
| 446 |
"current_q_index": 0,
|
|
@@ -518,19 +534,22 @@ def submit_answer_logic(audio, interview_state, text_model):
|
|
| 518 |
interview_state["current_q_index"] += 1
|
| 519 |
total_questions = len(interview_state["questions"])
|
| 520 |
is_last_question = interview_state["current_q_index"] >= total_questions
|
|
|
|
| 521 |
return {
|
| 522 |
-
"status": f"Answer submitted! {'
|
| 523 |
"answer_text": answer_text,
|
| 524 |
"interview_state": interview_state,
|
| 525 |
"feedback_text": feedback_text,
|
| 526 |
"metrics": metrics,
|
| 527 |
"ui_updates": {
|
| 528 |
-
"feedback_display": "gr_show_and_update",
|
| 529 |
-
"
|
| 530 |
-
"
|
|
|
|
| 531 |
"next_question_btn": "gr_hide" if is_last_question else "gr_show",
|
| 532 |
"submit_interview_btn": "gr_show" if is_last_question else "gr_hide",
|
| 533 |
-
"question_display": "gr_show",
|
|
|
|
| 534 |
}
|
| 535 |
}
|
| 536 |
except Exception as e:
|
|
@@ -571,10 +590,16 @@ def next_question_logic(interview_state):
|
|
| 571 |
"next_q": next_q,
|
| 572 |
"interview_state": interview_state,
|
| 573 |
"ui_updates": {
|
| 574 |
-
"audio_input": "gr_show",
|
| 575 |
-
"
|
| 576 |
-
"
|
| 577 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 578 |
}
|
| 579 |
}
|
| 580 |
else:
|
|
|
|
| 433 |
"initial_question": "",
|
| 434 |
"interview_state": {},
|
| 435 |
"ui_updates": {
|
| 436 |
+
"audio_input": "gr_show", # show recording for Q1
|
| 437 |
+
"submit_answer_btn": "gr_show", # show submit for Q1
|
| 438 |
+
"next_question_btn": "gr_hide", # hidden — must submit first
|
| 439 |
+
"submit_interview_btn": "gr_hide",
|
| 440 |
+
"feedback_display": "gr_hide",
|
| 441 |
+
"metrics_display": "gr_hide",
|
| 442 |
+
"question_display": "gr_show",
|
| 443 |
+
"answer_instructions": "gr_show"
|
| 444 |
}
|
| 445 |
}
|
| 446 |
try:
|
| 447 |
questions = generate_questions(roles, processed_resume_data, text_model)
|
| 448 |
+
default_questions = [
|
| 449 |
+
"Could you please introduce yourself based on your resume?",
|
| 450 |
+
"What are your key technical skills relevant to this role?",
|
| 451 |
+
"Describe a challenging project you've worked on and how you handled it.",
|
| 452 |
+
"Where do you see yourself in 5 years?",
|
| 453 |
+
"Do you have any questions for us?"
|
| 454 |
+
]
|
| 455 |
+
while len(questions) < 5:
|
| 456 |
+
questions.append(default_questions[len(questions)])
|
| 457 |
+
questions = questions[:5] # cap at 5
|
| 458 |
+
|
| 459 |
+
initial_question = questions[0]
|
| 460 |
interview_state = {
|
| 461 |
"questions": questions,
|
| 462 |
"current_q_index": 0,
|
|
|
|
| 534 |
interview_state["current_q_index"] += 1
|
| 535 |
total_questions = len(interview_state["questions"])
|
| 536 |
is_last_question = interview_state["current_q_index"] >= total_questions
|
| 537 |
+
|
| 538 |
return {
|
| 539 |
+
"status": f"Answer submitted! {'All questions answered — click Submit Interview.' if is_last_question else 'Click Next Question to continue.'}",
|
| 540 |
"answer_text": answer_text,
|
| 541 |
"interview_state": interview_state,
|
| 542 |
"feedback_text": feedback_text,
|
| 543 |
"metrics": metrics,
|
| 544 |
"ui_updates": {
|
| 545 |
+
"feedback_display": "gr_show_and_update",
|
| 546 |
+
"metrics_display": "gr_show_and_update",
|
| 547 |
+
"audio_input": "gr_hide", # hide until Next is clicked
|
| 548 |
+
"submit_answer_btn": "gr_hide", # hide until Next is clicked
|
| 549 |
"next_question_btn": "gr_hide" if is_last_question else "gr_show",
|
| 550 |
"submit_interview_btn": "gr_show" if is_last_question else "gr_hide",
|
| 551 |
+
"question_display": "gr_show",
|
| 552 |
+
"answer_instructions": "gr_show"
|
| 553 |
}
|
| 554 |
}
|
| 555 |
except Exception as e:
|
|
|
|
| 590 |
"next_q": next_q,
|
| 591 |
"interview_state": interview_state,
|
| 592 |
"ui_updates": {
|
| 593 |
+
"audio_input": "gr_show",
|
| 594 |
+
"submit_answer_btn": "gr_show",
|
| 595 |
+
"next_question_btn": "gr_hide",
|
| 596 |
+
"feedback_display": "gr_hide",
|
| 597 |
+
"metrics_display": "gr_hide",
|
| 598 |
+
"submit_interview_btn": "gr_hide",
|
| 599 |
+
"question_display": "gr_show",
|
| 600 |
+
"answer_instructions": "gr_show",
|
| 601 |
+
"answer_display": "gr_clear",
|
| 602 |
+
"metrics_display_clear": "gr_clear"
|
| 603 |
}
|
| 604 |
}
|
| 605 |
else:
|