Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,46 +2,6 @@ import gradio as gr
|
|
2 |
from openai import OpenAI
|
3 |
import time
|
4 |
|
5 |
-
# Predefined examples
|
6 |
-
SETUP_EXAMPLES = [
|
7 |
-
["AI Engineer", "Mid-level"],
|
8 |
-
["Data Scientist", "Senior"],
|
9 |
-
["ML Engineer", "Entry-level"]
|
10 |
-
]
|
11 |
-
|
12 |
-
PRACTICE_EXAMPLES = [
|
13 |
-
[
|
14 |
-
# Sample Questions
|
15 |
-
"""Technical Questions:
|
16 |
-
1. Can you explain the difference between supervised and unsupervised learning?
|
17 |
-
2. How do you handle imbalanced datasets in machine learning?
|
18 |
-
3. Can you describe a project where you used deep learning techniques?
|
19 |
-
4. How do you evaluate the performance of a machine learning model?
|
20 |
-
5. Can you explain the concept of overfitting and how to prevent it?
|
21 |
-
|
22 |
-
Behavioral Questions:
|
23 |
-
1. Can you describe a time when you had to work on a project with a tight deadline?
|
24 |
-
2. Tell me about a time when you faced a technical challenge during a project.
|
25 |
-
3. Can you give an example of teamwork experience?""",
|
26 |
-
|
27 |
-
# Sample Answer
|
28 |
-
"""### 1. **Supervised vs Unsupervised Learning**
|
29 |
-
Supervised learning uses labeled data to train models, while unsupervised learning finds patterns in unlabeled data...
|
30 |
-
|
31 |
-
### 2. **Handling Imbalanced Data**
|
32 |
-
Techniques include resampling, class weighting, and using appropriate evaluation metrics...
|
33 |
-
|
34 |
-
[Rest of the sample answer...]"""
|
35 |
-
]
|
36 |
-
]
|
37 |
-
|
38 |
-
FEEDBACK_EXAMPLE = [
|
39 |
-
"""**Feedback on Candidate's Answers**
|
40 |
-
**1. Supervised vs Unsupervised Learning**
|
41 |
-
Clarity: Clear explanation with good examples...
|
42 |
-
[Rest of the sample feedback...]"""
|
43 |
-
]
|
44 |
-
|
45 |
def generate_questions(api_key, role, experience):
|
46 |
if not api_key:
|
47 |
return "[ERROR] Please enter your OpenRouter API key"
|
@@ -115,48 +75,23 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
115 |
)
|
116 |
|
117 |
with gr.Tab("Interview Setup"):
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
generate_btn = gr.Button("Generate Questions")
|
127 |
-
|
128 |
-
# Setup examples
|
129 |
-
gr.Examples(
|
130 |
-
examples=SETUP_EXAMPLES,
|
131 |
-
inputs=[role, experience],
|
132 |
-
label="Click any example to load setup:"
|
133 |
-
)
|
134 |
-
|
135 |
with gr.Tab("Practice Session"):
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
feedback_btn = gr.Button("Get Feedback")
|
141 |
-
|
142 |
-
# Practice examples
|
143 |
-
gr.Examples(
|
144 |
-
examples=PRACTICE_EXAMPLES,
|
145 |
-
inputs=[questions, answer],
|
146 |
-
label="Click to load example Q&A:"
|
147 |
-
)
|
148 |
-
|
149 |
with gr.Tab("Feedback"):
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
# Feedback example
|
154 |
-
gr.Examples(
|
155 |
-
examples=FEEDBACK_EXAMPLE,
|
156 |
-
inputs=[feedback],
|
157 |
-
label="Example Feedback:"
|
158 |
-
)
|
159 |
-
|
160 |
generate_btn.click(
|
161 |
fn=generate_questions,
|
162 |
inputs=[api_key, role, experience],
|
|
|
2 |
from openai import OpenAI
|
3 |
import time
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
def generate_questions(api_key, role, experience):
|
6 |
if not api_key:
|
7 |
return "[ERROR] Please enter your OpenRouter API key"
|
|
|
75 |
)
|
76 |
|
77 |
with gr.Tab("Interview Setup"):
|
78 |
+
role = gr.Textbox(label="Desired Job Role")
|
79 |
+
experience = gr.Dropdown(
|
80 |
+
label="Experience Level",
|
81 |
+
choices=["Entry-level", "Mid-level", "Senior", "Executive"],
|
82 |
+
value="Mid-level"
|
83 |
+
)
|
84 |
+
generate_btn = gr.Button("Generate Interview Questions")
|
85 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
with gr.Tab("Practice Session"):
|
87 |
+
questions = gr.Textbox(label="Generated Questions", lines=10, interactive=False)
|
88 |
+
answer = gr.Textbox(label="Your Answer", lines=8, placeholder="Type your response here...")
|
89 |
+
feedback_btn = gr.Button("Get Feedback")
|
90 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
with gr.Tab("Feedback"):
|
92 |
+
feedback = gr.Textbox(label="Expert Feedback", lines=12, interactive=False)
|
93 |
+
|
94 |
+
# Event handlers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
generate_btn.click(
|
96 |
fn=generate_questions,
|
97 |
inputs=[api_key, role, experience],
|