Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -138,22 +138,7 @@ learning_style_questions = [
|
|
| 138 |
"When you need directions to a new place, you prefer:",
|
| 139 |
"When you learn a new skill, you prefer to:",
|
| 140 |
"When you're trying to concentrate, you:",
|
| 141 |
-
"When you meet new people, you remember them by:"
|
| 142 |
-
"When you're relaxing, you prefer to:",
|
| 143 |
-
"When you're explaining something to someone, you:",
|
| 144 |
-
"When you're trying to remember something, you:",
|
| 145 |
-
"When you're in a classroom, you learn best when:",
|
| 146 |
-
"When you're trying to solve a problem, you:",
|
| 147 |
-
"When you're taking notes, you:",
|
| 148 |
-
"When you're learning new software, you prefer to:",
|
| 149 |
-
"When you're at a museum, you spend the most time:",
|
| 150 |
-
"When you're assembling furniture, you:",
|
| 151 |
-
"When you're learning new vocabulary, you:",
|
| 152 |
-
"When you're giving a presentation, you prefer:",
|
| 153 |
-
"When you're at a party, you enjoy:",
|
| 154 |
-
"When you're taking a break from studying, you:",
|
| 155 |
-
"When you're learning dance moves, you:",
|
| 156 |
-
"When you're choosing a book, you prefer:"
|
| 157 |
]
|
| 158 |
|
| 159 |
learning_style_options = [
|
|
@@ -161,22 +146,7 @@ learning_style_options = [
|
|
| 161 |
["Look at a map (Visual)", "Have someone tell you (Auditory)", "Write down directions (Reading/Writing)", "Try walking/driving there (Kinesthetic)"],
|
| 162 |
["Read instructions (Reading/Writing)", "Have someone show you (Visual)", "Listen to explanations (Auditory)", "Try it yourself (Kinesthetic)"],
|
| 163 |
["Need quiet (Reading/Writing)", "Need background noise (Auditory)", "Need to move around (Kinesthetic)", "Need visual stimulation (Visual)"],
|
| 164 |
-
["Their face (Visual)", "Their name (Auditory)", "What you talked about (Reading/Writing)", "What you did together (Kinesthetic)"]
|
| 165 |
-
["Read (Reading/Writing)", "Listen to music (Auditory)", "Watch TV (Visual)", "Do something active (Kinesthetic)"],
|
| 166 |
-
["Write it down (Reading/Writing)", "Tell them verbally (Auditory)", "Show them (Visual)", "Demonstrate physically (Kinesthetic)"],
|
| 167 |
-
["See it written down (Visual)", "Say it out loud (Auditory)", "Write it down (Reading/Writing)", "Do it physically (Kinesthetic)"],
|
| 168 |
-
["Reading materials (Reading/Writing)", "Listening to lectures (Auditory)", "Seeing diagrams (Visual)", "Doing hands-on activities (Kinesthetic)"],
|
| 169 |
-
["Write down steps (Reading/Writing)", "Talk through it (Auditory)", "Draw diagrams (Visual)", "Try different approaches (Kinesthetic)"],
|
| 170 |
-
["Write detailed notes (Reading/Writing)", "Record lectures (Auditory)", "Draw mind maps (Visual)", "Take minimal notes (Kinesthetic)"],
|
| 171 |
-
["Read the manual (Reading/Writing)", "Have someone explain it (Auditory)", "Watch tutorial videos (Visual)", "Just start using it (Kinesthetic)"],
|
| 172 |
-
["Reading descriptions (Reading/Writing)", "Listening to audio guides (Auditory)", "Looking at exhibits (Visual)", "Interactive displays (Kinesthetic)"],
|
| 173 |
-
["Read instructions first (Reading/Writing)", "Ask someone to help (Auditory)", "Look at diagrams (Visual)", "Start assembling (Kinesthetic)"],
|
| 174 |
-
["Write them repeatedly (Reading/Writing)", "Say them repeatedly (Auditory)", "Use flashcards (Visual)", "Use them in conversation (Kinesthetic)"],
|
| 175 |
-
["Having detailed notes (Reading/Writing)", "Speaking freely (Auditory)", "Using visual aids (Visual)", "Demonstrating something (Kinesthetic)"],
|
| 176 |
-
["Conversations (Auditory)", "People-watching (Visual)", "Dancing/games (Kinesthetic)", "Reading about people (Reading/Writing)"],
|
| 177 |
-
["Read for fun (Reading/Writing)", "Listen to music (Auditory)", "Watch videos (Visual)", "Exercise (Kinesthetic)"],
|
| 178 |
-
["Watch demonstrations (Visual)", "Listen to instructions (Auditory)", "Read choreography (Reading/Writing)", "Try the moves (Kinesthetic)"],
|
| 179 |
-
["Text-heavy books (Reading/Writing)", "Audiobooks (Auditory)", "Books with pictures (Visual)", "Interactive books (Kinesthetic)"]
|
| 180 |
]
|
| 181 |
|
| 182 |
def learning_style_quiz(*answers):
|
|
@@ -187,36 +157,37 @@ def learning_style_quiz(*answers):
|
|
| 187 |
"Kinesthetic": 0
|
| 188 |
}
|
| 189 |
|
| 190 |
-
# Map each answer to a learning style
|
| 191 |
for i, answer in enumerate(answers):
|
| 192 |
-
if answer
|
| 193 |
scores["Reading/Writing"] += 1
|
| 194 |
-
elif answer
|
| 195 |
scores["Auditory"] += 1
|
| 196 |
-
elif answer
|
| 197 |
scores["Visual"] += 1
|
| 198 |
-
elif answer
|
| 199 |
scores["Kinesthetic"] += 1
|
| 200 |
|
| 201 |
-
# Get the highest score(s)
|
| 202 |
max_score = max(scores.values())
|
| 203 |
dominant_styles = [style for style, score in scores.items() if score == max_score]
|
| 204 |
|
| 205 |
-
# Generate result
|
| 206 |
if len(dominant_styles) == 1:
|
| 207 |
-
|
| 208 |
else:
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
# Add detailed breakdown
|
| 212 |
-
result += "\n\nDetailed Scores:\n"
|
| 213 |
-
for style, score in sorted(scores.items(), key=lambda x: x[1], reverse=True):
|
| 214 |
-
result += f"{style}: {score}/20\n"
|
| 215 |
-
|
| 216 |
-
return result
|
| 217 |
|
| 218 |
# ========== SAVE STUDENT PROFILE FUNCTION ==========
|
| 219 |
-
def save_profile(name, age, interests, transcript, learning_style,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
data = {
|
| 221 |
"name": name,
|
| 222 |
"age": age,
|
|
@@ -226,6 +197,7 @@ def save_profile(name, age, interests, transcript, learning_style, favorites, bl
|
|
| 226 |
"favorites": favorites,
|
| 227 |
"blog": blog
|
| 228 |
}
|
|
|
|
| 229 |
os.makedirs("student_profiles", exist_ok=True)
|
| 230 |
json_path = os.path.join("student_profiles", f"{name.replace(' ', '_')}_profile.json")
|
| 231 |
with open(json_path, "w") as f:
|
|
@@ -250,9 +222,9 @@ def save_profile(name, age, interests, transcript, learning_style, favorites, bl
|
|
| 250 |
def transcript_display(transcript_dict):
|
| 251 |
if not transcript_dict:
|
| 252 |
return "No transcript uploaded."
|
| 253 |
-
if isinstance(transcript_dict, dict) and
|
| 254 |
display = ""
|
| 255 |
-
for grade_level, courses in transcript_dict.items():
|
| 256 |
display += f"\n**Grade {grade_level}**\n"
|
| 257 |
for course in courses:
|
| 258 |
display += f"- {course['course']}"
|
|
@@ -260,8 +232,9 @@ def transcript_display(transcript_dict):
|
|
| 260 |
display += f" (Grade: {course['grade']})"
|
| 261 |
display += "\n"
|
| 262 |
return display
|
| 263 |
-
|
| 264 |
-
|
|
|
|
| 265 |
|
| 266 |
# ========== AI TEACHING ASSISTANT ==========
|
| 267 |
def load_profile():
|
|
@@ -296,42 +269,27 @@ def generate_response(message, history):
|
|
| 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
|
| 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
|
| 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
|
| 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
|
| 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
|
| 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 |
|
|
@@ -339,36 +297,28 @@ def generate_response(message, history):
|
|
| 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 |
-
"-
|
| 344 |
-
"-
|
| 345 |
-
"-
|
| 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
|
| 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 |
-
"-
|
| 360 |
-
"
|
| 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.
|
| 368 |
-
"
|
| 369 |
-
"
|
| 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:
|
|
@@ -379,14 +329,14 @@ with gr.Blocks() as app:
|
|
| 379 |
transcript_file.change(fn=parse_transcript, inputs=transcript_file, outputs=[transcript_output, transcript_data])
|
| 380 |
|
| 381 |
with gr.Tab("Step 2: Learning Style Quiz"):
|
| 382 |
-
gr.Markdown("###
|
| 383 |
quiz_components = []
|
| 384 |
for i, (question, options) in enumerate(zip(learning_style_questions, learning_style_options)):
|
| 385 |
quiz_components.append(
|
| 386 |
-
gr.Radio(
|
| 387 |
)
|
| 388 |
|
| 389 |
-
learning_output = gr.Textbox(label="Learning Style Result"
|
| 390 |
gr.Button("Submit Quiz").click(
|
| 391 |
learning_style_quiz,
|
| 392 |
inputs=quiz_components,
|
|
@@ -407,31 +357,19 @@ with gr.Blocks() as app:
|
|
| 407 |
character_reason = gr.Textbox(label="Why do you like that character?")
|
| 408 |
blog_checkbox = gr.Checkbox(label="Do you want to write a blog?", value=False)
|
| 409 |
blog_text = gr.Textbox(label="Write your blog here", visible=False, lines=5)
|
| 410 |
-
blog_checkbox.change(
|
| 411 |
|
| 412 |
with gr.Tab("Step 4: Save & Review"):
|
| 413 |
output_summary = gr.Markdown()
|
| 414 |
save_btn = gr.Button("Save Profile")
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
"book": book,
|
| 424 |
-
"book_reason": book_reason,
|
| 425 |
-
"character": character,
|
| 426 |
-
"character_reason": character_reason,
|
| 427 |
-
}
|
| 428 |
-
return save_profile(name, age, interests, transcript, learning_style, favorites, blog)
|
| 429 |
-
|
| 430 |
-
save_btn.click(fn=gather_and_save,
|
| 431 |
-
inputs=[name, age, interests, movie, movie_reason, show, show_reason,
|
| 432 |
-
book, book_reason, character, character_reason, blog_text,
|
| 433 |
-
transcript_data, learning_output],
|
| 434 |
-
outputs=output_summary)
|
| 435 |
|
| 436 |
# AI Teaching Assistant Tab
|
| 437 |
with gr.Tab("🤖 AI Teaching Assistant"):
|
|
@@ -441,9 +379,13 @@ with gr.Blocks() as app:
|
|
| 441 |
examples=[
|
| 442 |
"How should I study for my next test?",
|
| 443 |
"What's my GPA information?",
|
| 444 |
-
"
|
| 445 |
-
"How can I
|
| 446 |
]
|
| 447 |
)
|
| 448 |
|
| 449 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
"When you need directions to a new place, you prefer:",
|
| 139 |
"When you learn a new skill, you prefer to:",
|
| 140 |
"When you're trying to concentrate, you:",
|
| 141 |
+
"When you meet new people, you remember them by:"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
]
|
| 143 |
|
| 144 |
learning_style_options = [
|
|
|
|
| 146 |
["Look at a map (Visual)", "Have someone tell you (Auditory)", "Write down directions (Reading/Writing)", "Try walking/driving there (Kinesthetic)"],
|
| 147 |
["Read instructions (Reading/Writing)", "Have someone show you (Visual)", "Listen to explanations (Auditory)", "Try it yourself (Kinesthetic)"],
|
| 148 |
["Need quiet (Reading/Writing)", "Need background noise (Auditory)", "Need to move around (Kinesthetic)", "Need visual stimulation (Visual)"],
|
| 149 |
+
["Their face (Visual)", "Their name (Auditory)", "What you talked about (Reading/Writing)", "What you did together (Kinesthetic)"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
]
|
| 151 |
|
| 152 |
def learning_style_quiz(*answers):
|
|
|
|
| 157 |
"Kinesthetic": 0
|
| 158 |
}
|
| 159 |
|
|
|
|
| 160 |
for i, answer in enumerate(answers):
|
| 161 |
+
if answer == learning_style_options[i][0]:
|
| 162 |
scores["Reading/Writing"] += 1
|
| 163 |
+
elif answer == learning_style_options[i][1]:
|
| 164 |
scores["Auditory"] += 1
|
| 165 |
+
elif answer == learning_style_options[i][2]:
|
| 166 |
scores["Visual"] += 1
|
| 167 |
+
elif answer == learning_style_options[i][3]:
|
| 168 |
scores["Kinesthetic"] += 1
|
| 169 |
|
|
|
|
| 170 |
max_score = max(scores.values())
|
| 171 |
dominant_styles = [style for style, score in scores.items() if score == max_score]
|
| 172 |
|
|
|
|
| 173 |
if len(dominant_styles) == 1:
|
| 174 |
+
return f"Your primary learning style is: {dominant_styles[0]}"
|
| 175 |
else:
|
| 176 |
+
return f"You have multiple strong learning styles: {', '.join(dominant_styles)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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,
|
| 183 |
+
"show": show,
|
| 184 |
+
"show_reason": show_reason,
|
| 185 |
+
"book": book,
|
| 186 |
+
"book_reason": book_reason,
|
| 187 |
+
"character": character,
|
| 188 |
+
"character_reason": character_reason
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
data = {
|
| 192 |
"name": name,
|
| 193 |
"age": age,
|
|
|
|
| 197 |
"favorites": favorites,
|
| 198 |
"blog": blog
|
| 199 |
}
|
| 200 |
+
|
| 201 |
os.makedirs("student_profiles", exist_ok=True)
|
| 202 |
json_path = os.path.join("student_profiles", f"{name.replace(' ', '_')}_profile.json")
|
| 203 |
with open(json_path, "w") as f:
|
|
|
|
| 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']}"
|
|
|
|
| 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():
|
|
|
|
| 269 |
response = ("Based on your visual learning style, I recommend:\n"
|
| 270 |
"- Creating mind maps or diagrams\n"
|
| 271 |
"- Using color-coded notes\n"
|
| 272 |
+
"- Watching educational videos")
|
|
|
|
| 273 |
elif "Auditory" in learning_style:
|
| 274 |
response = ("Based on your auditory learning style, I recommend:\n"
|
| 275 |
"- Recording lectures and listening to them\n"
|
| 276 |
"- Participating in study groups\n"
|
| 277 |
+
"- Explaining concepts out loud")
|
|
|
|
| 278 |
elif "Reading/Writing" in learning_style:
|
| 279 |
response = ("Based on your reading/writing learning style, I recommend:\n"
|
| 280 |
"- Writing detailed notes\n"
|
| 281 |
"- Creating summaries in your own words\n"
|
| 282 |
+
"- Reading textbooks and articles")
|
|
|
|
| 283 |
elif "Kinesthetic" in learning_style:
|
| 284 |
response = ("Based on your kinesthetic learning style, I recommend:\n"
|
| 285 |
"- Hands-on practice\n"
|
| 286 |
"- Creating physical models\n"
|
| 287 |
+
"- Taking frequent movement breaks")
|
|
|
|
| 288 |
else:
|
| 289 |
response = ("Here are some general study tips:\n"
|
| 290 |
"- Break study sessions into 25-minute chunks\n"
|
| 291 |
"- Review material regularly\n"
|
| 292 |
+
"- Teach concepts to someone else")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
|
| 294 |
return response
|
| 295 |
|
|
|
|
| 297 |
return (f"Your GPA information:\n"
|
| 298 |
f"- Unweighted: {gpa.get('unweighted', 'N/A')}\n"
|
| 299 |
f"- Weighted: {gpa.get('weighted', 'N/A')}\n\n"
|
| 300 |
+
"To improve your grades, try:\n"
|
| 301 |
+
"- Setting specific goals\n"
|
| 302 |
+
"- Meeting with teachers\n"
|
| 303 |
+
"- Developing a study schedule")
|
|
|
|
| 304 |
|
| 305 |
elif any(word in message.lower() for word in interest_help):
|
| 306 |
return (f"I see you're interested in: {interests}\n\n"
|
| 307 |
"You might want to:\n"
|
| 308 |
"- Find clubs or activities related to these interests\n"
|
| 309 |
+
"- Explore career paths that align with them")
|
|
|
|
| 310 |
|
| 311 |
elif "help" in message.lower():
|
| 312 |
return ("I can help with:\n"
|
| 313 |
"- Study tips based on your learning style\n"
|
| 314 |
"- GPA and grade information\n"
|
| 315 |
+
"- General academic advice\n\n"
|
| 316 |
+
"Try asking about study strategies or your grades!")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
|
| 318 |
else:
|
| 319 |
+
return ("I'm your personalized teaching assistant. "
|
| 320 |
+
"I can help with study tips, grade information, and academic advice. "
|
| 321 |
+
"Try asking about how to study for your classes!")
|
|
|
|
|
|
|
| 322 |
|
| 323 |
# ========== GRADIO INTERFACE ==========
|
| 324 |
with gr.Blocks() as app:
|
|
|
|
| 329 |
transcript_file.change(fn=parse_transcript, inputs=transcript_file, outputs=[transcript_output, transcript_data])
|
| 330 |
|
| 331 |
with gr.Tab("Step 2: Learning Style Quiz"):
|
| 332 |
+
gr.Markdown("### Learning Style Quiz")
|
| 333 |
quiz_components = []
|
| 334 |
for i, (question, options) in enumerate(zip(learning_style_questions, learning_style_options)):
|
| 335 |
quiz_components.append(
|
| 336 |
+
gr.Radio(options, label=f"{i+1}. {question}")
|
| 337 |
)
|
| 338 |
|
| 339 |
+
learning_output = gr.Textbox(label="Learning Style Result")
|
| 340 |
gr.Button("Submit Quiz").click(
|
| 341 |
learning_style_quiz,
|
| 342 |
inputs=quiz_components,
|
|
|
|
| 357 |
character_reason = gr.Textbox(label="Why do you like that character?")
|
| 358 |
blog_checkbox = gr.Checkbox(label="Do you want to write a blog?", value=False)
|
| 359 |
blog_text = gr.Textbox(label="Write your blog here", visible=False, lines=5)
|
| 360 |
+
blog_checkbox.change(lambda x: gr.update(visible=x), inputs=blog_checkbox, outputs=blog_text)
|
| 361 |
|
| 362 |
with gr.Tab("Step 4: Save & Review"):
|
| 363 |
output_summary = gr.Markdown()
|
| 364 |
save_btn = gr.Button("Save Profile")
|
| 365 |
+
|
| 366 |
+
save_btn.click(
|
| 367 |
+
fn=save_profile,
|
| 368 |
+
inputs=[name, age, interests, transcript_data, learning_output,
|
| 369 |
+
movie, movie_reason, show, show_reason,
|
| 370 |
+
book, book_reason, character, character_reason, blog_text],
|
| 371 |
+
outputs=output_summary
|
| 372 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 373 |
|
| 374 |
# AI Teaching Assistant Tab
|
| 375 |
with gr.Tab("🤖 AI Teaching Assistant"):
|
|
|
|
| 379 |
examples=[
|
| 380 |
"How should I study for my next test?",
|
| 381 |
"What's my GPA information?",
|
| 382 |
+
"Help me with study strategies",
|
| 383 |
+
"How can I improve my grades?"
|
| 384 |
]
|
| 385 |
)
|
| 386 |
|
| 387 |
+
if __name__ == "__main__":
|
| 388 |
+
app.launch()
|
| 389 |
+
|
| 390 |
+
|
| 391 |
+
|