shukdevdatta123 commited on
Commit
db4a556
·
verified ·
1 Parent(s): a58d3f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +80 -15
app.py CHANGED
@@ -2,6 +2,46 @@ import gradio as gr
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,23 +115,48 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
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],
 
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
  )
116
 
117
  with gr.Tab("Interview Setup"):
118
+ with gr.Row():
119
+ with gr.Column():
120
+ role = gr.Textbox(label="Desired Job Role")
121
+ experience = gr.Dropdown(
122
+ label="Experience Level",
123
+ choices=["Entry-level", "Mid-level", "Senior", "Executive"],
124
+ value="Mid-level"
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
+ with gr.Row():
137
+ with gr.Column():
138
+ questions = gr.Textbox(label="Generated Questions", lines=10, interactive=False)
139
+ answer = gr.Textbox(label="Your Answer", lines=8, placeholder="Type your response here...")
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
+ with gr.Row():
151
+ feedback = gr.Textbox(label="Expert Feedback", lines=12, interactive=False)
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],