Update app.py
Browse files
app.py
CHANGED
|
@@ -184,65 +184,165 @@ def connect_resources():
|
|
| 184 |
else:
|
| 185 |
st.success("Thank you for contacting us! We will get back to you soon.")
|
| 186 |
|
| 187 |
-
def
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|
|
|
|
| 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 |
+
# Options for AI model, role, question type, etc.
|
| 274 |
+
model_choice = st.selectbox("Select AI Model", ["Gemini", "OpenAI"], key="select_model")
|
| 275 |
+
role = st.selectbox("Select Role", ["Software Developer", "Data Analyst", "Marketing Manager", "Project Manager", "UX Designer", "GenAI Engineer", "ML Engineer", "Graphic Designer"], key="select_role")
|
| 276 |
+
question_type = st.selectbox("Select Question Type", ["Behavioral", "Technical", "Situational", "Case Study", "Problem Solving"], key="select_question_type")
|
| 277 |
+
num_questions = st.slider("Number of Questions", 1, 10, key="slider_num_questions")
|
| 278 |
+
difficulty = st.selectbox("Select Difficulty Level", ["Easy", "Medium", "Hard"], key="select_difficulty")
|
| 279 |
+
|
| 280 |
+
# Initialize session state for questions and current index
|
| 281 |
+
if 'questions' not in st.session_state:
|
| 282 |
+
st.session_state.questions = []
|
| 283 |
+
if 'question_index' not in st.session_state:
|
| 284 |
+
st.session_state.question_index = 0
|
| 285 |
+
|
| 286 |
+
# Generate questions
|
| 287 |
+
st.header("π Generate Interview Questions")
|
| 288 |
+
if st.button("Generate Questions", key="generate_questions"):
|
| 289 |
+
with st.spinner("Generating questions..."):
|
| 290 |
+
questions = generate_questions(model_choice, role, question_type, num_questions, difficulty)
|
| 291 |
+
st.session_state.questions = questions
|
| 292 |
st.session_state.question_index = 0
|
| 293 |
+
progress_data["questions_solved"][question_type] += num_questions
|
| 294 |
+
|
| 295 |
+
# Display questions with navigation
|
| 296 |
+
if st.session_state.questions:
|
| 297 |
+
if st.session_state.question_index < len(st.session_state.questions):
|
| 298 |
+
st.write(f"**Question {st.session_state.question_index + 1}:** {st.session_state.questions[st.session_state.question_index]}")
|
| 299 |
+
|
| 300 |
+
col1, col2 = st.columns(2)
|
| 301 |
+
with col1:
|
| 302 |
+
if st.session_state.question_index > 0:
|
| 303 |
+
if st.button("Previous"):
|
| 304 |
+
st.session_state.question_index -= 1
|
| 305 |
+
st.experimental_rerun()
|
| 306 |
+
with col2:
|
| 307 |
+
if st.session_state.question_index < len(st.session_state.questions) - 1:
|
| 308 |
+
if st.button("Next"):
|
| 309 |
+
st.session_state.question_index += 1
|
| 310 |
+
st.experimental_rerun()
|
| 311 |
+
|
| 312 |
+
st.header("π£οΈ Provide Feedback")
|
| 313 |
+
answer = st.text_area("Submit Your Answer", key="text_area_answer")
|
| 314 |
+
if st.button("Submit Answer", key="submit_answer"):
|
| 315 |
+
if not answer:
|
| 316 |
+
st.error("Please enter an answer to receive feedback.")
|
| 317 |
+
else:
|
| 318 |
+
with st.spinner("Providing feedback..."):
|
| 319 |
+
feedback = provide_feedback(model_choice, answer)
|
| 320 |
+
st.markdown(style_output("Feedback Received:", "#FF5722"), unsafe_allow_html=True)
|
| 321 |
+
st.write(feedback)
|
| 322 |
+
progress_data["feedback_provided"] += 1
|
| 323 |
+
|
| 324 |
+
st.header("π‘ Interview Tips")
|
| 325 |
+
if st.button("Get Tips", key="get_tips"):
|
| 326 |
+
with st.spinner("Fetching tips..."):
|
| 327 |
+
tips = get_tips(model_choice, role)
|
| 328 |
+
st.markdown(style_output("Tips Received:", "#2196F3"), unsafe_allow_html=True)
|
| 329 |
+
st.write(tips)
|
| 330 |
+
progress_data["tips_retrieved"] += 1
|
| 331 |
+
|
| 332 |
+
st.header("π
Schedule Mock Interview")
|
| 333 |
+
schedule_mock_interview()
|
| 334 |
+
|
| 335 |
+
st.header("π Progress and Resources")
|
| 336 |
+
col1, col2 = st.columns(2)
|
| 337 |
+
with col1:
|
| 338 |
+
track_progress()
|
| 339 |
+
with col2:
|
| 340 |
+
connect_resources()
|
| 341 |
+
|
| 342 |
+
# Footer
|
| 343 |
+
st.markdown("""
|
| 344 |
+
<div class="footer">
|
| 345 |
+
<p>© 2024 TechPrep. All rights reserved.</p>
|
| 346 |
+
</div>
|
| 347 |
+
""", unsafe_allow_html=True)
|
| 348 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|