File size: 69,850 Bytes
a4ebbbf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99ebc67
a4ebbbf
 
 
 
 
 
 
 
 
 
 
 
e8282b4
a4ebbbf
 
e8282b4
a4ebbbf
 
 
 
 
 
99ebc67
 
a4ebbbf
99ebc67
a4ebbbf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8282b4
14f98db
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
 
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
 
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
 
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
 
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
 
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
14f98db
 
 
 
 
ee3a763
 
4968617
3615f62
4968617
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d0e3fb3
 
4968617
 
 
 
 
 
 
 
3615f62
4968617
 
 
 
 
 
3615f62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4968617
 
 
 
 
d0e3fb3
6ce9877
3615f62
 
4968617
 
3615f62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4968617
3615f62
4968617
 
3615f62
 
 
4968617
3615f62
 
4968617
 
 
3615f62
4968617
3615f62
 
 
 
 
 
 
 
 
4968617
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3615f62
4968617
 
 
 
3615f62
4968617
 
 
 
 
 
 
3615f62
 
4968617
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a62c95
 
4968617
3a62c95
4968617
3a62c95
 
 
 
 
4968617
 
 
 
 
 
 
 
 
 
3a62c95
4968617
 
 
 
 
 
 
414a8e5
4968617
414a8e5
4968617
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a62c95
4968617
 
 
 
 
 
 
 
 
 
 
2838aaa
 
 
4968617
2838aaa
 
 
 
 
 
 
 
 
 
 
3a62c95
4968617
2838aaa
 
4968617
2838aaa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4968617
2838aaa
 
 
 
4968617
2838aaa
 
 
4968617
2838aaa
 
414a8e5
4968617
2838aaa
 
 
4968617
2838aaa
 
 
4968617
2838aaa
 
 
4968617
2838aaa
4968617
2838aaa
4968617
2838aaa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4968617
2838aaa
 
4968617
 
2838aaa
 
 
 
 
 
 
4968617
2838aaa
 
 
 
4968617
2838aaa
 
4968617
 
2838aaa
4968617
2838aaa
 
3615f62
2838aaa
 
3615f62
2838aaa
 
 
 
3615f62
2838aaa
 
3a62c95
3615f62
 
 
 
 
 
 
 
 
414a8e5
 
 
 
 
3615f62
 
 
 
 
 
 
 
 
 
 
 
 
414a8e5
 
 
 
 
3615f62
 
 
20b6588
8031781
 
20b6588
 
 
260fa6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f5ddeca
 
260fa6e
 
 
 
 
 
 
 
 
 
 
 
 
 
f5ddeca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260fa6e
f5ddeca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260fa6e
 
 
 
 
 
 
20b6588
260fa6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20b6588
260fa6e
20b6588
 
260fa6e
20b6588
260fa6e
 
 
20b6588
 
 
260fa6e
 
 
 
 
 
20b6588
 
260fa6e
20b6588
 
260fa6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20b6588
260fa6e
 
 
 
20b6588
260fa6e
 
 
 
20b6588
260fa6e
 
 
 
 
20b6588
 
 
 
260fa6e
 
 
 
 
20b6588
 
 
260fa6e
 
 
 
 
 
 
 
 
 
 
20b6588
 
 
 
260fa6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f5ddeca
260fa6e
 
f5ddeca
 
 
 
260fa6e
f5ddeca
 
 
 
 
 
 
 
 
 
 
902a263
f5ddeca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260fa6e
20b6588
 
 
f8de84c
4968617
260fa6e
b3d49bc
 
 
 
4968617
 
 
b3d49bc
4968617
 
b3d49bc
 
 
 
 
4968617
 
 
 
 
 
b3d49bc
4968617
b3d49bc
 
4968617
 
b3d49bc
4968617
b3d49bc
 
4968617
 
b3d49bc
4968617
 
 
 
 
 
 
 
 
b3d49bc
4968617
 
 
b3d49bc
4968617
b3bf13e
b3d49bc
 
4968617
 
 
 
 
 
 
 
b3d49bc
4968617
 
 
b3d49bc
b3bf13e
b3d49bc
 
4968617
 
 
 
b3bf13e
b3d49bc
 
4968617
 
 
b3d49bc
4968617
b3d49bc
 
 
 
 
4968617
 
 
 
 
b3d49bc
4968617
b3bf13e
b3d49bc
 
4968617
 
 
b3d49bc
4968617
b3d49bc
 
 
 
 
4968617
 
 
 
 
b3d49bc
4968617
b3bf13e
b3d49bc
 
3123f90
b3d49bc
 
4968617
b3d49bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4968617
260fa6e
451c62f
4968617
260fa6e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
import gradio as gr
import os
import json
import uuid
from datetime import datetime
from groq import Groq

# Set up Groq API key
GROQ_API_KEY = os.environ.get("GROQ_API_KEY")
if not GROQ_API_KEY:
    raise ValueError("GROQ_API_KEY environment variable not set.")

client = Groq(api_key=GROQ_API_KEY)

# Default system prompt
SYSTEM_PROMPT = (
    "You are an intelligent, friendly, and highly adaptable Teaching Assistant Chatbot. "
    "Your mission is to help users of all ages and skill levels—from complete beginners to seasoned professionals—learn Python, Data Science, and Artificial Intelligence. "
    "You explain concepts clearly using real-world analogies, examples, and interactive exercises. "
    "You ask questions to assess the learner's level, adapt accordingly, and provide learning paths tailored to their pace and goals. "
    "Your responses are structured, engaging, and supportive. "
    "You can explain code snippets, generate exercises and quizzes, and recommend projects. "
    "You never overwhelm users with jargon. Instead, you scaffold complex concepts in simple, digestible steps."
)

# Define learning paths
LEARNING_PATHS = {
    "python_beginner": {
        "title": "Python Fundamentals",
        "description": "Learn Python basics from variables to functions",
        "modules": [
            "Variables & Data Types", 
            "Control Flow", 
            "Functions", 
            "Data Structures", 
            "File I/O"
        ]
    },
    "python_intermediate": {
        "title": "Intermediate Python",
        "description": "Advance your Python skills with OOP and more",
        "modules": [
            "Object-Oriented Programming", 
            "Modules & Packages", 
            "Error Handling", 
            "List Comprehensions", 
            "Decorators & Generators"
        ]
    },
    "data_science_beginner": {
        "title": "Data Science Foundations",
        "description": "Begin your data science journey",
        "modules": [
            "Numpy Basics", 
            "Pandas Fundamentals", 
            "Data Visualization", 
            "Basic Statistics", 
            "Intro to Machine Learning"
        ]
    },
    "data_science_advanced": {
        "title": "Advanced Data Science",
        "description": "Master complex data science concepts",
        "modules": [
            "Advanced ML Algorithms", 
            "Feature Engineering", 
            "Time Series Analysis", 
            "Natural Language Processing", 
            "Deep Learning Basics"
        ]
    },
    "ai_specialization": {
        "title": "AI Specialization",
        "description": "Focus on artificial intelligence concepts",
        "modules": [
            "Neural Networks", 
            "Computer Vision", 
            "Advanced NLP", 
            "Reinforcement Learning", 
            "AI Ethics"
        ]
    },
    "generative_ai": {
        "title": "Generative AI",
        "description": "Learn how to build and work with generative AI systems",
        "modules": [
            "Generative Models Overview", 
            "GANs & Diffusion Models", 
            "Large Language Models", 
            "Prompt Engineering", 
            "Fine-tuning & RLHF"
        ]
    },
    "agentic_ai": {
        "title": "Agentic AI Systems",
        "description": "Explore AI systems that can act autonomously",
        "modules": [
            "Foundations of AI Agents", 
            "Planning & Decision Making", 
            "Tool-using AI Systems", 
            "Multi-agent Architectures", 
            "Human-AI Collaboration"
        ]
    }
}

