Dannyar608 commited on
Commit
06c2c05
Β·
verified Β·
1 Parent(s): aa96e64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -5
app.py CHANGED
@@ -143,7 +143,6 @@ Your dreams are powerful: {'; '.join(hopes) if hopes else 'You are filled with p
143
  Believe in yourself and keep moving forward.
144
  """
145
 
146
- # Save all answers into profile
147
  def save_profile(file, *inputs):
148
  if not file:
149
  return "⚠️ Please upload your transcript."
@@ -191,7 +190,6 @@ def save_profile(file, *inputs):
191
 
192
  return f"βœ… Profile saved! Your learning style is: {learning_type}"
193
 
194
- # Build Gradio UI
195
  with gr.Blocks() as demo:
196
  gr.Markdown("## πŸŽ“ Personalized AI Student Assistant")
197
 
@@ -215,15 +213,38 @@ with gr.Blocks() as demo:
215
 
216
  blog_checkbox = gr.Checkbox(label="πŸ“ I'd like to write a mini blog about myself")
217
  blog_text = gr.Textbox(lines=5, label="✍️ Mini Blog", visible=False)
218
-
219
  blog_checkbox.change(fn=lambda x: gr.update(visible=x), inputs=blog_checkbox, outputs=blog_text)
220
 
221
  submit = gr.Button("πŸ—•οΈ Save My Profile")
222
  output = gr.Textbox(label="Status")
223
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  submit.click(fn=save_profile,
225
  inputs=[file, *quiz_components, blog_checkbox, blog_text, *category_inputs],
226
- outputs=[output])
 
 
 
 
227
 
228
  if __name__ == '__main__':
229
- demo.launch()
 
 
143
  Believe in yourself and keep moving forward.
144
  """
145
 
 
146
  def save_profile(file, *inputs):
147
  if not file:
148
  return "⚠️ Please upload your transcript."
 
190
 
191
  return f"βœ… Profile saved! Your learning style is: {learning_type}"
192
 
 
193
  with gr.Blocks() as demo:
194
  gr.Markdown("## πŸŽ“ Personalized AI Student Assistant")
195
 
 
213
 
214
  blog_checkbox = gr.Checkbox(label="πŸ“ I'd like to write a mini blog about myself")
215
  blog_text = gr.Textbox(lines=5, label="✍️ Mini Blog", visible=False)
 
216
  blog_checkbox.change(fn=lambda x: gr.update(visible=x), inputs=blog_checkbox, outputs=blog_text)
217
 
218
  submit = gr.Button("πŸ—•οΈ Save My Profile")
219
  output = gr.Textbox(label="Status")
220
 
221
+ # New UI elements for summary and confirmation
222
+ summary_markdown = gr.Markdown(visible=False)
223
+ confirm_button = gr.Button("βœ… Confirm", visible=False)
224
+ edit_button = gr.Button("✏️ Edit", visible=False)
225
+
226
+ def handle_post_save(message):
227
+ with open("student_summary.md", "r") as f:
228
+ summary = f.read()
229
+ return {
230
+ output: gr.update(value=message),
231
+ summary_markdown: gr.update(value=summary, visible=True),
232
+ confirm_button: gr.update(visible=True),
233
+ edit_button: gr.update(visible=True),
234
+ file: gr.update(visible=False),
235
+ blog_checkbox: gr.update(visible=False),
236
+ blog_text: gr.update(visible=False),
237
+ **{c: gr.update(visible=False) for c in quiz_components + category_inputs}
238
+ }
239
+
240
  submit.click(fn=save_profile,
241
  inputs=[file, *quiz_components, blog_checkbox, blog_text, *category_inputs],
242
+ outputs=[output]).then(
243
+ fn=handle_post_save,
244
+ inputs=None,
245
+ outputs=[output, summary_markdown, confirm_button, edit_button, file, blog_checkbox, blog_text, *quiz_components, *category_inputs]
246
+ )
247
 
248
  if __name__ == '__main__':
249
+ demo.launch()
250
+