Dannyar608 commited on
Commit
8912b3c
·
verified ·
1 Parent(s): 38fde1b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +120 -0
app.py CHANGED
@@ -263,6 +263,113 @@ def transcript_display(transcript_dict):
263
  return "\n".join([f"- {course}" for course in transcript_dict["courses"]] +
264
  [f"Grade Level: {transcript_dict['grade_level']}", f"GPA: {transcript_dict['gpa']}"])
265
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  # ========== GRADIO INTERFACE ==========
267
  with gr.Blocks() as app:
268
  with gr.Tab("Step 1: Upload Transcript"):
@@ -326,4 +433,17 @@ with gr.Blocks() as app:
326
  transcript_data, learning_output],
327
  outputs=output_summary)
328
 
 
 
 
 
 
 
 
 
 
 
 
 
 
329
  app.launch()
 
263
  return "\n".join([f"- {course}" for course in transcript_dict["courses"]] +
264
  [f"Grade Level: {transcript_dict['grade_level']}", f"GPA: {transcript_dict['gpa']}"])
265
 
266
+ # ========== AI TEACHING ASSISTANT ==========
267
+ def load_profile():
268
+ files = [f for f in os.listdir("student_profiles") if f.endswith('.json')]
269
+ if files:
270
+ with open(os.path.join("student_profiles", files[0]), "r") as f:
271
+ return json.load(f)
272
+ return {}
273
+
274
+ def generate_response(message, history):
275
+ profile = load_profile()
276
+ if not profile:
277
+ return "Please complete and save your profile first using the previous tabs."
278
+
279
+ # Get profile data
280
+ learning_style = profile.get("learning_style", "")
281
+ grade_level = profile.get("transcript", {}).get("grade_level", "unknown")
282
+ gpa = profile.get("transcript", {}).get("gpa", {})
283
+ interests = profile.get("interests", "")
284
+
285
+ # Common responses
286
+ greetings = ["hi", "hello", "hey"]
287
+ study_help = ["study", "learn", "prepare", "exam"]
288
+ grade_help = ["grade", "gpa", "score"]
289
+ interest_help = ["interest", "hobby", "passion"]
290
+
291
+ if any(greet in message.lower() for greet in greetings):
292
+ return f"Hello {profile.get('name', 'there')}! How can I help you today?"
293
+
294
+ elif any(word in message.lower() for word in study_help):
295
+ if "Visual" in learning_style:
296
+ response = ("Based on your visual learning style, I recommend:\n"
297
+ "- Creating mind maps or diagrams\n"
298
+ "- Using color-coded notes\n"
299
+ "- Watching educational videos\n"
300
+ "- Drawing concepts to understand them better")
301
+ elif "Auditory" in learning_style:
302
+ response = ("Based on your auditory learning style, I recommend:\n"
303
+ "- Recording lectures and listening to them\n"
304
+ "- Participating in study groups\n"
305
+ "- Explaining concepts out loud\n"
306
+ "- Using mnemonic devices with rhymes")
307
+ elif "Reading/Writing" in learning_style:
308
+ response = ("Based on your reading/writing learning style, I recommend:\n"
309
+ "- Writing detailed notes\n"
310
+ "- Creating summaries in your own words\n"
311
+ "- Reading textbooks and articles\n"
312
+ "- Making flashcards with written explanations")
313
+ elif "Kinesthetic" in learning_style:
314
+ response = ("Based on your kinesthetic learning style, I recommend:\n"
315
+ "- Hands-on practice\n"
316
+ "- Creating physical models\n"
317
+ "- Taking frequent movement breaks\n"
318
+ "- Using real-world applications of concepts")
319
+ else:
320
+ response = ("Here are some general study tips:\n"
321
+ "- Break study sessions into 25-minute chunks\n"
322
+ "- Review material regularly\n"
323
+ "- Teach concepts to someone else\n"
324
+ "- Practice with past exams or problems")
325
+
326
+ # Add grade-specific advice
327
+ if "9" in grade_level or "Freshman" in grade_level:
328
+ response += "\n\nAs a freshman, focus on building good study habits early."
329
+ elif "10" in grade_level or "Sophomore" in grade_level:
330
+ response += "\n\nAs a sophomore, start exploring subjects that interest you."
331
+ elif "11" in grade_level or "Junior" in grade_level:
332
+ response += "\n\nAs a junior, focus on preparing for college entrance exams."
333
+ elif "12" in grade_level or "Senior" in grade_level:
334
+ response += "\n\nAs a senior, balance college applications with maintaining your grades."
335
+
336
+ return response
337
+
338
+ elif any(word in message.lower() for word in grade_help):
339
+ return (f"Your GPA information:\n"
340
+ f"- Unweighted: {gpa.get('unweighted', 'N/A')}\n"
341
+ f"- Weighted: {gpa.get('weighted', 'N/A')}\n\n"
342
+ "To improve your grades:\n"
343
+ "- Set specific, measurable goals\n"
344
+ "- Meet with teachers to understand expectations\n"
345
+ "- Develop a consistent study schedule\n"
346
+ "- Focus on your weakest areas first")
347
+
348
+ elif any(word in message.lower() for word in interest_help):
349
+ return (f"I see you're interested in: {interests}\n\n"
350
+ "You might want to:\n"
351
+ "- Find clubs or activities related to these interests\n"
352
+ "- Explore career paths that align with them\n"
353
+ "- Connect these interests to your school subjects")
354
+
355
+ elif "help" in message.lower():
356
+ return ("I can help with:\n"
357
+ "- Study tips based on your learning style\n"
358
+ "- GPA and grade information\n"
359
+ "- Academic advice tailored to your grade level\n"
360
+ "- Connecting your interests to learning\n\n"
361
+ "Try asking about:\n"
362
+ "- How to study for your classes\n"
363
+ "- Ways to improve your grades\n"
364
+ "- How to connect your interests to school")
365
+
366
+ else:
367
+ return ("I'm your personalized teaching assistant. I can help with:\n"
368
+ "- Study strategies based on your learning style\n"
369
+ "- Understanding your academic performance\n"
370
+ "- Finding ways to connect school with your interests\n\n"
371
+ "Try asking me about study tips or your academic progress!")
372
+
373
  # ========== GRADIO INTERFACE ==========
374
  with gr.Blocks() as app:
375
  with gr.Tab("Step 1: Upload Transcript"):
 
433
  transcript_data, learning_output],
434
  outputs=output_summary)
435
 
436
+ # AI Teaching Assistant Tab
437
+ with gr.Tab("🤖 AI Teaching Assistant"):
438
+ gr.Markdown("## Your Personalized Learning Assistant")
439
+ chatbot = gr.ChatInterface(
440
+ fn=generate_response,
441
+ examples=[
442
+ "How should I study for my next test?",
443
+ "What's my GPA information?",
444
+ "How can I improve my grades?",
445
+ "How can I connect my interests to school?"
446
+ ]
447
+ )
448
+
449
  app.launch()