rashid01 commited on
Commit
51c1cb8
·
verified ·
1 Parent(s): e1a18fa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -149
app.py CHANGED
@@ -184,157 +184,65 @@ def connect_resources():
184
  else:
185
  st.success("Thank you for contacting us! We will get back to you soon.")
186
 
187
- def style_output(text, color):
188
- return f'<div class="output-container"><span style="color: {color}; font-weight: bold;">{text}</span></div>'
189
-
190
- # Streamlit app layout
191
- st.set_page_config(page_title="TechPrep", layout="wide")
192
- st.markdown(
193
- """
194
- <style>
195
- body {
196
- background-color: #e0f7fa; /* Light cyan background color */
197
- font-family: Arial, sans-serif;
198
- }
199
- .stButton>button {
200
- width: 100%;
201
- height: 3em;
202
- font-size: 1.2em;
203
- color: white;
204
- background-color: #4CAF50;
205
- border: none;
206
- border-radius: 8px;
207
- cursor: pointer;
208
- transition: background-color 0.3s ease;
209
- }
210
- .stButton>button:hover {
211
- background-color: #45a049;
212
- }
213
- .output-container {
214
- border: 2px solid #2196F3;
215
- border-radius: 8px;
216
- padding: 15px;
217
- margin: 15px 0;
218
- background-color: #f1f1f1;
219
- }
220
- .progress-container {
221
- border: 2px solid #2196F3;
222
- border-radius: 8px;
223
- padding: 15px;
224
- margin: 15px 0;
225
- background-color: #e3f2fd;
226
- }
227
- .sidebar {
228
- background-color: #ffffff; /* Sidebar background color */
229
- padding: 1em;
230
- }
231
- .footer {
232
- background-color: #4CAF50;
233
- color: white;
234
- text-align: center;
235
- padding: 1em;
236
- position: fixed;
237
- bottom: 0;
238
- width: 100%;
239
- border-top: 2px solid #ffffff;
240
- }
241
- </style>
242
- """,
243
- unsafe_allow_html=True
244
- )
245
-
246
- # Show welcome message with an icon for 3-4 seconds
247
- welcome_message = st.empty()
248
- with welcome_message.container():
249
- st.markdown("""
250
- <div style="
251
- text-align: center;
252
- padding: 20px;
253
- background-color: #4CAF50;
254
- color: white;
255
- border-radius: 8px;
256
- font-size: 24px;
257
- ">
258
- <i class="fa fa-smile-o" aria-hidden="true" style="font-size: 40px;"></i> Welcome to TechPrep!
259
- </div>
260
- """, unsafe_allow_html=True)
261
- time.sleep(4) # Wait for 4 seconds
262
- welcome_message.empty() # Remove the welcome message
263
-
264
- # Sidebar for additional links
265
- with st.sidebar:
266
- st.title("Menu")
267
- st.markdown("<h3>About Us</h3><p>We help you prepare for job interviews with simulated questions and feedback.</p>", unsafe_allow_html=True)
268
- st.markdown("<h3>Sponsored By</h3><p>Your trusted career preparation partner.</p>", unsafe_allow_html=True)
269
- 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)
270
-
271
- st.title("💼 TechPrep")
272
-
273
- model_choice = st.selectbox("Select AI Model", ["Gemini", "OpenAI"], key="select_model")
274
- role = st.selectbox("Select Role", ["GenAI Engineer", "Machine Learning Engineer", "Data Scientist", "Software Developer", "Marketing Manager"], key="select_role")
275
- question_type = st.selectbox("Select Question Type", ["Behavioral", "Technical", "Situational", "Case Study", "Problem Solving"], key="select_question_type")
276
- num_questions = st.slider("Number of Questions", 1, 10, key="slider_num_questions")
277
- difficulty = st.selectbox("Select Difficulty Level", ["Easy", "Medium", "Hard"], key="select_difficulty")
278
-
279
- st.header("📝 Generate Interview Questions")
280
- if st.button("Generate Questions", key="generate_questions"):
281
- with st.spinner("Generating questions..."):
282
- questions = generate_questions(model_choice, role, question_type, num_questions, difficulty)
283
- if questions:
284
- st.session_state['questions'] = questions
285
- st.session_state['question_index'] = 0 # Reset index to start
286
- st.session_state['questions_count'] = len(questions)
287
-
288
- st.markdown(style_output("Question:", "#4CAF50"), unsafe_allow_html=True)
289
- st.write(st.session_state['questions'][st.session_state['question_index']])
290
-
291
- col1, col2 = st.columns([3, 1])
292
  with col2:
293
- if st.button("Next", key="next_question"):
294
- if st.session_state['question_index'] + 1 < len(st.session_state['questions']):
295
- st.session_state['question_index'] += 1
296
- else:
297
- st.session_state['question_index'] = 0 # Loop back to first question
298
- st.success("You have reached the end of the questions.")
299
- st.markdown(style_output("Question:", "#4CAF50"), unsafe_allow_html=True)
300
- st.write(st.session_state['questions'][st.session_state['question_index']])
301
-
302
- progress_data["questions_solved"][question_type] += num_questions
303
 
304
- st.header("🗣️ Provide Feedback")
305
- answer = st.text_area("Submit Your Answer", key="text_area_answer")
306
- if st.button("Submit Answer", key="submit_answer"):
307
- if not answer:
308
- st.error("Please enter an answer to receive feedback.")
309
- else:
310
- with st.spinner("Providing feedback..."):
311
- feedback = provide_feedback(model_choice, answer)
312
- st.markdown(style_output("Feedback Received:", "#FF5722"), unsafe_allow_html=True)
313
- st.write(feedback)
314
- progress_data["feedback_provided"] += 1
315
 
316
- st.header("💡 Interview Tips")
317
- if st.button("Get Tips", key="get_tips"):
318
- with st.spinner("Fetching tips..."):
319
- tips = get_tips(model_choice, role)
320
- st.markdown(style_output("Tips Received:", "#2196F3"), unsafe_allow_html=True)
321
- st.write(tips)
322
- progress_data["tips_retrieved"] += 1
323
 
324
- st.header("📅 Schedule Mock Interview")
325
- schedule_mock_interview()
326
-
327
- st.header("📈 Progress and Resources")
328
- col1, col2 = st.columns(2)
329
- with col1:
330
- track_progress()
331
- with col2:
332
- connect_resources()
333
-
334
- # Footer
335
- st.markdown("""
336
- <div class="footer">
337
- <p>&copy; 2024 TechPrep. All rights reserved.</p>
338
- </div>
339
- """, unsafe_allow_html=True)
340
 
 
 
 
184
  else:
185
  st.success("Thank you for contacting us! We will get back to you soon.")
186
 
187
+ def display_questions(questions):
188
+ if questions:
189
+ for i, question in enumerate(questions):
190
+ st.write(f"**Question {i+1}:** {question}")
191
+
192
+ def main():
193
+ st.set_page_config(page_title="TechPrep", layout="wide")
194
+ st.title("TechPrep: Interview Preparation Tool")
195
+
196
+ # Initialize session state for questions
197
+ if 'questions' not in st.session_state:
198
+ st.session_state.questions = []
199
+ if 'question_index' not in st.session_state:
200
+ st.session_state.question_index = 0
201
+
202
+ # Define sidebar options
203
+ options = ["Generate Questions", "Track Progress", "Connect with Resources", "Schedule Mock Interview"]
204
+ selection = st.sidebar.radio("Choose an Option", options)
205
+
206
+ if selection == "Generate Questions":
207
+ model_choice = st.selectbox("Select Model", ["OpenAI", "Gemini"])
208
+ role = st.text_input("Role")
209
+ question_type = st.selectbox("Question Type", ["Behavioral", "Technical", "Situational", "Case Study", "Problem Solving"])
210
+ num_questions = st.number_input("Number of Questions", min_value=1, max_value=10, value=1)
211
+ difficulty = st.selectbox("Difficulty", ["Easy", "Medium", "Hard"])
212
+
213
+ if st.button("Generate Questions"):
214
+ if role:
215
+ questions = generate_questions(model_choice, role, question_type, num_questions, difficulty)
216
+ st.session_state.questions = questions
217
+ st.session_state.question_index = 0
218
+ st.success(f"Questions generated successfully!")
219
+ else:
220
+ st.error("Please enter a role.")
221
+
222
+ # Navigation for questions
223
+ if st.session_state.questions:
224
+ display_questions([st.session_state.questions[st.session_state.question_index]])
225
+
226
+ col1, col2 = st.columns([1, 1])
227
+ with col1:
228
+ if st.session_state.question_index > 0:
229
+ if st.button("Previous"):
230
+ st.session_state.question_index -= 1
231
+ st.experimental_rerun()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  with col2:
233
+ if st.session_state.question_index < len(st.session_state.questions) - 1:
234
+ if st.button("Next"):
235
+ st.session_state.question_index += 1
236
+ st.experimental_rerun()
 
 
 
 
 
 
237
 
238
+ elif selection == "Track Progress":
239
+ track_progress()
 
 
 
 
 
 
 
 
 
240
 
241
+ elif selection == "Connect with Resources":
242
+ connect_resources()
 
 
 
 
 
243
 
244
+ elif selection == "Schedule Mock Interview":
245
+ schedule_mock_interview()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
 
247
+ if __name__ == "__main__":
248
+ main()