# Learning resources organized by learning style
LEARNING_RESOURCES = {
    "Visual": {
        "python_beginner": [
            {"title": "Python Crash Course Visual Guide", "url": "https://nostarch.com/pythoncrashcourse2e"},
            {"title": "Video Course: Python for Everybody", "url": "https://www.py4e.com/"},
            {"title": "Python Visualizations and Infographics", "url": "https://python-graph-gallery.com/"},
            {"title": "Visual Studio Code Python Tutorial", "url": "https://code.visualstudio.com/docs/python/python-tutorial"}
        ],
        "python_intermediate": [
            {"title": "Fluent Python with Visual Examples", "url": "https://www.oreilly.com/library/view/fluent-python-2nd/9781492056348/"},
            {"title": "Python Design Patterns Visualized", "url": "https://refactoring.guru/design-patterns/python"},
            {"title": "Interactive Python Visualizer", "url": "https://pythontutor.com/"},
            {"title": "Visual Guide to Python Testing", "url": "https://pragprog.com/titles/bopytest/python-testing-with-pytest/"}
        ],
        "data_science_beginner": [
            {"title": "Data Visualization with Python and Seaborn", "url": "https://seaborn.pydata.org/tutorial.html"},
            {"title": "Kaggle Learn: Data Visualization", "url": "https://www.kaggle.com/learn/data-visualization"},
            {"title": "DataCamp Python Data Visualization", "url": "https://www.datacamp.com/courses/introduction-to-data-visualization-with-python"},
            {"title": "Plotly Python Graphing Library", "url": "https://plotly.com/python/"}
        ],
        "data_science_advanced": [
            {"title": "Visualization in Machine Learning", "url": "https://machinelearningmastery.com/data-visualization-for-machine-learning/"},
            {"title": "Visual Hands-On Machine Learning", "url": "https://www.oreilly.com/library/view/hands-on-machine-learning/9781492032632/"},
            {"title": "Stanford ML: Visual Guide to Neural Networks", "url": "https://see.stanford.edu/Course/CS229"},
            {"title": "Animated ML Algorithm Visualizations", "url": "https://www.youtube.com/c/3blue1brown"}
        ],
        "ai_specialization": [
            {"title": "DeepLearning.AI Video Courses", "url": "https://www.deeplearning.ai/"},
            {"title": "TensorFlow Playground", "url": "https://playground.tensorflow.org/"},
            {"title": "Visual Guide to Neural Networks", "url": "https://pytorch.org/tutorials/"},
            {"title": "GANs Explained Visually", "url": "https://poloclub.github.io/ganlab/"}
        ],
        "generative_ai": [
            {"title": "Visualizing Large Language Models", "url": "https://karpathy.ai/zero-to-hero.html"},
            {"title": "Diffusion Models Visual Guide", "url": "https://huggingface.co/learn/diffusion-models/"},
            {"title": "Visual Prompt Engineering Guide", "url": "https://www.promptingguide.ai/"},
            {"title": "Stable Diffusion Visual Tutorial", "url": "https://stability.ai/learn"}
        ],
        "agentic_ai": [
            {"title": "Visual Guide to LangChain", "url": "https://python.langchain.com/docs/get_started/introduction"},
            {"title": "Illustrated AutoGen Guide", "url": "https://microsoft.github.io/autogen/"},
            {"title": "Visual Multi-Agent Simulations", "url": "https://www.anthropic.com/research/debate"},
            {"title": "Animated Reinforcement Learning", "url": "https://rail.eecs.berkeley.edu/deeprlcourse/"}
        ]
    },
    "Reading/Writing": {
        "python_beginner": [
            {"title": "Python Documentation", "url": "https://docs.python.org/3/"},
            {"title": "Real Python Text Tutorials", "url": "https://realpython.com/"},
            {"title": "Automate the Boring Stuff with Python", "url": "https://automatetheboringstuff.com/"},
            {"title": "Think Python (Free eBook)", "url": "https://greenteapress.com/wp/think-python-2e/"}
        ],
        "python_intermediate": [
            {"title": "Fluent Python (Book)", "url": "https://www.oreilly.com/library/view/fluent-python-2nd/9781492056348/"},
            {"title": "Effective Python (Book)", "url": "https://effectivepython.com/"},
            {"title": "Python Cookbook (Book)", "url": "https://www.oreilly.com/library/view/python-cookbook-3rd/9781449357337/"},
            {"title": "Full Stack Python (Text Tutorials)", "url": "https://www.fullstackpython.com/"}
        ],
        "data_science_beginner": [
            {"title": "Python Data Science Handbook", "url": "https://jakevdp.github.io/PythonDataScienceHandbook/"},
            {"title": "Towards Data Science (Articles)", "url": "https://towardsdatascience.com/"},
            {"title": "Introduction to Statistical Learning", "url": "https://www.statlearning.com/"},
            {"title": "Data Science from Scratch (Book)", "url": "https://www.oreilly.com/library/view/data-science-from/9781492041122/"}
        ],
        "data_science_advanced": [
            {"title": "Machine Learning Mastery (Text Tutorials)", "url": "https://machinelearningmastery.com/"},
            {"title": "Deep Learning Book", "url": "https://www.deeplearningbook.org/"},
            {"title": "Elements of Statistical Learning", "url": "https://web.stanford.edu/~hastie/ElemStatLearn/"},
            {"title": "Dive into Deep Learning", "url": "https://d2l.ai/"}
        ],
        "ai_specialization": [
            {"title": "Artificial Intelligence: A Modern Approach", "url": "http://aima.cs.berkeley.edu/"},
            {"title": "Deep Learning (Book)", "url": "https://www.deeplearningbook.org/"},
            {"title": "Stanford ML Course Notes", "url": "https://see.stanford.edu/Course/CS229"},
            {"title": "ArXiv Machine Learning Papers", "url": "https://arxiv.org/list/cs.LG/recent"}
        ],
        "generative_ai": [
            {"title": "LLM Introduction Paper", "url": "https://arxiv.org/abs/2303.18223"},
            {"title": "Generative AI Guide (eBook)", "url": "https://www.oreilly.com/library/view/generative-deep-learning/9781492041931/"},
            {"title": "Prompt Engineering Guide", "url": "https://www.promptingguide.ai/"},
            {"title": "Stanford CS324: LLM Course Notes", "url": "https://stanford-cs324.github.io/winter2022/"}
        ],
        "agentic_ai": [
            {"title": "LangChain Documentation", "url": "https://python.langchain.com/docs/get_started/introduction"},
            {"title": "Agentic AI Papers Collection", "url": "https://arxiv.org/abs/2304.03442"},
            {"title": "Multi-Agent Debate Research", "url": "https://www.anthropic.com/research/debate"},
            {"title": "Reinforcement Learning: An Introduction", "url": "http://incompleteideas.net/book/the-book-2nd.html"}
        ]
    },
    "Hands-on Projects": {
        "python_beginner": [
            {"title": "Project-Based Python Tutorial", "url": "https://projectbasedpython.com/"},
            {"title": "Exercism: Python Track", "url": "https://exercism.org/tracks/python"},
            {"title": "Python Project Ideas with Code", "url": "https://github.com/topics/python-projects"},
            {"title": "Build 5 Mini Python Projects", "url": "https://www.freecodecamp.org/news/python-projects-for-beginners/"}
        ],
        "python_intermediate": [
            {"title": "Django Project Tutorial", "url": "https://docs.djangoproject.com/en/stable/intro/tutorial01/"},
            {"title": "Flask Mega-Tutorial", "url": "https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world"},
            {"title": "Python Project Cookbook", "url": "https://pythonprojectcookbook.com/"},
            {"title": "Real-world Python Projects", "url": "https://realpython.com/tutorials/projects/"}
        ],
        "data_science_beginner": [
            {"title": "Kaggle: Intro to Machine Learning", "url": "https://www.kaggle.com/learn/intro-to-machine-learning"},
            {"title": "Data Science Projects with Python", "url": "https://github.com/PacktPublishing/Data-Science-Projects-with-Python"},
            {"title": "DataCamp Projects", "url": "https://www.datacamp.com/projects"},
            {"title": "Practical Data Analysis Projects", "url": "https://www.dataquest.io/data-science-projects/"}
        ],
        "data_science_advanced": [
            {"title": "Applied Machine Learning Projects", "url": "https://github.com/practical-tutorials/project-based-learning#python"},
            {"title": "Kaggle Competitions", "url": "https://www.kaggle.com/competitions"},
            {"title": "Building ML Pipelines", "url": "https://www.oreilly.com/library/view/building-machine-learning/9781492053187/"},
            {"title": "ML Project Walkthroughs", "url": "https://machinelearningmastery.com/start-here/#projects"}
        ],
        "ai_specialization": [
            {"title": "TensorFlow Tutorials & Projects", "url": "https://www.tensorflow.org/tutorials"},
            {"title": "PyTorch Projects Collection", "url": "https://pytorch.org/tutorials/beginner/pytorch_with_examples.html"},
            {"title": "Hugging Face Project Walkthroughs", "url": "https://huggingface.co/learn"},
            {"title": "Computer Vision Projects", "url": "https://www.pyimagesearch.com/"}
        ],
        "generative_ai": [
            {"title": "Build Your Own LLM Application", "url": "https://buildyourowngpt.com/"},
            {"title": "Generative Art Projects", "url": "https://genart.tech/"},
            {"title": "LangChain Project Tutorials", "url": "https://python.langchain.com/docs/get_started/introduction"},
            {"title": "Fine-tuning LLMs: Hands-on Guide", "url": "https://huggingface.co/blog/how-to-train"}
        ],
        "agentic_ai": [
            {"title": "Build an AI Agent with LangChain", "url": "https://python.langchain.com/docs/use_cases/autonomous_agents"},
            {"title": "AutoGen Projects", "url": "https://microsoft.github.io/autogen/docs/examples/"},
            {"title": "Building Autonomous AI Systems", "url": "https://github.com/yoheinakajima/babyagi"},
            {"title": "Tool-using AI Projects", "url": "https://github.com/hwchase17/langchain-experiments"}
        ]
    },
    "Video Tutorials": {
        "python_beginner": [
            {"title": "CS50's Introduction to Programming with Python", "url": "https://cs50.harvard.edu/python/"},
            {"title": "freeCodeCamp Python Course", "url": "https://www.freecodecamp.org/learn/scientific-computing-with-python/"}
        ],
        "python_intermediate": [
            {"title": "MIT OpenCourseWare: Python", "url": "https://ocw.mit.edu/courses/6-0001-introduction-to-computer-science-and-programming-in-python-fall-2016/"}
        ],
        "data_science_beginner": [
            {"title": "freeCodeCamp Data Analysis Course", "url": "https://www.freecodecamp.org/learn/data-analysis-with-python/"}
        ],
        "data_science_advanced": [
            {"title": "Machine Learning Course by Andrew Ng", "url": "https://www.coursera.org/learn/machine-learning"},
            {"title": "Deep Learning Specialization", "url": "https://www.deeplearning.ai/deep-learning-specialization/"}
        ],
        "ai_specialization": [
            {"title": "MIT 6.S191: Introduction to Deep Learning", "url": "http://introtodeeplearning.com/"}
        ],
        "generative_ai": [
            {"title": "Neural Networks: Zero to Hero", "url": "https://karpathy.ai/zero-to-hero.html"},
            {"title": "Prompt Engineering for LLMs", "url": "https://www.deeplearning.ai/short-courses/chatgpt-prompt-engineering-for-developers/"}
        ],
        "agentic_ai": [
            {"title": "Building AI Agents with LangChain", "url": "https://www.youtube.com/watch?v=iw2Wcw7qPuE"},
            {"title": "AutoGPT and Multi-Agent Systems", "url": "https://www.youtube.com/watch?v=4YaILFaUXTo"}
        ]
    },
    "Interactive Exercises": {
        "python_beginner": [
            {"title": "CodeCademy Python Course", "url": "https://www.codecademy.com/learn/learn-python-3"},
            {"title": "CheckiO Python Challenges", "url": "https://py.checkio.org/"},
            {"title": "Python Tutor", "url": "https://pythontutor.com/"},
            {"title": "HackerRank Python Practice", "url": "https://www.hackerrank.com/domains/python"}
        ],
        "python_intermediate": [
            {"title": "Exercism Python Track", "url": "https://exercism.org/tracks/python"},
            {"title": "CodeWars Python Challenges", "url": "https://www.codewars.com/?language=python"},
            {"title": "LeetCode Python Problems", "url": "https://leetcode.com/problemset/all/?difficulty=EASY&page=1&languageTags=python"},
            {"title": "Project Euler", "url": "https://projecteuler.net/"}
        ],
        "data_science_beginner": [
            {"title": "DataCamp Interactive Courses", "url": "https://www.datacamp.com/courses/free-introduction-to-r"},
            {"title": "Kaggle Learn Interactive Tutorials", "url": "https://www.kaggle.com/learn/overview"},
            {"title": "DataQuest Interactive Data Science", "url": "https://www.dataquest.io/"},
            {"title": "Google's Data Analytics Course", "url": "https://www.coursera.org/professional-certificates/google-data-analytics"}
        ],
        "data_science_advanced": [
            {"title": "Interactive ML Course", "url": "https://www.coursera.org/learn/machine-learning"},
            {"title": "Kaggle Interactive Competitions", "url": "https://www.kaggle.com/competitions"},
            {"title": "Interactive Deep Learning", "url": "https://www.deeplearning.ai/courses/"},
            {"title": "Machine Learning Playground", "url": "https://ml-playground.com/"}
        ],
        "ai_specialization": [
            {"title": "TensorFlow Playground", "url": "https://playground.tensorflow.org/"},
            {"title": "Interactive Neural Network Builder", "url": "https://alexlenail.me/NN-SVG/"},
            {"title": "AI Experiments with Google", "url": "https://experiments.withgoogle.com/collection/ai"},
            {"title": "OpenAI Gym", "url": "https://www.gymlibrary.dev/"}
        ],
        "generative_ai": [
            {"title": "Hugging Face Spaces", "url": "https://huggingface.co/spaces"},
            {"title": "Interactive LLM Playground", "url": "https://platform.openai.com/playground"},
            {"title": "Interactive Stable Diffusion", "url": "https://huggingface.co/spaces/stabilityai/stable-diffusion"},
            {"title": "GPT-4 Interactive Demos", "url": "https://chat.openai.com/"}
        ],
        "agentic_ai": [
            {"title": "LangChain Interactive Tutorials", "url": "https://python.langchain.com/docs/get_started/introduction"},
            {"title": "Interactive AI Agent Builder", "url": "https://github.com/microsoft/TaskMatrix"},
            {"title": "AutoGen Playground", "url": "https://microsoft.github.io/autogen/"},
            {"title": "Reinforcement Learning Interactive Course", "url": "https://www.coursera.org/specializations/reinforcement-learning"}
        ]
    },
    "Combination": {
        "python_beginner": [
            {"title": "Python Documentation", "url": "https://docs.python.org/3/"},
            {"title": "Real Python", "url": "https://realpython.com/"},
            {"title": "Python for Everybody", "url": "https://www.py4e.com/"},
            {"title": "Automate the Boring Stuff with Python", "url": "https://automatetheboringstuff.com/"}
        ],
        "python_intermediate": [
            {"title": "Fluent Python", "url": "https://www.oreilly.com/library/view/fluent-python-2nd/9781492056348/"},
            {"title": "Python Design Patterns", "url": "https://refactoring.guru/design-patterns/python"},
            {"title": "Full Stack Python", "url": "https://www.fullstackpython.com/"},
            {"title": "Python Testing with pytest", "url": "https://pragprog.com/titles/bopytest/python-testing-with-pytest/"}
        ],
        "data_science_beginner": [
            {"title": "Kaggle Learn", "url": "https://www.kaggle.com/learn"},
            {"title": "Towards Data Science", "url": "https://towardsdatascience.com/"},
            {"title": "DataCamp", "url": "https://www.datacamp.com/"},
            {"title": "Python Data Science Handbook", "url": "https://jakevdp.github.io/PythonDataScienceHandbook/"}
        ],
        "data_science_advanced": [
            {"title": "Machine Learning Mastery", "url": "https://machinelearningmastery.com/"},
            {"title": "Hands-On Machine Learning with Scikit-Learn", "url": "https://www.oreilly.com/library/view/hands-on-machine-learning/9781492032632/"},
            {"title": "Fast.ai", "url": "https://www.fast.ai/"},
            {"title": "Stanford CS229: Machine Learning", "url": "https://see.stanford.edu/Course/CS229"}
        ],
        "ai_specialization": [
            {"title": "DeepLearning.AI", "url": "https://www.deeplearning.ai/"},
            {"title": "TensorFlow Tutorials", "url": "https://www.tensorflow.org/tutorials"},
            {"title": "PyTorch Tutorials", "url": "https://pytorch.org/tutorials/"},
            {"title": "Hugging Face Course", "url": "https://huggingface.co/learn"}
        ],
        "generative_ai": [
            {"title": "Andrej Karpathy's Neural Networks Course", "url": "https://karpathy.ai/zero-to-hero.html"},
            {"title": "Hugging Face Diffusion Models Course", "url": "https://huggingface.co/learn/diffusion-models/"},
            {"title": "Prompt Engineering Guide", "url": "https://www.promptingguide.ai/"},
            {"title": "Stanford CS324: Large Language Models", "url": "https://stanford-cs324.github.io/winter2022/"}
        ],
        "agentic_ai": [
            {"title": "LangChain Documentation", "url": "https://python.langchain.com/docs/get_started/introduction"},
            {"title": "Microsoft AutoGen", "url": "https://microsoft.github.io/autogen/"},
            {"title": "Multi-Agent Debate by Anthropic", "url": "https://www.anthropic.com/research/debate"},
            {"title": "Berkeley CS285: Deep Reinforcement Learning", "url": "https://rail.eecs.berkeley.edu/deeprlcourse/"}
        ]
    }
}


