File size: 2,832 Bytes
aab85bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e27eca7
 
 
 
 
aab85bc
 
 
82c089d
aab85bc
 
 
e27eca7
aab85bc
 
e27eca7
aab85bc
 
 
 
 
 
 
 
 
e27eca7
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import gradio as gr

# HR Interview Questions
questions = [
    "Tell me about yourself.",
    "Why do you want to join our company?",
    "What are your strengths?",
    "What is your biggest weakness?",
    "Where do you see yourself in 5 years?",
    "Describe a challenging situation you faced and how you overcame it.",
    "How do you handle pressure or stress?",
    "Tell me about a time you worked in a team.",
    "Why should we hire you?",
    "Do you have any questions for us?"
]

# Soft Skills Keywords
soft_skills = {
    "Communication": ["communicate", "communication", "presented", "explained"],
    "Leadership": ["lead", "led", "managed", "organized", "supervised"],
    "Teamwork": ["team", "collaborated", "together", "group", "cooperate"],
    "Problem-Solving": ["solve", "fixed", "handled", "resolved", "dealt"],
    "Adaptability": ["adapt", "change", "adjust", "flexible"],
    "Time Management": ["deadline", "time", "schedule", "prioritize"],
    "Critical Thinking": ["analyze", "think", "evaluated", "decision"]
}

# Core Chatbot Logic
def interview_bot(user_input, history):
    if len(history) < len(questions):
        current_question = questions[len(history)]
        history.append((current_question, user_input))
        detected_skills = []
        for skill, keywords in soft_skills.items():
            if any(keyword in user_input.lower() for keyword in keywords):
                detected_skills.append(skill)
        if detected_skills:
            feedback = f"✅ You highlighted soft skills: {', '.join(detected_skills)}"
        else:
            feedback = "ℹ️ Try mentioning soft skills like teamwork, leadership, or problem-solving."
        if len(history) < len(questions):
            next_question = f"\n\n➡️ Next Question: {questions[len(history)]}"
        else:
            next_question = "\n\n🎯 You've completed the interview practice!"
        return history, feedback + next_question
    else:
        return history, "🎯 You've completed the interview practice!"

# Gradio Interface demo
with gr.Blocks() as demo:
    gr.Markdown("# 🤖 HR Interview Practice Chatbot")
    chatbot = gr.Chatbot()
    msg = gr.Textbox(label="Your Answer", placeholder="Type your answer here...")
    state = gr.State([])
    btn = gr.Button("Submit")

    def respond(user_message, chat_state):
        response_state, bot_reply = interview_bot(user_message, chat_state)
        chat_display = []
        for q, a in response_state:
            chat_display.append((f"💬 {q}", f"📝 {a}"))
        chat_display.append(("🤖 Feedback", bot_reply))
        return chat_display, response_state

    btn.click(respond, [msg, state], [chatbot, state])

    gr.Markdown("👉 Practice your answers and get soft skill feedback! Made with ❤️ using Gradio.")

demo.launch()