Sa-m commited on
Commit
1b64a38
·
verified ·
1 Parent(s): 5cc8366

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -89
app.py CHANGED
@@ -200,98 +200,72 @@ with gr.Blocks(title="PrepGenie - Mock Interviewer") as demo:
200
  elem_id="title"
201
  )
202
 
203
- # --- Main App Sections ---
204
- with gr.Column(visible=True) as main_app:
205
- with gr.Row():
206
- with gr.Column(scale=1):
207
- # Remove logout button
208
- # logout_btn = gr.Button("Logout")
209
- with gr.Column(scale=4):
210
- welcome_display = gr.Markdown("### Welcome, User!")
211
- with gr.Row():
212
- with gr.Column(scale=1):
213
- # Remove login/signup buttons
214
- # interview_btn = gr.Button("Mock Interview")
215
- # if CHAT_MODULE_AVAILABLE:
216
- # chat_btn = gr.Button("Chat with Resume")
217
- # else:
218
- # chat_btn = gr.Button("Chat with Resume (Unavailable)", interactive=False)
219
- # history_btn = gr.Button("My Interview History")
220
-
221
- # Replace with direct buttons
222
- mock_interview_btn = gr.Button("Mock Interview")
223
- if CHAT_MODULE_AVAILABLE:
224
- chat_btn = gr.Button("Chat with Resume")
225
- else:
226
- chat_btn = gr.Button("Chat with Resume (Unavailable)", interactive=False)
227
- history_btn = gr.Button("My Interview History")
228
-
229
- with gr.Column(scale=4):
230
- # --- Interview Section ---
231
- with gr.Column(visible=False) as interview_selection:
232
- gr.Markdown("## Mock Interview")
 
 
 
 
 
 
 
 
 
 
 
233
  with gr.Row():
234
  with gr.Column():
235
- file_upload_interview = gr.File(label="Upload Resume (PDF)", file_types=[".pdf"])
236
- process_btn_interview = gr.Button("Process Resume")
237
  with gr.Column():
238
- file_status_interview = gr.Textbox(label="Status", interactive=False)
239
- role_selection = gr.Dropdown(
240
- choices=["Data Scientist", "Software Engineer", "Product Manager", "Data Analyst", "Business Analyst"],
241
- multiselect=True, label="Select Job Role(s)", visible=False
242
- )
243
- start_interview_btn = gr.Button("Start Interview", visible=False)
244
- question_display = gr.Textbox(label="Question", interactive=False, visible=False)
245
- answer_instructions = gr.Markdown("Click 'Record Answer' and speak your response.", visible=False)
246
- audio_input = gr.Audio(label="Record Answer", type="numpy", visible=False)
247
- submit_answer_btn = gr.Button("Submit Answer", visible=False)
248
- next_question_btn = gr.Button("Next Question", visible=False)
249
- submit_interview_btn = gr.Button("Submit Interview", visible=False, variant="primary")
250
- answer_display = gr.Textbox(label="Your Answer", interactive=False, visible=False)
251
- feedback_display = gr.Textbox(label="Feedback", interactive=False, visible=False)
252
- metrics_display = gr.JSON(label="Metrics", visible=False)
253
- processed_resume_data_hidden_interview = gr.Textbox(visible=False)
254
- # --- Evaluation Results Section ---
255
- with gr.Column(visible=False) as evaluation_selection:
256
- gr.Markdown("## Interview Evaluation Results")
257
- evaluation_report_display = gr.Markdown(label="Your Evaluation Report", visible=False)
258
- evaluation_chart_display = gr.Image(label="Skills Breakdown", type="pil", visible=False)
259
-
260
- # --- Chat Section ---
261
- if CHAT_MODULE_AVAILABLE:
262
- with gr.Column(visible=False) as chat_selection:
263
- gr.Markdown("## Chat with Resume")
264
- with gr.Row():
265
- with gr.Column():
266
- file_upload_chat = gr.File(label="Upload Resume (PDF)", file_types=[".pdf"])
267
- process_chat_btn = gr.Button("Process Resume")
268
- with gr.Column():
269
- file_status_chat = gr.Textbox(label="Status", interactive=False)
270
- chatbot = gr.Chatbot(label="Chat History", visible=False, type="messages")
271
- query_input = gr.Textbox(label="Ask about your resume", placeholder="Type your question here...", visible=False)
272
- send_btn = gr.Button("Send", visible=False)
273
- else:
274
- with gr.Column(visible=False) as chat_selection:
275
- gr.Markdown("## Chat with Resume (Unavailable)")
276
- gr.Textbox(value="Chat module is not available.", interactive=False)
277
-
278
- # --- History Section ---
279
- with gr.Column(visible=False) as history_selection:
280
- gr.Markdown("## Your Interview History")
281
- # Use the new history_state to load past interviews
282
- load_history_btn = gr.Button("Load My Past Interviews")
283
- history_output = gr.Textbox(label="Past Interviews", max_lines=30, interactive=False, visible=True)
284
-
285
- # Assign view variables for navigation
286
- interview_view = interview_selection
287
- chat_view = chat_selection
288
- history_view = history_selection
289
-
290
- # Navigation button listeners
291
- mock_interview_btn.click(fn=navigate_to_interview, inputs=None, outputs=[interview_view, chat_view, history_view])
292
- if CHAT_MODULE_AVAILABLE:
293
- chat_btn.click(fn=navigate_to_chat, inputs=None, outputs=[interview_view, chat_view, history_view])
294
- history_btn.click(fn=navigate_to_history, inputs=None, outputs=[interview_view, chat_view, history_view])
295
 