PROJECT_IDEAS = {
    "Visual": {
        "python_beginner": [
            "Data Visualization Dashboard with Matplotlib",
            "Interactive Game with Pygame",
            "Visual Timer Application with Tkinter",
            "Color Palette Generator",
            "Image Processing Tool"
        ],
        "python_intermediate": [
            "Data Visualization Web App with Flask and D3.js",
            "Interactive Map Application",
            "Animated Data Dashboard",
            "Custom Visualization Library",
            "Image Recognition System"
        ],
        "data_science_beginner": [
            "Interactive Data Dashboard with Plotly",
            "Visual Exploratory Data Analysis Tool",
            "Chart Comparison Application",
            "Geographic Data Visualization",
            "Statistical Visualization Gallery"
        ],
        "data_science_advanced": [
            "Real-time Visual Analytics Dashboard",
            "Machine Learning Model Visualizer",
            "Neural Network Visualization Tool",
            "Computer Vision Project",
            "Interactive Data Storytelling Platform"
        ],
        "ai_specialization": [
            "Neural Network Architecture Visualizer",
            "Interactive AI Learning Environment",
            "Computer Vision Object Detector",
            "Visual Pattern Recognition System",
            "Brain-Computer Interface Visualization"
        ],
        "generative_ai": [
            "Style Transfer Art Generator",
            "Visual AI Art Gallery",
            "Image Generation Dashboard",
            "Interactive Text-to-Image System",
            "Visual Prompt Engineering Tool"
        ],
        "agentic_ai": [
            "Visual Agent Environment Simulator",
            "Agent Decision Tree Visualizer",
            "Multi-Agent Interaction Visualization",
            "Visual Reinforcement Learning Playground",
            "Interactive Agent Behavior Explorer"
        ]
    },
    "Reading/Writing": {
        "python_beginner": [
            "Text File Processing Tool",
            "Personal Journal Application",
            "Notes Organization System",
            "Simple Blog Platform",
            "Document Analyzer"
        ],
        "python_intermediate": [
            "Advanced Text Editor",
            "Markdown Documentation Generator",
            "Content Management System",
            "Personal Wiki Platform",
            "Technical Documentation Tool"
        ],
        "data_science_beginner": [
            "Text Data Analysis Tool",
            "Literature Review Database",
            "Research Paper Summarizer",
            "Study Notes Organizer",
            "Data Analysis Report Generator"
        ],
        "data_science_advanced": [
            "Research Paper Recommendation System",
            "Advanced NLP Analysis Tool",
            "Automated Report Generator",
            "Literature Review AI Assistant",
            "Technical Writing Assistant"
        ],
        "ai_specialization": [
            "Text Summarization System",
            "AI-Powered Document Analysis",
            "Scientific Paper Classification Tool",
            "Sentiment Analysis for Literature",
            "Technical Writing Enhancement System"
        ],
        "generative_ai": [
            "AI Writing Assistant",
            "Creative Story Generator",
            "Academic Paper Generator",
            "LLM-Powered Documentation Tool",
            "Custom Prompt Engineering Workbook"
        ],
        "agentic_ai": [
            "AI Research Assistant Agent",
            "Technical Documentation Generator",
            "Writing Style Analyzer",
            "Text-Based Agent Environment",
            "AI-Powered Knowledge Management System"
        ]
    },
    "Hands-on Projects": {
        "python_beginner": [
            "Weather App with API Integration",
            "To-Do List Application",
            "Simple Calculator",
            "Basic Web Scraper",
            "File Organizer Tool"
        ],
        "python_intermediate": [
            "REST API with Flask or Django",
            "Web Application with User Authentication",
            "Automated Testing Framework",
            "Command-Line Tool with Click",
            "Desktop Application with PyQt"
        ],
        "data_science_beginner": [
            "Exploratory Data Analysis Project",
            "Basic Machine Learning Model",
            "Data Cleaning Pipeline",
            "Simple Predictive Model",
            "Dataset Visualization Tool"
        ],
        "data_science_advanced": [
            "End-to-End Machine Learning Pipeline",
            "Model Deployment with Flask/FastAPI",
            "Time Series Forecasting Application",
            "Natural Language Processing Tool",
            "Recommendation System"
        ],
        "ai_specialization": [
            "Custom Neural Network Implementation",
            "Image Classification Application",
            "NLP Chatbot",
            "Reinforcement Learning Environment",
            "Computer Vision Project"
        ],
        "generative_ai": [
            "Fine-tuned LLM Application",
            "Text-to-Image Generation Tool",
            "Music Generation System",
            "Creative Writing AI Assistant",
            "Voice Synthesis Application"
        ],
        "agentic_ai": [
            "Autonomous Task Execution Agent",
            "Multi-Agent Simulation",
            "Tool-Using AI Assistant",
            "AI Agent for Data Analysis",
            "Agent-Based Decision Support System"
        ]
    },
    "Video Tutorials": {
        "python_beginner": [
            "Educational Python Basics Series",
            "Interactive Coding Tutorial Videos",
            "Python Concept Explanation Screencast",
            "Code-Along Project Videos",
            "Python Tips and Tricks Channel"
        ],
        "python_intermediate": [
            "Advanced Python Features Tutorial Series",
            "Framework Deep-Dive Videos",
            "Performance Optimization Screencasts",
            "Design Patterns in Python Series",
            "Testing and Debugging Tutorials"
        ],
        "data_science_beginner": [
            "Data Analysis Walkthrough Series",
            "Statistics Visualization Tutorials",
            "Data Cleaning Process Videos",
            "Basic Machine Learning Model Tutorials",
            "Data Visualization Guide Videos"
        ],
        "data_science_advanced": [
            "Advanced ML Algorithm Explanations",
            "Feature Engineering Masterclass",
            "Model Optimization Techniques Series",
            "ML Pipeline Development Videos",
            "Model Deployment Tutorials"
        ],
        "ai_specialization": [
            "Neural Network Architecture Explanations",
            "Deep Learning Framework Tutorials",
            "Computer Vision Project Series",
            "NLP Implementation Videos",
            "AI Ethics Discussion Series"
        ],
        "generative_ai": [
            "LLM Implementation Tutorials",
            "Diffusion Model Training Guide",
            "Prompt Engineering Masterclass",
            "Fine-tuning Walkthrough Videos",
            "Generative AI Application Tutorials"
        ],
        "agentic_ai": [
            "AI Agent Development Series",
            "Multi-Agent System Tutorials",
            "LangChain Implementation Videos",
            "Tool-Using AI Development Guide",
            "Agent Communication Protocol Tutorials"
        ]
    },
    "Interactive Exercises": {
        "python_beginner": [
            "Python Syntax Practice Platform",
            "Interactive Coding Challenge Website",
            "Function Implementation Exercises",
            "Python Puzzle Game",
            "Basic Algorithm Challenge Series"
        ],
        "python_intermediate": [
            "Object-Oriented Programming Exercises",
            "Advanced Data Structure Challenges",
            "Algorithm Optimization Problems",
            "Design Pattern Implementation Tasks",
            "Testing Framework Exercise Platform"
        ],
        "data_science_beginner": [
            "Data Cleaning Exercise Platform",
            "Statistical Analysis Practice Problems",
            "Basic ML Model Implementation Challenges",
            "Data Visualization Exercise Series",
            "Exploratory Data Analysis Worksheets"
        ],
        "data_science_advanced": [
            "Advanced ML Algorithm Implementation",
            "Feature Engineering Challenge Platform",
            "Model Optimization Exercises",
            "NLP Processing Tasks",
            "Time Series Analysis Problems"
        ],
        "ai_specialization": [
            "Neural Network Implementation Exercises",
            "Deep Learning Framework Challenges",
            "Computer Vision Task Series",
            "NLP Model Building Problems",
            "AI Ethics Case Studies"
        ],
        "generative_ai": [
            "Prompt Engineering Practice Platform",
            "LLM Fine-tuning Exercise Suite",
            "Diffusion Model Parameter Tuning",
            "Generative Model Evaluation Tasks",
            "Text-to-Image Generation Challenges"
        ],
        "agentic_ai": [
            "Agent Development Exercise Platform",
            "Multi-Agent System Building Tasks",
            "Tool-Using AI Implementation Challenges",
            "Reinforcement Learning Problems",
            "Agent Communication Protocol Exercises"
        ]
    },
    "Combination": {
        "python_beginner": [
            "Multi-format Python Learning Platform",
            "Integrated Code and Video Tutorial Project",
            "Interactive Documentation System",
            "Visual and Written Tutorial Combination",
            "Exercise-Based Learning Environment"
        ],
        "python_intermediate": [
            "Full-Stack Python Development Course",
            "Project-Based Learning Platform",
            "Video and Interactive Exercise Combination",
            "Visual Programming Environment",
            "Code Review and Mentoring System"
        ],
        "data_science_beginner": [
            "Data Science Learning Path Platform",
            "Interactive Data Analysis Environment",
            "Video and Exercise-Based Statistics Course",
            "Visual Data Science Notebook System",
            "Hands-on Data Project Platform"
        ],
        "data_science_advanced": [
            "Advanced ML Project Portfolio",
            "Interactive Research Implementation Platform",
            "Video and Code-Based ML Framework",
            "Visual ML Pipeline Development System",
            "Experimental ML Environment"
        ],
        "ai_specialization": [
            "AI Research and Implementation Platform",
            "Deep Learning Visual Learning System",
            "Interactive Neural Network Builder",
            "Video and Code-Based AI Framework",
            "Hands-on AI Ethics Learning Environment"
        ],
        "generative_ai": [
            "Generative AI Development Platform",
            "Interactive LLM Training Environment",
            "Visual Prompt Engineering System",
            "Model Fine-tuning Learning Path",
            "Creative AI Implementation Framework"
        ],
        "agentic_ai": [
            "Agent Development Environment",
            "Multi-Agent Simulation Platform",
            "Interactive Tool-Using AI Builder",
            "Video and Code-Based Agent Framework",
            "Experimental Agent Testing System"
        ]
    }
}

