Spaces:
Sleeping
Sleeping
| 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() | |