rashid01 commited on
Commit
b8907fa
Β·
verified Β·
1 Parent(s): 06c8c47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +73 -57
app.py CHANGED
@@ -19,9 +19,6 @@ progress_data = {
19
  "tips_retrieved": 0
20
  }
21
 
22
- # Placeholder for recorded interviews
23
- recorded_interviews = []
24
-
25
  def get_llm(model_choice):
26
  if model_choice == "Gemini":
27
  return ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=GOOGLE_API_KEY)
@@ -81,13 +78,11 @@ def get_tips(model_choice, role):
81
  else:
82
  raise ValueError("Unsupported model choice.")
83
 
84
- def start_mock_interview(interview_details):
85
  st.write("### Mock Interview Starting")
86
- st.write(f"The mock interview with the bot is starting now. Please proceed with your responses.")
87
- st.write(f"**Interview Timer:**")
88
- countdown_end = datetime.now() + timedelta(minutes=interview_details['duration'])
89
 
90
- # Simulate interview environment
91
  st.markdown("""
92
  <div style="
93
  width: 100%;
@@ -95,6 +90,7 @@ def start_mock_interview(interview_details):
95
  background-color: #000;
96
  color: #fff;
97
  display: flex;
 
98
  align-items: center;
99
  justify-content: center;
100
  font-size: 24px;
@@ -102,11 +98,16 @@ def start_mock_interview(interview_details):
102
  border-radius: 8px;
103
  border: 2px solid #2196F3;
104
  ">
105
- <p>Interview in Progress with Bot...</p>
 
 
 
 
106
  </div>
107
  """, unsafe_allow_html=True)
108
 
109
- # Timer for the mock interview
 
110
  while datetime.now() < countdown_end:
111
  remaining_time = countdown_end - datetime.now()
112
  if remaining_time <= timedelta(seconds=3):
@@ -114,31 +115,23 @@ def start_mock_interview(interview_details):
114
  time.sleep(1)
115
 
116
  st.write("Mock Interview Session Ended.")
117
- recorded_interviews.append({
118
- "date": datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
119
- "duration": interview_details['duration'],
120
- "role": interview_details['role']
121
- })
122
  progress_data["mock_interviews_taken"] += 1
123
 
124
  def schedule_mock_interview():
125
  st.subheader("Schedule a Mock Interview")
126
-
127
- # Unique keys for each widget
128
- date = st.date_input("Select Date", min_value=datetime.today(), key="schedule_date")
129
- time = st.time_input("Select Time", value=datetime.now().time(), key="schedule_time")
130
- duration = st.selectbox("Duration (Minutes)", [30, 45, 60], key="duration_select")
131
- role = st.selectbox("Select Role", ["Software Developer", "Data Analyst", "Marketing Manager"], key="role_select")
132
  now = datetime.now()
133
  selected_datetime = datetime.combine(date, time)
134
 
135
  col1, col2 = st.columns(2)
136
  with col1:
137
- if st.button("Start Interview Now", key="start_now"):
138
- start_mock_interview({"role": role, "duration": duration})
139
 
140
  with col2:
141
- if st.button("Schedule Interview", key="schedule_interview"):
142
  if selected_datetime < now:
143
  st.error("Selected time is in the past. Please choose a future time.")
144
  else:
@@ -160,17 +153,6 @@ def track_progress():
160
  </div>