# User session data store
SESSION_DATA = {}

def save_session(session_id, data):
    """Save session data to SESSION_DATA global dictionary"""
    if session_id in SESSION_DATA:
        SESSION_DATA[session_id].update(data)
    else:
        SESSION_DATA[session_id] = data
    
    # Add timestamp for session tracking
    SESSION_DATA[session_id]["last_activity"] = datetime.now().isoformat()

def load_session(session_id):
    """Load session data from SESSION_DATA global dictionary"""
    return SESSION_DATA.get(session_id, {})

def recommend_learning_path(age, goals, knowledge_level, interests):
    """Recommend personalized learning paths based on user profile"""
    paths = []
    
    # Simple recommendation logic based on profile
    if "beginner" in knowledge_level.lower():
        if any(topic in interests.lower() for topic in ["python", "programming", "coding"]):
            paths.append("python_beginner")
        if any(topic in interests.lower() for topic in ["data", "analysis", "statistics"]):
            paths.append("data_science_beginner")
    elif "intermediate" in knowledge_level.lower():
        if any(topic in interests.lower() for topic in ["python", "programming", "coding"]):
            paths.append("python_intermediate")
        if any(topic in interests.lower() for topic in ["data", "analysis", "statistics"]):
            paths.append("data_science_advanced")
        if any(topic in interests.lower() for topic in ["ai", "machine learning", "deep learning"]):
            paths.append("ai_specialization")
        if any(topic in interests.lower() for topic in ["generative", "gpt", "llm", "diffusion"]):
            paths.append("generative_ai")
    elif "advanced" in knowledge_level.lower() or "expert" in knowledge_level.lower():
        if any(topic in interests.lower() for topic in ["ai", "machine learning", "deep learning"]):
            paths.append("ai_specialization")
        if any(topic in interests.lower() for topic in ["generative", "gpt", "llm", "diffusion"]):
            paths.append("generative_ai")
        if any(topic in interests.lower() for topic in ["agent", "autonomous", "planning"]):
            paths.append("agentic_ai")
    
    # Check for specific mentions of generative or agentic AI regardless of level
    if any(topic in interests.lower() for topic in ["generative", "gpt", "llm", "diffusion"]):
        if "generative_ai" not in paths:
            paths.append("generative_ai")
            
    if any(topic in interests.lower() for topic in ["agent", "autonomous", "planning"]):
        if "agentic_ai" not in paths:
            paths.append("agentic_ai")
    
    # Default path if no matches
    if not paths:
        paths = ["python_beginner"]
    
    return [LEARNING_PATHS[path] for path in paths if path in LEARNING_PATHS]

