rashid01 commited on
Commit
1791550
·
verified ·
1 Parent(s): cb6544e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -13
app.py CHANGED
@@ -40,11 +40,11 @@ def generate_questions(model_choice, role, question_type, num_questions, difficu
40
  prompt=prompt,
41
  max_tokens=150
42
  )
43
- return response.choices[0].text.strip()
44
  elif model_choice == "Gemini":
45
  llm = get_llm(model_choice)
46
  response = llm.invoke(prompt)
47
- return response.content
48
  else:
49
  raise ValueError("Unsupported model choice.")
50
 
@@ -210,16 +210,14 @@ st.markdown(
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;
@@ -227,6 +225,8 @@ st.markdown(
227
  .sidebar {
228
  background-color: #ffffff; /* Sidebar background color */
229
  padding: 1em;
 
 
230
  }
231
  .footer {
232
  background-color: #4CAF50;
@@ -272,7 +272,7 @@ st.title("💼 TechPrep")
272
 
273
  model_choice = st.selectbox("Select AI Model", ["Gemini", "OpenAI"], key="select_model")
274
 
275
- # Updated role dropdown with 20 roles
276
  roles = [
277
  "Software Developer", "Data Analyst", "Marketing Manager", "Project Manager", "UX Designer",
278
  "Machine Learning Engineer", "Data Scientist", "AI Researcher", "Product Manager", "Business Analyst",
@@ -290,8 +290,30 @@ st.header("📝 Generate Interview Questions")
290
  if st.button("Generate Questions", key="generate_questions"):
291
  with st.spinner("Generating questions..."):
292
  questions = generate_questions(model_choice, role, question_type, num_questions, difficulty)
293
- st.markdown(style_output("Questions Generated:", "#4CAF50"), unsafe_allow_html=True)
294
- st.write(questions)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  progress_data["questions_solved"][question_type] += num_questions
296
 
297
  st.header("🗣️ Provide Feedback")
 
40
  prompt=prompt,
41
  max_tokens=150
42
  )
43
+ return response.choices[0].text.strip().split("\n")
44
  elif model_choice == "Gemini":
45
  llm = get_llm(model_choice)
46
  response = llm.invoke(prompt)
47
+ return response.content.strip().split("\n")
48
  else:
49
  raise ValueError("Unsupported model choice.")
50
 
 
210
  .stButton>button:hover {
211
  background-color: #45a049;
212
  }
 
 
 
 
 
 
 
213
  .progress-container {
214
+ padding: 15px;
215
+ background-color: #f1f8e9;
216
  border-radius: 8px;
217
+ border: 1px solid #c5e1a5;
218
+ margin-bottom: 20px;
219
+ }
220
+ .output-container {
221
  padding: 15px;
222
  margin: 15px 0;
223
  background-color: #e3f2fd;
 
225
  .sidebar {
226
  background-color: #ffffff; /* Sidebar background color */
227
  padding: 1em;
228
+ max-height: 600px; /* Adjust height for scrolling */
229
+ overflow-y: auto;
230
  }
231
  .footer {
232
  background-color: #4CAF50;
 
272
 
273
  model_choice = st.selectbox("Select AI Model", ["Gemini", "OpenAI"], key="select_model")
274
 
275
+ # Updated role dropdown with scrollable feature
276
  roles = [
277
  "Software Developer", "Data Analyst", "Marketing Manager", "Project Manager", "UX Designer",
278
  "Machine Learning Engineer", "Data Scientist", "AI Researcher", "Product Manager", "Business Analyst",
 
290
  if st.button("Generate Questions", key="generate_questions"):
291
  with st.spinner("Generating questions..."):
292
  questions = generate_questions(model_choice, role, question_type, num_questions, difficulty)
293
+
294
+ # Paginate questions
295
+ if "question_index" not in st.session_state:
296
+ st.session_state.question_index = 0
297
+
298
+ if "questions" not in st.session_state:
299
+ st.session_state.questions = questions
300
+
301
+ total_questions = len(st.session_state.questions)
302
+ if total_questions > 0:
303
+ st.markdown(style_output(f"Question {st.session_state.question_index + 1} of {total_questions}:", "#4CAF50"), unsafe_allow_html=True)
304
+ st.write(st.session_state.questions[st.session_state.question_index])
305
+
306
+ col1, col2 = st.columns(2)
307
+ with col1:
308
+ if st.session_state.question_index > 0:
309
+ if st.button("Previous Question"):
310
+ st.session_state.question_index -= 1
311
+
312
+ with col2:
313
+ if st.session_state.question_index < total_questions - 1:
314
+ if st.button("Next Question"):
315
+ st.session_state.question_index += 1
316
+
317
  progress_data["questions_solved"][question_type] += num_questions
318
 
319
  st.header("🗣️ Provide Feedback")