Dannyar608 commited on
Commit
a68c620
·
verified ·
1 Parent(s): efb4698

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -16
app.py CHANGED
@@ -177,6 +177,9 @@ def learning_style_quiz(*answers):
177
 
178
  # ========== SAVE STUDENT PROFILE FUNCTION ==========
179
  def save_profile(name, age, interests, transcript, learning_style, movie, movie_reason, show, show_reason, book, book_reason, character, character_reason, blog):
 
 
 
180
  favorites = {
181
  "movie": movie,
182
  "movie_reason": movie_reason,
@@ -222,22 +225,25 @@ def save_profile(name, age, interests, transcript, learning_style, movie, movie_
222
  def transcript_display(transcript_dict):
223
  if not transcript_dict:
224
  return "No transcript uploaded."
225
- if isinstance(transcript_dict, dict) and "courses" in transcript_dict and isinstance(transcript_dict["courses"], dict):
226
- display = ""
227
- for grade_level, courses in transcript_dict["courses"].items():
228
- display += f"\n**Grade {grade_level}**\n"
229
- for course in courses:
230
- display += f"- {course['course']}"
231
- if 'grade' in course:
232
- display += f" (Grade: {course['grade']})"
233
- display += "\n"
234
- return display
235
- elif isinstance(transcript_dict, dict) and "courses" in transcript_dict and isinstance(transcript_dict["courses"], list):
236
- return "\n".join([f"- {course}" for course in transcript_dict["courses"]])
 
237
  return "No course information available"
238
 
239
  # ========== AI TEACHING ASSISTANT ==========
240
  def load_profile():
 
 
241
  files = [f for f in os.listdir("student_profiles") if f.endswith('.json')]
242
  if files:
243
  with open(os.path.join("student_profiles", files[0]), "r") as f:
@@ -345,7 +351,7 @@ with gr.Blocks() as app:
345
 
346
  with gr.Tab("Step 3: Personal Questions"):
347
  name = gr.Textbox(label="What's your name?")
348
- age = gr.Number(label="How old are you?")
349
  interests = gr.Textbox(label="What are your interests?")
350
  movie = gr.Textbox(label="Favorite movie?")
351
  movie_reason = gr.Textbox(label="Why do you like that movie?")
@@ -386,6 +392,4 @@ with gr.Blocks() as app:
386
 
387
  if __name__ == "__main__":
388
  app.launch()
389
-
390
-
391
-
 
177
 
178
  # ========== SAVE STUDENT PROFILE FUNCTION ==========
179
  def save_profile(name, age, interests, transcript, learning_style, movie, movie_reason, show, show_reason, book, book_reason, character, character_reason, blog):
180
+ # Convert age to int if it's a numpy number (from gradio Number input)
181
+ age = int(age) if age else 0
182
+
183
  favorites = {
184
  "movie": movie,
185
  "movie_reason": movie_reason,
 
225
  def transcript_display(transcript_dict):
226
  if not transcript_dict:
227
  return "No transcript uploaded."
228
+ if isinstance(transcript_dict, dict) and "courses" in transcript_dict:
229
+ if isinstance(transcript_dict["courses"], dict):
230
+ display = ""
231
+ for grade_level, courses in transcript_dict["courses"].items():
232
+ display += f"\n**Grade {grade_level}**\n"
233
+ for course in courses:
234
+ display += f"- {course['course']}"
235
+ if 'grade' in course:
236
+ display += f" (Grade: {course['grade']})"
237
+ display += "\n"
238
+ return display
239
+ elif isinstance(transcript_dict["courses"], list):
240
+ return "\n".join([f"- {course}" for course in transcript_dict["courses"]])
241
  return "No course information available"
242
 
243
  # ========== AI TEACHING ASSISTANT ==========
244
  def load_profile():
245
+ if not os.path.exists("student_profiles"):
246
+ return {}
247
  files = [f for f in os.listdir("student_profiles") if f.endswith('.json')]
248
  if files:
249
  with open(os.path.join("student_profiles", files[0]), "r") as f:
 
351
 
352
  with gr.Tab("Step 3: Personal Questions"):
353
  name = gr.Textbox(label="What's your name?")
354
+ age = gr.Number(label="How old are you?", precision=0)
355
  interests = gr.Textbox(label="What are your interests?")
356
  movie = gr.Textbox(label="Favorite movie?")
357
  movie_reason = gr.Textbox(label="Why do you like that movie?")
 
392
 
393
  if __name__ == "__main__":
394
  app.launch()
395
+