def get_recommended_resources(interests, knowledge_level, recommended_paths):
    """Get recommended learning resources based on interests and recommended paths"""
    resources = []
    
    # Get path IDs from recommended paths
    path_ids = []
    for path in recommended_paths:
        path_id = next((k for k, v in LEARNING_PATHS.items() if v["title"] == path["title"]), None)
        if path_id:
            path_ids.append(path_id)
    
    # Add resources for each recommended path
    for path_id in path_ids:
        if path_id in LEARNING_RESOURCES:
            resources.extend(LEARNING_RESOURCES[path_id])
    
    # If no specific paths match, provide resources based on interests and level
    if not resources:
        if "beginner" in knowledge_level.lower():
            if any(topic in interests.lower() for topic in ["python", "programming", "coding"]):
                resources.extend(LEARNING_RESOURCES["python_beginner"])
            if any(topic in interests.lower() for topic in ["data", "analysis", "statistics"]):
                resources.extend(LEARNING_RESOURCES["data_science_beginner"])
        elif "intermediate" in knowledge_level.lower():
            if any(topic in interests.lower() for topic in ["python", "programming", "coding"]):
                resources.extend(LEARNING_RESOURCES["python_intermediate"])
            if any(topic in interests.lower() for topic in ["data", "analysis", "statistics"]):
                resources.extend(LEARNING_RESOURCES["data_science_advanced"])
        elif "advanced" in knowledge_level.lower() or "expert" in knowledge_level.lower():
            if any(topic in interests.lower() for topic in ["ai", "machine learning", "deep learning"]):
                resources.extend(LEARNING_RESOURCES["ai_specialization"])
    
    # If still no resources, provide general resources
    if not resources:
        for category in ["python_beginner", "data_science_beginner"]:
            resources.extend(LEARNING_RESOURCES[category][:2])
    
    # Remove duplicates while preserving order
    unique_resources = []
    seen_titles = set()
    for resource in resources:
        if resource["title"] not in seen_titles:
            seen_titles.add(resource["title"])
            unique_resources.append(resource)
    
    return unique_resources

def get_project_ideas(recommended_paths):
    """Get project ideas based on recommended learning paths"""
    ideas = []
    
    # Get project ideas for each recommended path
    for path in recommended_paths:
        path_id = next((k for k, v in LEARNING_PATHS.items() if v["title"] == path["title"]), None)
        if path_id and path_id in PROJECT_IDEAS:
            ideas.extend(PROJECT_IDEAS[path_id])
    
    # If no specific paths match, provide some general project ideas
    if not ideas:
        ideas = PROJECT_IDEAS["python_beginner"][:2] + PROJECT_IDEAS["data_science_beginner"][:2]
    
    # Remove duplicates while preserving order
    unique_ideas = []
    seen_ideas = set()
    for idea in ideas:
        if idea not in seen_ideas:
            seen_ideas.add(idea)
            unique_ideas.append(idea)
    
    return unique_ideas[:5]  # Return up to 5 project ideas