296
  # --- Event Listeners for Interview ---
297
  process_btn_interview.click(
 
200
  elem_id="title"
201
  )
202
 
203
+ # --- Main App Sections ---
204
+ with gr.Column(visible=False) as main_app:
205
+ with gr.Row():
206
+ with gr.Column(scale=1):
207
+ logout_btn = gr.Button("Logout")
208
+ # This column needs content indented inside it
209
+ with gr.Column(scale=4):
210
+ # --- Interview Section ---
211
+ with gr.Column(visible=False) as interview_selection:
212
+ gr.Markdown("## Mock Interview")
213
+ with gr.Row():
214
+ with gr.Column():
215
+ file_upload_interview = gr.File(label="Upload Resume (PDF)", file_types=[".pdf"])
216
+ process_btn_interview = gr.Button("Process Resume")
217
+ with gr.Column():
218
+ file_status_interview = gr.Textbox(label="Status", interactive=False)
219
+ role_selection = gr.Dropdown(
220
+ choices=["Data Scientist", "Software Engineer", "Product Manager", "Data Analyst", "Business Analyst"],
221
+ multiselect=True, label="Select Job Role(s)", visible=False
222
+ )
223
+ start_interview_btn = gr.Button("Start Interview", visible=False)
224
+ question_display = gr.Textbox(label="Question", interactive=False, visible=False)
225
+ answer_instructions = gr.Markdown("Click 'Record Answer' and speak your response.", visible=False)
226
+ audio_input = gr.Audio(label="Record Answer", type="numpy", visible=False)
227
+ submit_answer_btn = gr.Button("Submit Answer", visible=False)
228
+ next_question_btn = gr.Button("Next Question", visible=False)
229
+ submit_interview_btn = gr.Button("Submit Interview", visible=False, variant="primary")
230
+ answer_display = gr.Textbox(label="Your Answer", interactive=False, visible=False)
231
+ feedback_display = gr.Textbox(label="Feedback", interactive=False, visible=False)
232
+ metrics_display = gr.JSON(label="Metrics", visible=False)
233
+ processed_resume_data_hidden_interview = gr.Textbox(visible=False)
234
+ # --- Evaluation Results Section ---
235
+ with gr.Column(visible=False) as evaluation_selection:
236
+ gr.Markdown("## Interview Evaluation Results")
237
+ evaluation_report_display = gr.Markdown(label="Your Evaluation Report", visible=False)
238
+ evaluation_chart_display = gr.Image(label="Skills Breakdown", type="pil", visible=False)
239
+
240
+ # --- Chat Section ---
241
+ if CHAT_MODULE_AVAILABLE:
242
+ with gr.Column(visible=False) as chat_selection:
243
+ gr.Markdown("## Chat with Resume")
244
  with gr.Row():
245
  with gr.Column():
246
+ file_upload_chat = gr.File(label="Upload Resume (PDF)", file_types=[".pdf"])
247
+ process_chat_btn = gr.Button("Process Resume")
248
  with gr.Column():
249
+ file_status_chat = gr.Textbox(label="Status", interactive=False)
250
+ chatbot = gr.Chatbot(label="Chat History", visible=False, type="messages")
251
+ query_input = gr.Textbox(label="Ask about your resume", placeholder="Type your question here...", visible=False)
252
+ send_btn = gr.Button("Send", visible=False)
253
+ else:
254
+ with gr.Column(visible=False) as chat_selection:
255
+ gr.Markdown("## Chat with Resume (Unavailable)")
256
+ gr.Textbox(value="Chat module is not available.", interactive=False)
257
+
258
+ # --- History Section ---
259
+ with gr.Column(visible=False) as history_selection:
260
+ gr.Markdown("## Your Interview History")
261
+ load_history_btn = gr.Button("Load My Past Interviews")
262
+ history_output = gr.Textbox(label="Past Interviews", max_lines=30, interactive=False, visible=True)
263
+
264
+ # Navigation button listeners (these should be inside the main_app column)
265
+ interview_btn.click(fn=navigate_to_interview, inputs=None, outputs=[interview_view, chat_view, history_view])
266
+ if CHAT_MODULE_AVAILABLE:
267
+ chat_btn.click(fn=navigate_to_chat, inputs=None, outputs=[interview_view, chat_view, history_view])
268
+ history_btn.click(fn=navigate_to_history, inputs=None, outputs=[interview_view, chat_view, history_view])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
 
270
  # --- Event Listeners for Interview ---
271
  process_btn_interview.click(