Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -59,7 +59,7 @@ def extract_pdf_text(uploaded_file):
|
|
| 59 |
return "".join(page.extract_text() or "" for page in pdf_reader.pages).strip()
|
| 60 |
|
| 61 |
def get_questions(prompt, input_text, num_questions=3, max_retries=10):
|
| 62 |
-
model = genai.GenerativeModel('gemini-2.
|
| 63 |
|
| 64 |
if "previous_questions" not in st.session_state:
|
| 65 |
st.session_state["previous_questions"] = set()
|
|
@@ -148,7 +148,7 @@ for param in HR_PARAMETERS_CONFIG:
|
|
| 148 |
# SUmmary of improvement(function)
|
| 149 |
|
| 150 |
def generate_improvement_suggestions():
|
| 151 |
-
model = genai.GenerativeModel('gemini-2.
|
| 152 |
difficulty_level = st.session_state.get("difficulty_level_select", "Beginner")
|
| 153 |
level_string = difficulty_level.lower()
|
| 154 |
|
|
@@ -184,24 +184,17 @@ def generate_improvement_suggestions():
|
|
| 184 |
---
|
| 185 |
{cleaned_initial_evaluation}
|
| 186 |
---
|
| 187 |
-
|
| 188 |
Based on all this information, your task is to provide DETAILED and CONSTRUCTIVE suggestions for each question to help the candidate improve. Be supportive and encouraging.
|
| 189 |
-
|
| 190 |
For EACH question, please provide:
|
| 191 |
1. **How to Improve This Answer:** Specific, actionable advice on what the candidate could have added, clarified, or approached differently to make their answer better for their {level_string} level. Focus on 1-2 key improvement points.
|
| 192 |
2. **Hints for an Ideal Answer:** Briefly mention 2-3 key concepts, terms, or elements that a strong answer (appropriate for their {level_string} level) would typically include. DO NOT provide a full model answer, just hints and pointers.
|
| 193 |
-
|
| 194 |
Keep the tone positive and focused on learning.
|
| 195 |
-
|
| 196 |
Structure your response clearly for each question. Example for one question:
|
| 197 |
-
|
| 198 |
---
|
| 199 |
**Regarding Question X: "[Original Question Text Here]"**
|
| 200 |
-
|
| 201 |
*How to Improve This Answer:*
|
| 202 |
[Your specific suggestion 1 for improvement...]
|
| 203 |
[Your specific suggestion 2 for improvement...]
|
| 204 |
-
|
| 205 |
*Hints for an Ideal Answer (Key Points to Consider):*
|
| 206 |
- Hint 1 or Key concept 1
|
| 207 |
- Hint 2 or Key concept 2
|
|
@@ -234,7 +227,7 @@ def generate_improvement_suggestions():
|
|
| 234 |
|
| 235 |
|
| 236 |
def evaluate_answers():
|
| 237 |
-
model = genai.GenerativeModel('gemini-2.
|
| 238 |
# difficulty_level_select is the key for the difficulty selectbox in your sidebar
|
| 239 |
difficulty_level = st.session_state.get("difficulty_level_select", "Beginner")
|
| 240 |
level_string = difficulty_level.lower()
|
|
@@ -291,15 +284,11 @@ def evaluate_answers():
|
|
| 291 |
hr_prompt_template = f"""
|
| 292 |
You are an experienced HR interview evaluator assessing a candidate's soft skills based on their answers to interview questions.
|
| 293 |
The candidate's performance across ALL answers should inform your scores for the following parameters.
|
| 294 |
-
|
| 295 |
**Parameters to Score (Assign a score from 1 to 5 for each):**
|
| 296 |
{hr_prompt_parameter_list}
|
| 297 |
-
|
| 298 |
After providing a score (1-5) for each of the above parameters, also write an **Overall Qualitative Feedback** section.
|
| 299 |
This section should summarize the candidate's general soft skill strengths and areas for improvement, based on their communication, engagement, and professionalism throughout the interview.
|
| 300 |
-
|
| 301 |
**REQUIRED OUTPUT FORMAT (Strictly Adhere):**
|
| 302 |
-
|
| 303 |
**Parameter Scores (1-5):**
|
| 304 |
Voice Modulation: [score]
|
| 305 |
Confidence: [score]
|
|
@@ -310,7 +299,6 @@ def evaluate_answers():
|
|
| 310 |
Basics of Grammar + SVA: [score]
|
| 311 |
Persuasiveness: [score]
|
| 312 |
Quality of Answers: [score]
|
| 313 |
-
|
| 314 |
**Overall Qualitative Feedback:**
|
| 315 |
[Your holistic qualitative feedback here. Be encouraging and constructive.]
|
| 316 |
"""
|
|
@@ -428,11 +416,9 @@ def evaluate_answers():
|
|
| 428 |
{base_assessment_criteria_qualitative_non_hr}
|
| 429 |
**YOUR RESPONSE MUST STRICTLY FOLLOW THIS FORMAT. PROVIDE SCORES FOR EACH QUESTION.**
|
| 430 |
Output format:
|
| 431 |
-
|
| 432 |
**Per-Question Scores:**
|
| 433 |
Question 1 Score: [Score for Q1 out of 5]
|
| 434 |
... (repeat for all {num_answered_questions} questions provided)
|
| 435 |
-
|
| 436 |
**Overall Evaluation Summary:**
|
| 437 |
- Concept Understanding: [Overall qualitative feedback here]
|
| 438 |
- Communication: [Overall qualitative feedback here]
|
|
@@ -512,7 +498,6 @@ def evaluate_answers():
|
|
| 512 |
BEGINNER_PROMPT = """
|
| 513 |
You are a friendly mock interview trainer conducting a **Beginner-level** spoken interview in the domain of **{domain}**.
|
| 514 |
Ask basic verbal interview questions based on the candidate's input: **{input_text}**.
|
| 515 |
-
|
| 516 |
Guidelines:
|
| 517 |
- Ask simple conceptual questions.
|
| 518 |
- Avoid jargon and complex examples.
|
|
@@ -521,7 +506,6 @@ Guidelines:
|
|
| 521 |
Ensure the questions are clear, to the point, and suitable for a {difficulty_level}-level interview in {selected_domain}.
|
| 522 |
**New Requirement:**
|
| 523 |
π« **Do NOT repeat any questions from previous generations again and again.** Ensure all generated questions are unique and different from past sessions.
|
| 524 |
-
|
| 525 |
**Guidelines:**
|
| 526 |
β
Questions should focus on key concepts, best practices, and problem-solving within {selected_domain}.
|
| 527 |
β
Ensure questions are direct, structured, and relevant to real-world applications.
|
|
@@ -532,7 +516,6 @@ Ensure the questions are clear, to the point, and suitable for a {difficulty_lev
|
|
| 532 |
INTERMEDIATE_PROMPT = """
|
| 533 |
You are a professional mock interviewer conducting an **Intermediate-level** spoken interview in the domain of **{domain}**.
|
| 534 |
Ask moderately challenging verbal interview questions based on the candidate's input: **{input_text}**.
|
| 535 |
-
|
| 536 |
Guidelines:
|
| 537 |
- Use a mix of conceptual and real-world scenario questions.
|
| 538 |
- Include light critical thinking.
|
|
@@ -541,7 +524,6 @@ Guidelines:
|
|
| 541 |
Ensure the questions are clear, to the point, and suitable for a {difficulty_level}-level interview in {selected_domain}.
|
| 542 |
**New Requirement:**
|
| 543 |
π« **Do NOT repeat any questions from previous generations again and again.** Ensure all generated questions are unique and different from past sessions.
|
| 544 |
-
|
| 545 |
**Guidelines:**
|
| 546 |
β
Questions should focus on key concepts, best practices, and problem-solving within {selected_domain}.
|
| 547 |
β
Ensure questions are direct, structured, and relevant to real-world applications.
|
|
@@ -552,7 +534,6 @@ Ensure the questions are clear, to the point, and suitable for a {difficulty_lev
|
|
| 552 |
ADVANCED_PROMPT = """
|
| 553 |
You are a strict mock interviewer conducting an **Advanced-level** spoken interview in the domain of **{domain}**.
|
| 554 |
Ask deep, analytical, real-world scenario-based questions from the candidate's input: **{input_text}**.
|
| 555 |
-
|
| 556 |
Guidelines:
|
| 557 |
- Expect detailed, logical, well-structured answers.
|
| 558 |
- Include challenging βwhyβ and βhowβ based questions.
|
|
@@ -561,7 +542,6 @@ Guidelines:
|
|
| 561 |
Ensure the questions are clear, to the point, and suitable for a {difficulty_level}-level interview in {selected_domain}.
|
| 562 |
**New Requirement:**
|
| 563 |
π« **Do NOT repeat any questions from previous generations again and again.** Ensure all generated questions are unique and different from past sessions.
|
| 564 |
-
|
| 565 |
**Guidelines:**
|
| 566 |
β
Questions should focus on key concepts, best practices, and problem-solving within {selected_domain}.
|
| 567 |
β
Ensure questions are direct, structured, and relevant to real-world applications.
|
|
@@ -600,7 +580,6 @@ st.markdown("""
|
|
| 600 |
box-shadow: 0 0 0 0.2rem rgba(0,123,255,.5) !important;
|
| 601 |
outline: none !important;
|
| 602 |
}
|
| 603 |
-
|
| 604 |
.timer-text {
|
| 605 |
font-size: 1.3rem;
|
| 606 |
font-weight: 600;
|
|
@@ -612,7 +591,6 @@ st.markdown("""
|
|
| 612 |
50% {opacity: 0.4;}
|
| 613 |
100% {opacity: 1;}
|
| 614 |
}
|
| 615 |
-
|
| 616 |
.summary-card {
|
| 617 |
background-color: #f9f9f9;
|
| 618 |
padding: 20px;
|
|
@@ -1199,5 +1177,4 @@ if st.session_state.get("show_summary", False):
|
|
| 1199 |
# Clear all session state keys and re-initialize to defaults
|
| 1200 |
keys_to_fully_clear = list(st.session_state.keys())
|
| 1201 |
for key_to_del_full in keys_to_fully_clear:
|
| 1202 |
-
del st.session_state[key_to_del_full]
|
| 1203 |
-
|
|
|
|
| 59 |
return "".join(page.extract_text() or "" for page in pdf_reader.pages).strip()
|
| 60 |
|
| 61 |
def get_questions(prompt, input_text, num_questions=3, max_retries=10):
|
| 62 |
+
model = genai.GenerativeModel('gemini-2.0-flash-lite')
|
| 63 |
|
| 64 |
if "previous_questions" not in st.session_state:
|
| 65 |
st.session_state["previous_questions"] = set()
|
|
|
|
| 148 |
# SUmmary of improvement(function)
|
| 149 |
|
| 150 |
def generate_improvement_suggestions():
|
| 151 |
+
model = genai.GenerativeModel('gemini-2.0-flash-lite')
|
| 152 |
difficulty_level = st.session_state.get("difficulty_level_select", "Beginner")
|
| 153 |
level_string = difficulty_level.lower()
|
| 154 |
|
|
|
|
| 184 |
---
|
| 185 |
{cleaned_initial_evaluation}
|
| 186 |
---
|
|
|
|
| 187 |
Based on all this information, your task is to provide DETAILED and CONSTRUCTIVE suggestions for each question to help the candidate improve. Be supportive and encouraging.
|
|
|
|
| 188 |
For EACH question, please provide:
|
| 189 |
1. **How to Improve This Answer:** Specific, actionable advice on what the candidate could have added, clarified, or approached differently to make their answer better for their {level_string} level. Focus on 1-2 key improvement points.
|
| 190 |
2. **Hints for an Ideal Answer:** Briefly mention 2-3 key concepts, terms, or elements that a strong answer (appropriate for their {level_string} level) would typically include. DO NOT provide a full model answer, just hints and pointers.
|
|
|
|
| 191 |
Keep the tone positive and focused on learning.
|
|
|
|
| 192 |
Structure your response clearly for each question. Example for one question:
|
|
|
|
| 193 |
---
|
| 194 |
**Regarding Question X: "[Original Question Text Here]"**
|
|
|
|
| 195 |
*How to Improve This Answer:*
|
| 196 |
[Your specific suggestion 1 for improvement...]
|
| 197 |
[Your specific suggestion 2 for improvement...]
|
|
|
|
| 198 |
*Hints for an Ideal Answer (Key Points to Consider):*
|
| 199 |
- Hint 1 or Key concept 1
|
| 200 |
- Hint 2 or Key concept 2
|
|
|
|
| 227 |
|
| 228 |
|
| 229 |
def evaluate_answers():
|
| 230 |
+
model = genai.GenerativeModel('gemini-2.0-flash-lite')
|
| 231 |
# difficulty_level_select is the key for the difficulty selectbox in your sidebar
|
| 232 |
difficulty_level = st.session_state.get("difficulty_level_select", "Beginner")
|
| 233 |
level_string = difficulty_level.lower()
|
|
|
|
| 284 |
hr_prompt_template = f"""
|
| 285 |
You are an experienced HR interview evaluator assessing a candidate's soft skills based on their answers to interview questions.
|
| 286 |
The candidate's performance across ALL answers should inform your scores for the following parameters.
|
|
|
|
| 287 |
**Parameters to Score (Assign a score from 1 to 5 for each):**
|
| 288 |
{hr_prompt_parameter_list}
|
|
|
|
| 289 |
After providing a score (1-5) for each of the above parameters, also write an **Overall Qualitative Feedback** section.
|
| 290 |
This section should summarize the candidate's general soft skill strengths and areas for improvement, based on their communication, engagement, and professionalism throughout the interview.
|
|
|
|
| 291 |
**REQUIRED OUTPUT FORMAT (Strictly Adhere):**
|
|
|
|
| 292 |
**Parameter Scores (1-5):**
|
| 293 |
Voice Modulation: [score]
|
| 294 |
Confidence: [score]
|
|
|
|
| 299 |
Basics of Grammar + SVA: [score]
|
| 300 |
Persuasiveness: [score]
|
| 301 |
Quality of Answers: [score]
|
|
|
|
| 302 |
**Overall Qualitative Feedback:**
|
| 303 |
[Your holistic qualitative feedback here. Be encouraging and constructive.]
|
| 304 |
"""
|
|
|
|
| 416 |
{base_assessment_criteria_qualitative_non_hr}
|
| 417 |
**YOUR RESPONSE MUST STRICTLY FOLLOW THIS FORMAT. PROVIDE SCORES FOR EACH QUESTION.**
|
| 418 |
Output format:
|
|
|
|
| 419 |
**Per-Question Scores:**
|
| 420 |
Question 1 Score: [Score for Q1 out of 5]
|
| 421 |
... (repeat for all {num_answered_questions} questions provided)
|
|
|
|
| 422 |
**Overall Evaluation Summary:**
|
| 423 |
- Concept Understanding: [Overall qualitative feedback here]
|
| 424 |
- Communication: [Overall qualitative feedback here]
|
|
|
|
| 498 |
BEGINNER_PROMPT = """
|
| 499 |
You are a friendly mock interview trainer conducting a **Beginner-level** spoken interview in the domain of **{domain}**.
|
| 500 |
Ask basic verbal interview questions based on the candidate's input: **{input_text}**.
|
|
|
|
| 501 |
Guidelines:
|
| 502 |
- Ask simple conceptual questions.
|
| 503 |
- Avoid jargon and complex examples.
|
|
|
|
| 506 |
Ensure the questions are clear, to the point, and suitable for a {difficulty_level}-level interview in {selected_domain}.
|
| 507 |
**New Requirement:**
|
| 508 |
π« **Do NOT repeat any questions from previous generations again and again.** Ensure all generated questions are unique and different from past sessions.
|
|
|
|
| 509 |
**Guidelines:**
|
| 510 |
β
Questions should focus on key concepts, best practices, and problem-solving within {selected_domain}.
|
| 511 |
β
Ensure questions are direct, structured, and relevant to real-world applications.
|
|
|
|
| 516 |
INTERMEDIATE_PROMPT = """
|
| 517 |
You are a professional mock interviewer conducting an **Intermediate-level** spoken interview in the domain of **{domain}**.
|
| 518 |
Ask moderately challenging verbal interview questions based on the candidate's input: **{input_text}**.
|
|
|
|
| 519 |
Guidelines:
|
| 520 |
- Use a mix of conceptual and real-world scenario questions.
|
| 521 |
- Include light critical thinking.
|
|
|
|
| 524 |
Ensure the questions are clear, to the point, and suitable for a {difficulty_level}-level interview in {selected_domain}.
|
| 525 |
**New Requirement:**
|
| 526 |
π« **Do NOT repeat any questions from previous generations again and again.** Ensure all generated questions are unique and different from past sessions.
|
|
|
|
| 527 |
**Guidelines:**
|
| 528 |
β
Questions should focus on key concepts, best practices, and problem-solving within {selected_domain}.
|
| 529 |
β
Ensure questions are direct, structured, and relevant to real-world applications.
|
|
|
|
| 534 |
ADVANCED_PROMPT = """
|
| 535 |
You are a strict mock interviewer conducting an **Advanced-level** spoken interview in the domain of **{domain}**.
|
| 536 |
Ask deep, analytical, real-world scenario-based questions from the candidate's input: **{input_text}**.
|
|
|
|
| 537 |
Guidelines:
|
| 538 |
- Expect detailed, logical, well-structured answers.
|
| 539 |
- Include challenging βwhyβ and βhowβ based questions.
|
|
|
|
| 542 |
Ensure the questions are clear, to the point, and suitable for a {difficulty_level}-level interview in {selected_domain}.
|
| 543 |
**New Requirement:**
|
| 544 |
π« **Do NOT repeat any questions from previous generations again and again.** Ensure all generated questions are unique and different from past sessions.
|
|
|
|
| 545 |
**Guidelines:**
|
| 546 |
β
Questions should focus on key concepts, best practices, and problem-solving within {selected_domain}.
|
| 547 |
β
Ensure questions are direct, structured, and relevant to real-world applications.
|
|
|
|
| 580 |
box-shadow: 0 0 0 0.2rem rgba(0,123,255,.5) !important;
|
| 581 |
outline: none !important;
|
| 582 |
}
|
|
|
|
| 583 |
.timer-text {
|
| 584 |
font-size: 1.3rem;
|
| 585 |
font-weight: 600;
|
|
|
|
| 591 |
50% {opacity: 0.4;}
|
| 592 |
100% {opacity: 1;}
|
| 593 |
}
|
|
|
|
| 594 |
.summary-card {
|
| 595 |
background-color: #f9f9f9;
|
| 596 |
padding: 20px;
|
|
|
|
| 1177 |
# Clear all session state keys and re-initialize to defaults
|
| 1178 |
keys_to_fully_clear = list(st.session_state.keys())
|
| 1179 |
for key_to_del_full in keys_to_fully_clear:
|
| 1180 |
+
del st.session_state[key_to_del_full]
|
|
|