def generate_quiz(topic, difficulty):
    """Generate a quiz based on the topic and difficulty"""
    # In a real application, you might use the LLM to generate quizzes
    # Here we're using a template approach for simplicity
    quiz_prompt = f"""
    Generate a {difficulty} level quiz on {topic} with 3 multiple-choice questions.
    For each question, provide 4 options and indicate the correct answer.
    Format the quiz nicely with clear question numbering and option lettering.
    """
    
    # Use Groq to generate the quiz
    quiz_messages = [
        {"role": "system", "content": SYSTEM_PROMPT},
        {"role": "user", "content": quiz_prompt}
    ]
    
    quiz_response = client.chat.completions.create(
        messages=quiz_messages,
        model="llama-3.3-70b-versatile",
        stream=False
    )
    
    return quiz_response.choices[0].message.content

def create_study_plan(topic, time_available, goals, knowledge_level):
    """Create a personalized study plan"""
    plan_prompt = f"""
    Create a structured study plan for learning {topic} with {time_available} hours per week available for study.
    The learner's goal is: {goals}
    The learner's knowledge level is: {knowledge_level}
    
    Include:
    1. Weekly breakdown of topics
    2. Time allocation for theory vs practice
    3. Recommended resources for each week
    4. Milestone projects or assessments
    5. Tips for effective learning
    
    Make this plan specific, actionable, and tailored to the knowledge level.
    """
    
    # Use Groq to generate the study plan
    plan_messages = [
        {"role": "system", "content": SYSTEM_PROMPT},
        {"role": "user", "content": plan_prompt}
    ]
    
    plan_response = client.chat.completions.create(
        messages=plan_messages,
        model="llama-3.3-70b-versatile",
        stream=False
    )
    
    return plan_response.choices[0].message.content

def chat_with_groq(user_input, session_id):
    """Chat with Groq LLM using session context"""
    user_data = load_session(session_id)
    
    # Build context from session data if available
    context = ""
    if user_data:
        context = f"""
        User Profile:
        - Age: {user_data.get('age', 'Unknown')}
        - Knowledge Level: {user_data.get('knowledge_level', 'Unknown')}
        - Learning Goals: {user_data.get('goals', 'Unknown')}
        - Interests: {user_data.get('interests', 'Unknown')}
        - Available Study Time: {user_data.get('study_time', 'Unknown')} hours per week
        - Preferred Learning Style: {user_data.get('learning_style', 'Unknown')}
        
        Based on this profile, tailor your response appropriately.
        """
    
    # Add chat history context if available
    chat_history = user_data.get('chat_history', [])
    if chat_history:
        context += "\n\nRecent conversation context (most recent first):\n"
        # Include up to 3 most recent exchanges
        for i, (q, a) in enumerate(reversed(chat_history[-3:])):
            context += f"User: {q}\nYou: {a}\n\n"
    
    # Combine everything for the LLM
    full_prompt = f"{context}\n\nUser's current question: {user_input}"
    
    messages = [
        {"role": "system", "content": SYSTEM_PROMPT},
        {"role": "user", "content": full_prompt}
    ]
    
    chat_completion = client.chat.completions.create(
        messages=messages,
        model="llama-3.3-70b-versatile",
        stream=False
    )
    
    response = chat_completion.choices[0].message.content
    
    # Update chat history
    if 'chat_history' not in user_data:
        user_data['chat_history'] = []
    user_data['chat_history'].append((user_input, response))
    save_session(session_id, user_data)
    
    return response

def format_learning_paths(paths):
    """Format learning paths for display"""
    if not paths:
        return "No specific learning paths recommended yet. Please complete your profile."
    
    result = "### Recommended Learning Paths\n\n"
    for i, path in enumerate(paths, 1):
        result += f"{i}. {path['title']}\n"
        result += f"{path['description']}\n\n"
        result += "*Modules:*\n"
        for module in path['modules']:
            result += f"- {module}\n"
        result += "\n"
    
    return result

def format_resources(resources):
    """Format resources for display"""
    if not resources:
        return "No resources recommended yet. Please complete your profile."
    
    result = "### Recommended Learning Resources\n\n"
    for i, resource in enumerate(resources, 1):
        result += f"{i}. [{resource['title']}]({resource['url']})\n"
    
    return result

def format_project_ideas(ideas):
    """Format project ideas for display"""
    if not ideas:
        return "No project ideas recommended yet. Please complete your profile."
    
    result = "### Recommended Practice Projects\n\n"
    for i, idea in enumerate(ideas, 1):
        result += f"{i}. {idea}\n"
    
    return result

# Dictionary to store user profiles by session ID
user_profiles = {}

def user_onboarding(session_id, age, goals, knowledge_level, interests, study_time, learning_style):
    """Process user profile information and generate personalized recommendations"""
    
    # Store user profile information
    user_profiles[session_id] = {
        "age": age,
        "goals": goals,
        "knowledge_level": knowledge_level,
        "interests": interests,
        "study_time": study_time,
        "learning_style": learning_style,
        "last_updated": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    }
    
    # Generate initial recommendations based on profile
    return generate_recommendations(session_id)

def generate_recommendations(session_id):
    """Generate personalized learning recommendations based on user profile"""
    
    # Check if user profile exists
    if session_id not in user_profiles:
        return "Please complete your profile first to get personalized recommendations."
    
    profile = user_profiles[session_id]
    learning_style = profile["learning_style"]
    knowledge_level = profile["knowledge_level"].lower()
    
    # Map knowledge level to appropriate learning path
    if "python" in profile["interests"].lower():
        if knowledge_level == "beginner":
            learning_path_key = "python_beginner"
        else:
            learning_path_key = "python_intermediate"
    elif "data" in profile["interests"].lower():
        if knowledge_level == "beginner":
            learning_path_key = "data_science_beginner"
        else:
            learning_path_key = "data_science_advanced"
    elif "ai" in profile["interests"].lower() or "artificial" in profile["interests"].lower():
        if "gen" in profile["interests"].lower():
            learning_path_key = "generative_ai"
        elif "agent" in profile["interests"].lower():
            learning_path_key = "agentic_ai"
        else:
            learning_path_key = "ai_specialization"
    else:
        # Default path
        learning_path_key = "python_beginner"
    
    # Get learning path and resources based on style and path
    learning_path = LEARNING_PATHS.get(learning_path_key, LEARNING_PATHS["python_beginner"])
    resources = LEARNING_RESOURCES.get(learning_style, LEARNING_RESOURCES["Combination"])
    path_resources = resources.get(learning_path_key, resources["python_beginner"])
    
    # Get project ideas
    project_ideas = PROJECT_IDEAS.get(learning_style, PROJECT_IDEAS["Combination"])
    path_projects = project_ideas.get(learning_path_key, project_ideas["python_beginner"])
    
    # Build the recommendation markdown
    markdown = f"## Your Personalized Learning Path: {learning_path['title']}\n\n"
    markdown += f"{learning_path['description']}\n\n"
    
    markdown += "### Learning Modules\n"
    for i, module in enumerate(learning_path['modules'], 1):
        markdown += f"{i}. {module}\n"
    
    markdown += "\n### Recommended Resources\n"
    for i, resource in enumerate(path_resources[:3], 1):
        markdown += f"{i}. [{resource['title']}]({resource['url']})\n"
    
    markdown += "\n### Project Ideas\n"
    for i, project in enumerate(path_projects[:3], 1):
        markdown += f"{i}. {project}\n"
    
    markdown += f"\n\nRecommendations generated based on your {learning_style} learning style preference."
    
    return markdown

def chatbot_interface(session_id, message):
    """Process user messages and generate assistant responses"""
    
    if not message:
        return "Please type a message to start the conversation."
    
    # Build system message with context from user profile if available
    system_message = SYSTEM_PROMPT
    
    if session_id in user_profiles:
        profile = user_profiles[session_id]
        system_message += f"\n\nUser Profile Information:\n"
        system_message += f"- Knowledge Level: {profile['knowledge_level']}\n"
        system_message += f"- Learning Style: {profile['learning_style']}\n"
        system_message += f"- Interests: {profile['interests']}\n"
        system_message += f"- Learning Goals: {profile['goals']}\n"
    
    # Call the Groq API
    try:
        chat_completion = client.chat.completions.create(
            model="llama3-70b-8192",  # or another appropriate model
            messages=[
                {"role": "system", "content": system_message},
                {"role": "user", "content": message}
            ],
            temperature=0.7,
            max_tokens=2048
        )
        
        # Extract and return the response
        return chat_completion.choices[0].message.content
    
    except Exception as e:
        return f"I apologize, but I encountered an error: {str(e)}\n\nPlease try again in a moment."

