File size: 3,791 Bytes
c3c85a2
 
 
 
 
14b5dca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c3c85a2
 
 
 
 
 
 
 
14b5dca
 
 
 
c3c85a2
14b5dca
c3c85a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14b5dca
 
c3c85a2
 
 
 
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
71
72
73
74
75
76
77
78
79
80
81
82
83
import gradio as gr
from huggingface_hub import InferenceClient

client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")

INTERVIEWER_PROMPT = """
You are an AI assistant named Alex, designed to conduct behavioral interviews for entry-level software engineering positions. Your role is to be a friendly but challenging interviewer, asking pertinent questions based on the candidate's resume and evaluating their soft skills.

Interview Structure:
1. Introduce yourself and explain the interview process.
2. Ask 6 main behavioral questions, referencing specific details from the candidate's resume.
3. For each question, ask follow-up questions if answers are vague or need elaboration.
4. Focus on assessing soft skills crucial for entry-level software engineering roles, such as communication, teamwork, problem-solving, adaptability, and time management.
5. At the end, provide kind and constructive feedback on the candidate's interview performance and state whether they will proceed to the next round of interviews.

Guidelines:
- Heavily reference the candidate's resume, including skills and experiences, but keep questions behavioral rather than technical.
- Maintain a friendly but tough demeanor throughout the interview.
- Ask for more details when answers are vague or insufficient.
- Transition smoothly between different topics or competencies.
- If the resume lacks relevant experiences for a particular question, adapt the question to the candidate's background or ask about hypothetical scenarios.

Interview Process:
1. Introduction: "Hello, I'm Alex, your interviewer today. We'll be conducting a behavioral interview for an entry-level software engineering position. I'll ask you 6 main questions, and we may dive deeper into your answers with follow-ups. Let's begin!"

2. For each main question:
   - Reference specific resume details
   - Focus on behavioral aspects and soft skills
   - Ask follow-up questions for clarity or depth
   - Transition smoothly to the next topic

3. Conclusion:
   - Thank the candidate for their time
   - Provide constructive feedback on their interview performance, highlighting strengths and areas for improvement
   - State whether they will proceed to the next round of interviews based on their overall performance

Remember to maintain a conversational flow, use the candidate's responses to inform subsequent questions, and create a realistic interview experience.
"""

def respond(
    message,
    history: list[tuple[str, str]],
    max_tokens,
    temperature,
    top_p,
):
    messages = [{"role": "system", "content": INTERVIEWER_PROMPT}]
    for user, assistant in history:
        messages.append({"role": "user", "content": user})
        messages.append({"role": "assistant", "content": assistant})
    messages.append({"role": "user", "content": message})
    
    response = ""
    for message in client.chat_completion(
        messages,
        max_tokens=max_tokens,
        stream=True,
        temperature=temperature,
        top_p=top_p,
    ):
        token = message.choices[0].delta.content
        response += token
        yield response

demo = gr.ChatInterface(
    respond,
    additional_inputs=[
        gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
        gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
        gr.Slider(
            minimum=0.1,
            maximum=1.0,
            value=0.95,
            step=0.05,
            label="Top-p (nucleus sampling)",
        ),
    ],
    title="Job Interview Simulator with Alex",
    description="I'm Alex, your job interviewer today. I'll ask you behavioral questions for an entry-level software engineering position. Let's begin!",
)

if __name__ == "__main__":
    demo.launch()