161
  """, unsafe_allow_html=True)
162
 
163
- # Show recorded interviews
164
- st.subheader("Recorded Mock Interviews")
165
- if recorded_interviews:
166
- for interview in recorded_interviews:
167
- st.write(f"**Date:** {interview['date']}")
168
- st.write(f"**Role:** {interview['role']}")
169
- st.write(f"**Duration:** {interview['duration']} minutes")
170
- st.write("---")
171
- else:
172
- st.write("No recorded interviews yet.")
173
-
174
  def connect_resources():
175
  st.subheader("Connect with Resources")
176
  st.write("### Articles & Books")
@@ -187,10 +169,10 @@ def connect_resources():
187
  # Form to connect with career coaches or mentors
188
  with st.form("contact_form"):
189
  st.write("For personalized assistance, please fill out this form:")
190
- name = st.text_input("Name", key="contact_name")
191
- email = st.text_input("Email", key="contact_email")
192
- message = st.text_area("Message", key="contact_message")
193
- submit_button = st.form_submit_button("Submit", key="contact_submit")
194
 
195
  if submit_button:
196
  if not name or not email or not message:
@@ -280,27 +262,61 @@ with st.sidebar:
280
  st.title("Menu")
281
  st.markdown("<h3>About Us</h3><p>We help you prepare for job interviews with simulated questions and feedback.</p>", unsafe_allow_html=True)
282
  st.markdown("<h3>Sponsored By</h3><p>Your trusted career preparation partner.</p>", unsafe_allow_html=True)
283
- st.markdown("<h3>Contact Us</h3><p>For support, email us at support@techprep.com</p>", unsafe_allow_html=True)
284
-
285
- # Main app
286
- menu = st.sidebar.selectbox("Select a Page", ["Home", "Mock Interviews", "Track Progress", "Resources"])
287
-
288
- if menu == "Home":
289
- st.title("Welcome to TechPrep!")
290
- st.write("Your comprehensive tool for interview preparation. Choose an option from the menu to get started.")
291
-
292
- elif menu == "Mock Interviews":
293
- st.title("Mock Interviews")
294
- schedule_mock_interview()
295
-
296
- elif menu == "Track Progress":
297
- st.title("Track Your Progress")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  track_progress()
299
-
300
- elif menu == "Resources":
301
- st.title("Resources")
302
  connect_resources()
303
 
 
 
 
 
 
 
 
304
 
305
 
306
 
 
19
  "tips_retrieved": 0
20
  }
21
 
 
 
 
22
  def get_llm(model_choice):
23
  if model_choice == "Gemini":
24
  return ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=GOOGLE_API_KEY)
 
78
  else:
79
  raise ValueError("Unsupported model choice.")
80
 
81
+ def start_mock_interview():
82
  st.write("### Mock Interview Starting")
83
+ st.write("The mock interview is starting now. Please connect with your interviewer.")
 
 
84
 
85
+ # Simulate video call window with recording message
86
  st.markdown("""
87
  <div style="
88
  width: 100%;
 
90
  background-color: #000;
91
  color: #fff;
92
  display: flex;
93
+ flex-direction: column;
94
  align-items: center;
95
  justify-content: center;
96
  font-size: 24px;
 
98
  border-radius: 8px;
99
  border: 2px solid #2196F3;
100
  ">
101
+ <p style="margin: 10px;">
102
+ <i class="fa fa-circle" aria-hidden="true" style="font-size: 50px; color: red;"></i><br>
103
+ Call is being RECORDED
104
+ </p>
105
+ <p style="font-size: 18px;">Interview with: John Doe</p>
106
  </div>
107
  """, unsafe_allow_html=True)
108
 
109
+ countdown_end = datetime.now() + timedelta(seconds=60) # 60 seconds timer
110
+
111
  while datetime.now() < countdown_end:
112
  remaining_time = countdown_end - datetime.now()
113
  if remaining_time <= timedelta(seconds=3):
 
115
  time.sleep(1)
116
 
117
  st.write("Mock Interview Session Ended.")
 
 
 
 
 
118
  progress_data["mock_interviews_taken"] += 1
119
 
120
  def schedule_mock_interview():
121
  st.subheader("Schedule a Mock Interview")
122
+ date = st.date_input("Select Date", min_value=datetime.today())
123
+ time = st.time_input("Select Time", value=datetime.now().time())
124
+ duration = st.selectbox("Duration (Minutes)", [30, 45, 60])
 
 
 
125
  now = datetime.now()
126
  selected_datetime = datetime.combine(date, time)
127
 
128
  col1, col2 = st.columns(2)
129
  with col1:
130
+ if st.button("Start Interview Now"):
131
+ start_mock_interview()
132
 
133
  with col2:
134
+ if st.button("Schedule Interview"):
135
  if selected_datetime < now:
136
  st.error("Selected time is in the past. Please choose a future time.")
137
  else:
 
153
  </div>
154
  """, unsafe_allow_html=True)