def handle_quiz_request(session_id, topic, difficulty):
    """Generate a quiz based on the specified topic and difficulty"""
    
    if not topic:
        return "Please specify a topic for the quiz."
    
    # Build prompt for quiz generation
    prompt = f"Create a quiz on {topic} at {difficulty} level. Include 5 questions with multiple choice answers and provide the correct answers at the end."
    
    # Add context from user profile if available
    if session_id in user_profiles:
        profile = user_profiles[session_id]
        prompt += f"\nThe user has a {profile['knowledge_level']} knowledge level and prefers {profile['learning_style']} learning style."
    
    # Use chatbot interface with the quiz prompt
    return chatbot_interface(session_id, prompt)

def handle_study_plan_request(session_id, topic, time_available):
    """Generate a personalized study plan based on topic and available time"""
    
    if not topic:
        return "Please specify a topic for your study plan."
    
    # Build prompt for study plan generation
    prompt = f"Create a detailed study plan for learning {topic} with {time_available} hours available per week. Include specific goals, resources, and milestones."
    
    # Add context from user profile if available
    if session_id in user_profiles:
        profile = user_profiles[session_id]
        prompt += f"\nThe user has a {profile['knowledge_level']} knowledge level, prefers {profile['learning_style']} learning style, and has these goals: {profile['goals']}."
    
    # Use chatbot interface with the study plan prompt
    return chatbot_interface(session_id, prompt)

def add_generative_ai_info():
    """Return information about Generative AI"""
    return """
    ## What is Generative AI?
    
    Generative AI refers to artificial intelligence systems that can create new content, such as text, images, code, audio, video, or 3D models. Unlike traditional AI systems that are designed to recognize patterns or make predictions, generative AI creates original outputs based on the patterns it has learned during training.
    
    ### Key Concepts in Generative AI:
    
    - *Large Language Models (LLMs)*: Text generation systems like GPT-4, LLaMA, Claude, etc.
    - *Diffusion Models*: For image generation (DALL-E, Midjourney, Stable Diffusion)
    - *Prompt Engineering*: The art of crafting inputs to get desired outputs
    - *Fine-tuning*: Adapting pre-trained models for specific domains or tasks
    - *RLHF (Reinforcement Learning from Human Feedback)*: Method for aligning AI with human preferences
    
    Learning generative AI involves understanding these foundation models, how they work, and how to effectively use and customize them for various applications.
    """

def add_agentic_ai_info():
    """Return information about Agentic AI"""
    return """
    ## What is Agentic AI?
    
    Agentic AI refers to AI systems that can act autonomously to achieve specified goals. Unlike passive AI systems that respond only when prompted, agentic AI can take initiative, make decisions, use tools, and perform sequences of actions to accomplish tasks.
    
    ### Key Concepts in Agentic AI:
    
    - *Planning & Decision Making*: AI systems that can formulate and execute plans
    - *Tool Use*: AI that can leverage external tools and APIs
    - *Autonomous Execution*: Systems that can work without constant human supervision
    - *Multi-agent Systems*: Multiple AI agents collaborating or competing
    - *Memory & Context Management*: How agents maintain state across interactions
    
    Agentic AI represents an evolution from AI as a passive tool to AI as an active collaborator that can work independently while remaining aligned with human goals and values.
    """

def create_chatbot():
    """Create the Gradio interface for the chatbot"""
    # Generate a random session ID for the user
    session_id = str(uuid.uuid4())
    
    # Define theme colors
    theme_colors = {
        "light": {
            "primary": "#4a6fa5",
            "secondary": "#6c757d",
            "success": "#28a745",
            "background": "#f8f9fa",
            "text": "#212529",
            "card_bg": "#ffffff",
            "card_border": "#dee2e6",
            "input_bg": "#ffffff",
            "highlight": "#e7f5fe",
            "accent": "#007bff",
            "completed": "#d4edda",
            "info_box_bg": "#e7f5fe"
        },
        "dark": {
            "primary": "#5b88c7",         # Lighter blue for better visibility in dark mode
            "secondary": "#adb5bd",       # Lighter gray for better visibility
            "success": "#48c774",         # Brighter green for dark mode
            "background": "#1a1a1a",      # Dark background 
            "text": "#f1f1f1",            # Light text for dark backgrounds
            "card_bg": "#2d2d2d",         # Dark card background
            "card_border": "#444444",     # Dark border
            "input_bg": "#333333",        # Dark input background
            "highlight": "#193652",       # Dark highlight
            "accent": "#3291ff",          # Bright accent
            "completed": "#204829",       # Dark green for completed
            "info_box_bg": "#193652"      # Dark info box
        }
    }
    
    # Create CSS with theme variables
    custom_css = """
        /* Theme variables - will be applied based on user's theme preference */
        .light-theme {
            --primary-color: #4a6fa5;
            --secondary-color: #6c757d;
            --success-color: #28a745;
            --bg-color: #f8f9fa;
            --text-color: #212529;
            --card-bg: #ffffff;
            --card-border: #dee2e6;
            --input-bg: #ffffff;
            --highlight-color: #e7f5fe;
            --accent-color: #007bff;
            --completed-color: #d4edda;
            --info-box-bg: #e7f5fe;
        }
        
        .dark-theme {
            --primary-color: #5b88c7;
            --secondary-color: #adb5bd;
            --success-color: #48c774;
            --bg-color: #1a1a1a;
            --text-color: #f1f1f1;
            --card-bg: #2d2d2d;
            --card-border: #444444;
            --input-bg: #333333;
            --highlight-color: #193652;
            --accent-color: #3291ff;
            --completed-color: #204829;
            --info-box-bg: #193652;
        }
        
        /* Automatically detect theme preference and apply appropriate theme class */
        @media (prefers-color-scheme: dark) {
            body {
                color-scheme: dark;
            }
            
            body:not(.light-theme):not(.force-light) {
                background-color: var(--bg-color);
                color: var(--text-color);
            }
        }
        
        @media (prefers-color-scheme: light) {
            body {
                color-scheme: light;
            }
            
            body:not(.dark-theme):not(.force-dark) {
                background-color: var(--bg-color);
                color: var(--text-color);
            }
        }
        
        /* Apply theme variables to elements */
        .gradio-container { 
            background-color: var(--bg-color) !important; 
            color: var(--text-color) !important;
            font-family: 'Inter', 'Segoe UI', sans-serif; 
        }
        
        /* Style overrides for Gradio components to respect theme */
        .gr-box, .gr-panel {
            background-color: var(--card-bg) !important;
            border-color: var(--card-border) !important;
            color: var(--text-color) !important;
        }
        
        .gr-input, .gr-dropdown {
            background-color: var(--input-bg) !important;
            color: var(--text-color) !important;
            border-color: var(--card-border) !important;
        }
        
        .gr-input:focus, .gr-dropdown:focus {
            border-color: var(--accent-color) !important;
        }
        
        .gr-input::placeholder {
            color: var(--secondary-color) !important;
            opacity: 0.7;
        }
        
        /* App specific styling */
        #title { 
            font-size: 32px; 
            font-weight: bold; 
            text-align: center; 
            padding-top: 20px; 
            color: var(--primary-color) !important;
            margin-bottom: 0;
        }
        
        #subtitle { 
            font-size: 18px; 
            text-align: center; 
            margin-bottom: 20px; 
            color: var(--secondary-color) !important; 
        }
        
        .card {
            background-color: var(--card-bg) !important;
            color: var(--text-color) !important;
            padding: 20px;
            border-radius: 12px;
            border: 1px solid var(--card-border);
            box-shadow: 0 4px 10px rgba(0,0,0,0.08);
            margin-bottom: 20px;
        }
        
        /* Fix markdown text color for both themes */
        .prose {
            color: var(--text-color) !important;
        }
        
        /* Ensure markdown headings are visible in both themes */
        .prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
            color: var(--primary-color) !important;
            font-weight: 600;
        }
        
        /* Make links visible in both themes */
        .prose a {
            color: var(--accent-color) !important;
            text-decoration: underline;
        }
        
        /* Fix button colors */
        .gr-button-primary { 
            background-color: var(--primary-color) !important; 
            color: #ffffff !important;
        }
        
        .gr-button-secondary { 
            background-color: var(--secondary-color) !important; 
            color: #ffffff !important;
        }
        
        .gr-button-success { 
            background-color: var(--success-color) !important; 
            color: #ffffff !important;
        }
        
        /* Footer styling */
        .footer {
            text-align: center;
            margin-top: 30px;
            padding: 10px;
            font-size: 14px;
            color: var(--secondary-color) !important;
        }
        
        /* Progress modules */
        .progress-module {
            padding: 10px;
            margin: 5px 0;
            border-radius: 5px;
            background-color: var(--highlight-color);
            color: var(--text-color);
        }
        
        .progress-module.completed {
            background-color: var(--completed-color);
        }
        
        /* Info box styling */
        .info-box {
            background-color: var(--info-box-bg);
            border-left: 4px solid var(--primary-color);
            padding: 15px;
            margin: 15px 0;
            border-radius: 4px;
            color: var(--text-color);
        }
        
        /* Tab styling improvements */
        .tabs button {
            color: var(--text-color) !important;
        }
        
        .tabs button[data-selected="true"] {
            color: var(--primary-color) !important;
            border-color: var(--primary-color) !important;
        }
        
        /* Add theme detection script */
        .theme-script {
            display: none;
        }
    """
    
    # JavaScript to detect and apply theme
    theme_script = """
    <script>
        // Function to detect and apply theme
        function applyTheme() {
            // Check if user has a saved preference
            const savedTheme = localStorage.getItem('preferredTheme');
            
            if (savedTheme) {
                // Apply saved preference
                document.body.classList.add(savedTheme + '-theme');
            } else {
                // Check system preference
                if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
                    document.body.classList.add('dark-theme');
                } else {
                    document.body.classList.add('light-theme');
                }
            }
            
            // Listen for theme changes
            window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
                // Only apply if no saved preference
                if (!savedTheme) {
                    document.body.classList.remove('light-theme', 'dark-theme');
                    document.body.classList.add(event.matches ? 'dark-theme' : 'light-theme');
                }
            });
        }
        
        // Apply theme when DOM is loaded
        document.addEventListener('DOMContentLoaded', applyTheme);
        
        // For Gradio that might load content dynamically
        if (document.readyState === 'complete' || document.readyState === 'interactive') {
            setTimeout(applyTheme, 1);
        }
    </script>
    """
    
    with gr.Blocks(css=custom_css, theme=gr.themes.Soft(primary_hue="blue")) as demo:
        gr.HTML("<div id='title'>🎓 AI Teaching Assistant</div>")
        gr.HTML("<div id='subtitle'>Your personalized learning companion for Python, Data Science & AI</div>")
        gr.HTML(theme_script, elem_classes=["theme-script"])
        
        # Tabs for different sections
        with gr.Tabs(elem_classes=["tabs"]) as tabs:
            # Profile Tab
            with gr.Tab("Profile & Goals"):
                with gr.Column(elem_classes=["card"]):
                    gr.HTML("<h3>Complete Your Learning Profile</h3>")
                    
                    with gr.Row():
                        with gr.Column(scale=1):
                            age_input = gr.Textbox(
                                label="Age", 
                                placeholder="e.g. 20",
                                lines=1
                            )
                        with gr.Column(scale=2):
                            knowledge_level_input = gr.Dropdown(
                                choices=["Beginner", "Intermediate", "Advanced", "Expert"],
                                label="Knowledge Level",
                                value="Beginner"
                            )
                    
                    goals_input = gr.Textbox(
                        label="Learning Goals", 
                        placeholder="e.g. I want to become a data scientist and work with machine learning models",
                        lines=2
                    )
                    
                    interests_input = gr.Textbox(
                        label="Specific Interests", 
                        placeholder="e.g. Python, data visualization, neural networks",
                        lines=2
                    )
                    
                    with gr.Row():
                        with gr.Column(scale=1):
                            study_time_input = gr.Dropdown(
                                choices=["1-3", "4-6", "7-10", "10+"],
                                label="Hours Available Weekly",
                                value="4-6"
                            )
                        with gr.Column(scale=2):
                            learning_style_input = gr.Dropdown(
                                choices=["Visual", "Reading/Writing", "Hands-on Projects", "Video Tutorials", "Interactive Exercises", "Combination"],
                                label="Preferred Learning Style",
                                value="Combination"
                            )
                    
                    profile_submit_btn = gr.Button("Save Profile & Generate Recommendations", variant="primary")
                    profile_output = gr.Markdown(label="Personalized Recommendations")
            
            # Chat Tab
            with gr.Tab("Learning Assistant"):
                with gr.Row():
                    with gr.Column(elem_classes=["card"]):
                        chat_input = gr.Textbox(
                            label="Ask a Question",
                            placeholder="Ask anything about Python, Data Science, AI...",
                            lines=3
                        )
                        
                        with gr.Row():
                            chat_submit_btn = gr.Button("Send Message", variant="primary")
                            chat_clear_btn = gr.Button("Clear Chat", variant="secondary")
                        
                        chat_output = gr.Markdown(label="Assistant Response")
            
            # Resources Tab
            with gr.Tab("Resources & Recommendations"):
                with gr.Column(elem_classes=["card"]):
                    gr.HTML("<h3>Your Learning Resources</h3>")
                    refresh_recommendations_btn = gr.Button("Refresh Recommendations", variant="primary")
                    recommendations_output = gr.Markdown(label="Personalized Recommendations")
            
            # Practice Tab
            with gr.Tab("Practice & Assessment"):
                with gr.Column(elem_classes=["card"]):
                    gr.HTML("<h3>Generate a Quiz</h3>")
                    
                    with gr.Row():
                        quiz_topic_input = gr.Textbox(
                            label="Quiz Topic", 
                            placeholder="e.g. Python Lists",
                            lines=1
                        )
                        quiz_difficulty_input = gr.Dropdown(
                            choices=["Beginner", "Intermediate", "Advanced"],
                            label="Difficulty Level",
                            value="Beginner"
                        )
                    
                    generate_quiz_btn = gr.Button("Generate Quiz", variant="primary")
                    quiz_output = gr.Markdown(label="Quiz")
            
            # Study Plan Tab
            with gr.Tab("Study Plan"):
                with gr.Column(elem_classes=["card"]):
                    gr.HTML("<h3>Generate a Personalized Study Plan</h3>")
                    
                    with gr.Row():
                        plan_topic_input = gr.Textbox(
                            label="Study Topic", 
                            placeholder="e.g. Data Science",
                            lines=1
                        )
                        plan_time_input = gr.Dropdown(
                            choices=["1-3", "4-6", "7-10", "10+"],
                            label="Hours Available Weekly",
                            value="4-6"
                        )
                    
                    generate_plan_btn = gr.Button("Generate Study Plan", variant="primary")
                    plan_output = gr.Markdown(label="Personalized Study Plan")
        
        gr.HTML("""<div class="footer">
            AI Teaching Assistant | Powered by Groq AI |Created by Maria Nadeem
        </div>""")
        
        # Event handlers
        profile_submit_btn.click(
            user_onboarding,
            inputs=[
                gr.State(session_id), 
                age_input, 
                goals_input, 
                knowledge_level_input,
                interests_input,
                study_time_input,
                learning_style_input
            ],
            outputs=profile_output
        )
        
        chat_submit_btn.click(
            chatbot_interface,
            inputs=[gr.State(session_id), chat_input],
            outputs=chat_output
        )
        
        chat_clear_btn.click(
            lambda: "",
            inputs=[],
            outputs=[chat_output, chat_input]
        )
        
        refresh_recommendations_btn.click(
            generate_recommendations,
            inputs=[gr.State(session_id)],
            outputs=recommendations_output
        )
        
        generate_quiz_btn.click(
            handle_quiz_request,
            inputs=[gr.State(session_id), quiz_topic_input, quiz_difficulty_input],
            outputs=quiz_output
        )
        
        generate_plan_btn.click(
            handle_study_plan_request,
            inputs=[gr.State(session_id), plan_topic_input, plan_time_input],
            outputs=plan_output
        )
    
    return demo

if __name__ == "__main__":
    app = create_chatbot()
    app.launch()