155
 
 
 
 
 
 
 
 
 
 
 
 
156
  def connect_resources():
157
  st.subheader("Connect with Resources")
158
  st.write("### Articles & Books")
 
169
  # Form to connect with career coaches or mentors
170
  with st.form("contact_form"):
171
  st.write("For personalized assistance, please fill out this form:")
172
+ name = st.text_input("Name")
173
+ email = st.text_input("Email")
174
+ message = st.text_area("Message")
175
+ submit_button = st.form_submit_button("Submit")
176
 
177
  if submit_button:
178
  if not name or not email or not message:
 
262
  st.title("Menu")
263
  st.markdown("<h3>About Us</h3><p>We help you prepare for job interviews with simulated questions and feedback.</p>", unsafe_allow_html=True)
264
  st.markdown("<h3>Sponsored By</h3><p>Your trusted career preparation partner.</p>", unsafe_allow_html=True)
265
+ st.markdown("<h3>Contact Us</h3><p>For support, email us at <a href='mailto:support@example.com'>support@example.com</a>.</p>", unsafe_allow_html=True)
266
+
267
+ st.title("πŸ’Ό TechPrep")
268
+
269
+ model_choice = st.selectbox("Select AI Model", ["Gemini", "OpenAI"], key="select_model")
270
+ role = st.selectbox("Select Role", ["Software Developer", "Data Analyst", "Marketing Manager"], key="select_role")
271
+ question_type = st.selectbox("Select Question Type", ["Behavioral", "Technical", "Situational"], key="select_question_type")
272
+ num_questions = st.slider("Number of Questions", 1, 10, key="slider_num_questions")
273
+ difficulty = st.selectbox("Select Difficulty Level", ["Easy", "Medium", "Hard"], key="select_difficulty")
274
+
275
+ st.header("πŸ“ Generate Interview Questions")
276
+ if st.button("Generate Questions", key="generate_questions"):
277
+ with st.spinner("Generating questions..."):
278
+ questions = generate_questions(model_choice, role, question_type, num_questions, difficulty)
279
+ st.markdown(style_output("Questions Generated:", "#4CAF50"), unsafe_allow_html=True)
280
+ st.write(questions)
281
+ progress_data["questions_solved"][question_type] += num_questions
282
+
283
+ st.header("πŸ—£οΈ Provide Feedback")
284
+ answer = st.text_area("Submit Your Answer", key="text_area_answer")
285
+ if st.button("Submit Answer", key="submit_answer"):
286
+ if not answer:
287
+ st.error("Please enter an answer to receive feedback.")
288
+ else:
289
+ with st.spinner("Providing feedback..."):
290
+ feedback = provide_feedback(model_choice, answer)
291
+ st.markdown(style_output("Feedback Received:", "#FF5722"), unsafe_allow_html=True)
292
+ st.write(feedback)
293
+ progress_data["feedback_provided"] += 1
294
+
295
+ st.header("πŸ’‘ Interview Tips")
296
+ if st.button("Get Tips", key="get_tips"):
297
+ with st.spinner("Fetching tips..."):
298
+ tips = get_tips(model_choice, role)
299
+ st.markdown(style_output("Tips Received:", "#2196F3"), unsafe_allow_html=True)
300
+ st.write(tips)
301
+ progress_data["tips_retrieved"] += 1
302
+
303
+ st.header("πŸ“… Schedule Mock Interview")
304
+ schedule_mock_interview()
305
+
306
+ st.header("πŸ“ˆ Progress and Resources")
307
+ col1, col2 = st.columns(2)
308
+ with col1:
309
  track_progress()
310
+ with col2:
 
 
311
  connect_resources()
312
 
313
+ # Footer
314
+ st.markdown("""
315
+ <div class="footer">
316
+ <p>&copy; 2024 TechPrep. All rights reserved.</p>
317
+ </div>
318
+ """, unsafe_allow_html=True)
319
+
320
 
321
 
322