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
2f60860
45dce4f
 
 
 
 
 
 
2f60860
 
 
 
45dce4f
 
 
2f60860
45dce4f
 
 
 
 
 
 
 
 
 
 
 
 
2f60860
45dce4f
 
 
 
 
 
 
 
 
2f60860
45dce4f
 
2b38d79
2f60860
 
 
 
fd01f65
2f60860
 
 
2b38d79
 
 
fd01f65
2b38d79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45dce4f
 
 
 
 
 
fd01f65
45dce4f
 
2b38d79
 
fd01f65
 
 
 
 
 
 
 
 
 
 
 
2b38d79
 
45dce4f
 
 
 
 
 
 
 
2f60860
 
45dce4f
 
 
 
 
fd01f65
45dce4f
 
fd01f65
45dce4f
 
 
 
fd01f65
2f60860
45dce4f
2f60860
fd01f65
45dce4f
 
 
2f60860
45dce4f
 
 
2f60860
45dce4f
 
 
2f60860
 
 
 
 
 
 
45dce4f
 
2f60860
45dce4f
 
 
 
 
 
fd01f65
45dce4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2f60860
45dce4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fd01f65
45dce4f
 
 
 
 
 
 
 
 
 
 
2b38d79
45dce4f
 
 
 
 
 
 
 
 
 
 
 
4ec07e1
45dce4f
 
 
 
 
 
 
fd01f65
45dce4f
 
 
 
2b38d79
45dce4f
 
 
 
 
 
2b38d79
45dce4f
 
 
 
2f60860
45dce4f
 
 
 
fd01f65
45dce4f
 
 
 
 
 
 
 
 
2f60860
45dce4f
 
 
 
fd01f65
45dce4f
 
2f60860
 
 
 
 
 
 
 
fd01f65
2f60860
 
45dce4f
 
 
 
 
 
 
 
 
 
2f60860
45dce4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fd01f65
45dce4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fd01f65
45dce4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fd01f65
45dce4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fd01f65
45dce4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fd01f65
45dce4f
 
 
 
2b38d79
45dce4f
2b38d79
 
45dce4f
 
2b38d79
 
2f60860
2b38d79
 
 
 
 
 
 
2f60860
2b38d79
 
 
 
2f60860
2b38d79
 
 
 
 
 
 
 
 
 
 
 
45dce4f
 
 
2b38d79
45dce4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fd01f65
45dce4f
 
 
 
 
2b38d79
 
 
 
45dce4f
 
 
 
 
 
 
2b38d79
 
45dce4f
 
2b38d79
 
45dce4f
 
 
 
 
 
 
2b38d79
45dce4f
2b38d79
45dce4f
 
 
 
 
 
fd01f65
45dce4f
 
 
 
 
2b38d79
 
 
 
 
 
 
 
45dce4f
 
 
 
 
 
 
 
2b38d79
 
 
 
 
 
 
 
 
 
 
45dce4f
 
 
 
 
fd01f65
45dce4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b38d79
 
 
 
 
 
 
 
 
 
 
45dce4f
 
fd01f65
45dce4f
 
 
 
 
 
 
 
 
 
 
2b38d79
45dce4f
 
 
 
 
 
 
 
2b38d79
 
 
 
45dce4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fd01f65
 
 
 
 
 
 
 
 
 
 
 
 
45dce4f
fd01f65
45dce4f
 
 
 
 
 
 
 
 
2f60860
45dce4f
 
 
 
fd01f65
 
 
 
 
 
 
 
45dce4f
fd01f65
 
 
 
45dce4f
 
 
fd01f65
45dce4f
 
 
 
fd01f65
45dce4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fd01f65
45dce4f
 
 
 
 
 
 
 
 
fd01f65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45dce4f
 
 
 
 
 
 
 
 
 
 
fd01f65
 
 
 
 
 
 
45dce4f
 
fd01f65
 
45dce4f
 
 
fd01f65
45dce4f
 
 
fd01f65
45dce4f
 
fd01f65
45dce4f
 
fd01f65
baea076
fd01f65
 
baea076
45dce4f
 
fd01f65
45dce4f
 
fd01f65
45dce4f
 
 
 
 
fd01f65
45dce4f
 
fd01f65
 
 
 
 
 
 
 
 
 
 
 
45dce4f
 
 
 
 
 
fd01f65
45dce4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fd01f65
9bc7a47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fd01f65
45dce4f
 
2f60860
45dce4f
 
 
 
 
2b38d79
45dce4f
 
 
 
 
 
 
2b38d79
45dce4f
 
9bc7a47
 
 
2b38d79
45dce4f
2b38d79
 
 
45dce4f
fd01f65
45dce4f
 
 
 
 
fd01f65
2f60860
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fd01f65
2f60860
 
 
fd01f65
2f60860
 
 
 
 
fd01f65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2f60860
 
fd01f65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2f60860
 
 
 
 
 
 
2b38d79
 
2f60860
2b38d79
 
 
 
 
 
fd01f65
45dce4f
 
fd01f65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45dce4f
fd01f65
45dce4f
 
 
2b38d79
fd01f65
2b38d79
45dce4f
2b38d79
45dce4f
2b38d79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45dce4f
 
 
 
ebc54c7
2b38d79
45dce4f
 
 
2b38d79
 
 
 
 
 
45dce4f
 
 
 
ebc54c7
2f60860
45dce4f
ebc54c7
2f60860
 
 
2b38d79
 
 
fd01f65
2f60860
2b38d79
 
 
 
 
 
 
 
 
2f60860
2b38d79
fd01f65
2b38d79
 
 
fd01f65
2f60860
 
 
2b38d79
 
 
fd01f65
 
2f60860
2b38d79
 
2f60860
2b38d79
2f60860
 
 
2b38d79
2f60860
2b38d79
2f60860
 
 
 
fd01f65
 
2f60860
fd01f65
2f60860
 
2b38d79
fd01f65
2b38d79
 
2f60860
fd01f65
2b38d79
 
 
fd01f65
 
2b38d79
 
 
 
 
2f60860
 
2b38d79
 
2f60860
 
fd01f65
2f60860
 
 
2b38d79
fd01f65
2b38d79
 
 
fd01f65
 
 
 
 
 
2f60860
 
fd01f65
 
 
2b38d79
 
2f60860
 
2b38d79
fd01f65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2f60860
 
fd01f65
2f60860
fd01f65
 
2b38d79
 
 
2f60860
fd01f65
2f60860
 
fd01f65
 
2b38d79
 
 
 
fd01f65
2b38d79
 
fd01f65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45dce4f
2b38d79
 
 
45dce4f
 
fd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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45dce4f
 
 
 
 
2b38d79
45dce4f
 
2b38d79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45dce4f
 
 
 
fd01f65
45dce4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e02e1b00",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import cloudinary\n",
    "import cloudinary.uploader\n",
    "import requests\n",
    "from io import BytesIO\n",
    "from dotenv import load_dotenv\n",
    "\n",
    "load_dotenv()\n",
    "\n",
    "# Explicitly configure using your 3 credentials\n",
    "cloudinary.config( \n",
    "  cloud_name = os.getenv('CLOUDINARY_CLOUD_NAME'), \n",
    "  api_key = os.getenv('CLOUDINARY_API_KEY'), \n",
    "  api_secret = os.getenv('CLOUDINARY_API_SECRET'),\n",
    "  secure = True\n",
    ")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c11377c5",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import cloudinary\n",
    "import cloudinary.uploader\n",
    "from dotenv import load_dotenv\n",
    "\n",
    "# 1. Load credentials from your .env file\n",
    "load_dotenv()\n",
    "\n",
    "cloudinary.config( \n",
    "  cloud_name = os.getenv('CLOUDINARY_CLOUD_NAME'), \n",
    "  api_key = os.getenv('CLOUDINARY_API_KEY'), \n",
    "  api_secret = os.getenv('CLOUDINARY_API_SECRET'),\n",
    "  secure = True\n",
    ")\n",
    "\n",
    "# 2. Set your variables\n",
    "resume_path = r\"c:\\Users\\ATHARVA\\Downloads\\my codes\\python\\machine_learning\\Learning_Files\\ChirayuResume.pdf\"\n",
    "thread_id = \"trial_thread_001\"\n",
    "file_name = \"ChirayuResume\"\n",
    "\n",
    "# 3. Perform the upload\n",
    "try:\n",
    "    response = cloudinary.uploader.upload(\n",
    "        resume_path,\n",
    "        folder = f\"threads/{thread_id}\",\n",
    "        public_id = file_name,\n",
    "        resource_type = \"image\"  # Use \"image\" for PDFs to get previews in UI\n",
    "    )\n",
    "\n",
    "    # 4. Create the URL from the response\n",
    "    pdf_url = response.get(\"secure_url\")\n",
    "    \n",
    "    print(f\"✅ Upload Successful!\")\n",
    "    print(f\"📂 Folder: threads/{thread_id}\")\n",
    "    print(f\"🔗 URL to push: {pdf_url}\")\n",
    "\n",
    "except Exception as e:\n",
    "    print(f\"❌ Upload failed: {e}\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f986ff8f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "from io import BytesIO\n",
    "\n",
    "def get_pdf_for_ai(url):\n",
    "    # 1. Reach out to the URL\n",
    "    response = requests.get(url)\n",
    "    \n",
    "    if response.status_code == 200:\n",
    "        # 2. Convert the web response into a \"file-like\" object\n",
    "        pdf_stream = BytesIO(response.content)\n",
    "        print(\"✅ PDF loaded into memory for processing!\")\n",
    "        return pdf_stream\n",
    "    else:\n",
    "        print(f\"❌ Failed to fetch PDF. Status: {response.status_code}\")\n",
    "        return None\n",
    "\n",
    "# --- USE YOUR ACTUAL URL ---\n",
    "resume_url = \"https://res.cloudinary.com/dvxnazx8e/image/upload/v1774166452/threads/trial_thread_001/ChirayuResume.pdf\"\n",
    "pdf_data = get_pdf_for_ai(resume_url)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "938186bf",
   "metadata": {},
   "outputs": [],
   "source": [
    "import cloudinary\n",
    "from cloudinary import Search\n",
    "\n",
    "\n",
    "def get_resume_url(thread_id: str) -> str:\n",
    "    \"\"\"\n",
    "    Searches Cloudinary for the resume PDF in the thread's folder\n",
    "    and returns the secure URL.\n",
    "    \"\"\"\n",
    "    result = Search() \\\n",
    "        .expression(f'folder:\"threads/{thread_id}/*\"') \\\n",
    "        .sort_by('public_id', 'desc') \\\n",
    "        .max_results(1) \\\n",
    "        .execute()\n",
    "\n",
    "    resources = result.get(\"resources\", [])\n",
    "\n",
    "    if not resources:\n",
    "        raise FileNotFoundError(f\"No resume found for thread_id: {thread_id}\")\n",
    "\n",
    "    pdf_url = resources[0][\"secure_url\"]\n",
    "    print(f\"Found resume: {pdf_url}\")\n",
    "    return pdf_url"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f4340cbb",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "import tempfile\n",
    "import os\n",
    "from langchain_community.document_loaders import PyMuPDFLoader\n",
    "\n",
    "thread_id = \"trial_thread_001\"\n",
    "\n",
    "try:\n",
    "    # Step 1 — Get URL from Cloudinary\n",
    "    url = get_resume_url(thread_id)\n",
    "    print(f\"URL: {url}\")\n",
    "\n",
    "    # Step 2 — Fetch PDF bytes\n",
    "    response = requests.get(url)\n",
    "    response.raise_for_status()\n",
    "\n",
    "    # Step 3 — Write to temp file\n",
    "    with tempfile.NamedTemporaryFile(delete=False, suffix=\".pdf\") as tmp:\n",
    "        tmp.write(response.content)\n",
    "        tmp_path = tmp.name\n",
    "\n",
    "    # Step 4 — Load with PyMuPDF\n",
    "    loader = PyMuPDFLoader(tmp_path)\n",
    "    docs = loader.load()\n",
    "    resume_text = \"\\n\".join([doc.page_content for doc in docs])\n",
    "\n",
    "    # Step 5 — Cleanup\n",
    "    os.remove(tmp_path)\n",
    "\n",
    "    print(f\"Pages loaded: {len(docs)}\")\n",
    "    print(f\"Preview:\\n{resume_text[:500]}\")\n",
    "\n",
    "except FileNotFoundError as e:\n",
    "    print(f\"Not found: {e}\")\n",
    "except Exception as e:\n",
    "    print(f\"Error: {e}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b010e49b",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_community.document_loaders import  PyMuPDFLoader"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7164448e",
   "metadata": {},
   "outputs": [],
   "source": [
    "resumepath=r\"c:\\Users\\ATHARVA\\Downloads\\my codes\\python\\machine_learning\\Learning_Files\\ChirayuResume.pdf\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6d1029c0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import cloudinary.uploader\n",
    "import os\n",
    "\n",
    "# Your resume path (using 'r' for raw string to handle backslashes correctly)\n",
    "resume_path = r\"c:\\Users\\ATHARVA\\Downloads\\my codes\\python\\machine_learning\\Learning_Files\\ChirayuResume.pdf\"\n",
    "\n",
    "# Extract filename without extension for the public_id\n",
    "file_name = os.path.basename(resume_path).split('.')[0] \n",
    "thread_id = \"trial_thread_001\"\n",
    "\n",
    "# Upload directly using the file path\n",
    "upload_result = cloudinary.uploader.upload(\n",
    "    resume_path, \n",
    "    folder=f\"threads/{thread_id}\",\n",
    "    public_id=file_name,\n",
    "    resource_type=\"auto\" # Handles the PDF correctly\n",
    ")\n",
    "\n",
    "print(f\"Upload Successful! URL: {upload_result['secure_url']}\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "928b7237",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import requests\n",
    "import cloudinary\n",
    "from io import BytesIO\n",
    "\n",
    "# --- 1. CONFIGURATION (Do this once) ---\n",
    "# This tells the library your API Key/Secret. \n",
    "# In a real app, put this in your .env file!\n",
    "os.environ[\"CLOUDINARY_URL\"] = \"cloudinary://866996699612973:9Tp3hGjI9npawSIrN4Mu4hFRwLQ@dtscmobmv\"\n",
    "\n",
    "def get_pdf_content(file_url):\n",
    "    \"\"\"\n",
    "    This function expects an HTTPS url, NOT the cloudinary:// credentials.\n",
    "    \"\"\"\n",
    "    # Ensure the URL is a real web link\n",
    "    if not file_url.startswith(\"http\"):\n",
    "        raise ValueError(\"The URL must start with http or https!\")\n",
    "\n",
    "    response = requests.get(file_url)\n",
    "    if response.status_code == 200:\n",
    "        return BytesIO(response.content)\n",
    "    else:\n",
    "        print(f\"Error: Could not download file. Status: {response.status_code}\")\n",
    "        return None\n",
    "\n",
    "# --- 2. TESTING ---\n",
    "# This is what the MERN devs will send you:\n",
    "test_resume_url = \"https://res.cloudinary.com\"\n",
    "\n",
    "# This will now work!\n",
    "pdf_file = get_pdf_content(test_resume_url)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "26688a4a",
   "metadata": {},
   "source": [
    "**Start**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b75a238a",
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import Any, Dict, List, Optional, Tuple,TypedDict,Literal\n",
    "from typing import Annotated, Sequence\n",
    "import os\n",
    "from pydantic import BaseModel, Field\n",
    "from langchain_groq import ChatGroq\n",
    "from langchain_core.messages import SystemMessage, HumanMessage,ToolMessage,AIMessage\n",
    "from langchain_core.tools import Tool\n",
    "from langgraph.graph import StateGraph,END,START\n",
    "from langgraph.types import interrupt  \n",
    "from langchain_core.prompts import ChatPromptTemplate,MessagesPlaceholder\n",
    "from langchain_community.document_loaders import  PyMuPDFLoader\n",
    "import json\n",
    "from pydantic import BaseModel, Field\n",
    "from typing import List, Optional\n",
    "from pprint import pprint\n",
    "import os\n",
    "from dotenv import load_dotenv\n",
    "import json\n",
    "from langchain_core.documents import Document\n",
    "from langchain_huggingface import HuggingFaceEmbeddings\n",
    "import os\n",
    "from pinecone import Pinecone, ServerlessSpec\n",
    "from pinecone_text.sparse import BM25Encoder\n",
    "from langchain_community.embeddings import HuggingFaceEmbeddings\n",
    "from langchain_community.retrievers import PineconeHybridSearchRetriever\n",
    "import json\n",
    "from langchain_core.documents import Document\n",
    "from langchain_core.messages import BaseMessage\n",
    "from langgraph.graph import add_messages\n",
    "from langgraph.prebuilt import ToolNode ,tools_condition\n",
    "import torch\n",
    "from langgraph.checkpoint.memory import MemorySaver\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c7058b37",
   "metadata": {},
   "source": [
    "Pydantic model of resume data extraction"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "69094b87",
   "metadata": {},
   "source": [
    "**Defining the pydantic models to be used**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "7da5b1c6",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "\n",
    "class Skill(BaseModel):\n",
    "    name: str = Field(..., description=\"Skill name e.g. Python, Docker\")\n",
    "    category: Optional[str] = Field(\n",
    "        None, description=\"Category: Backend | ML | DevOps | Frontend | Other\"\n",
    "    )\n",
    "\n",
    "\n",
    "class ExperienceItem(BaseModel):\n",
    "    job_title: str = Field(\n",
    "        ...,\n",
    "        description=\"Role title of the candidate. Example: 'Backend Intern', 'Software Engineer'\"\n",
    "    )\n",
    "\n",
    "    experience_type: Optional[Literal['internship', 'full_time', 'contract', 'freelance']] = Field(\n",
    "        None,\n",
    "        description=\"Type of experience: internship, full_time, contract, or freelance\"\n",
    "    )\n",
    "\n",
    "\n",
    "\n",
    "    technologies: Optional[List[str]] = Field(\n",
    "        default_factory=list,\n",
    "        description=\"Technologies, tools, or frameworks used in this role\"\n",
    "    )\n",
    "\n",
    "    responsibilities: Optional[List[str]] = Field(\n",
    "        default_factory=list,\n",
    "        description=\"Key responsibilities, tasks, or learnings in concise bullet points keep it summarised detail *not* required\"\n",
    "    )\n",
    "\n",
    "class ProjectItem(BaseModel):\n",
    "    name: str = Field(..., description=\"Project name\")\n",
    "    technologies: List[str] = Field(\n",
    "        default_factory=list,\n",
    "        description=\"Technologies used in this project hence learned during the project.\"\n",
    "    )\n",
    "   \n",
    "\n",
    "\n",
    "class CertificationItem(BaseModel):\n",
    "    name: str = Field(..., description=\"Certification name\")\n",
    "    \n",
    "    topics_covered: List[str] = Field(\n",
    "        default_factory=list,\n",
    "        description=\"Key topics or skills the certification covers\"\n",
    "    )\n",
    "\n",
    "\n",
    "\n",
    "class ResumeExtract(BaseModel):\n",
    "\n",
    "\n",
    "    candidate_name:Optional[str]\n",
    "\n",
    "    \n",
    "    job_title: Optional[str] = Field(\n",
    "    None,\n",
    "    description=(\n",
    "        \"Primary job title or role of the candidate. \"\n",
    "        \"Examples: 'AI Engineer', 'Data Scientist', \"\n",
    "        \"'Construction Project Manager', 'Healthcare Representative'. \"\n",
    "        \"Should reflect the most recent or current role.\"\n",
    "       )\n",
    "    )\n",
    "\n",
    "  \n",
    "\n",
    "   \n",
    "    skills: List[Skill] = Field(\n",
    "        default_factory=list,\n",
    "        description=\"Skills explicitly listed by the candidate\"\n",
    "    )\n",
    "    experience: List[ExperienceItem] = Field(\n",
    "        default_factory=list,\n",
    "        description=(\n",
    "            \"Each role as a separate entry. \"\n",
    "            \"No company name needed — focus on what was done and learned.\"\n",
    "        )\n",
    "    )\n",
    "    projects: List[ProjectItem] = Field(\n",
    "        default_factory=list,\n",
    "        description=\"Projects with technologies used and what was built\"\n",
    "    )\n",
    "    certifications: Optional[List[CertificationItem]] = Field(\n",
    "        None,\n",
    "        description=\"Certifications with topics they cover. None if not present.\"\n",
    "    )\n",
    "    \n",
    "\n",
    "\n",
    "    is_fresher: bool = Field(\n",
    "    ...,\n",
    "    description=(\n",
    "        \"Set to True if the candidate lacks full-time professional employment. \"\n",
    "        \"Academic projects, certifications, and internships are considered \"\n",
    "        \"part of the learning phase and do not qualify a candidate as 'non-fresher' hence is_.\"\n",
    "    )\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "99ac1086",
   "metadata": {},
   "source": [
    "  \"skills\": {\"__all__\": {\"category\"}}, # Drops 'category' from every skill\n",
    "            \"experience\": {\"__all__\": {\"responsibilities\"}}, # Drops bullet points\n",
    "            \"projects\": {\"__all__\": {\"what_was_built\"}}, # Drops project descriptions\n",
    "            \"certifications\": {\"__all__\": {\"issuer\"}} # Drops the issuer"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5b0756e0",
   "metadata": {},
   "source": [
    "Pydantic model for job description"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4b2441cd",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pydantic import BaseModel, Field\n",
    "from typing import List, Optional\n",
    "\n",
    "\n",
    "class SkillRequirement(BaseModel):\n",
    "    name: str = Field(\n",
    "        ...,\n",
    "        description=\"Skill or technology required for the job (e.g., Python, SQL, React)\"\n",
    "    )\n",
    "    level: Optional[str] = Field(\n",
    "        None,\n",
    "        description=\"Expected proficiency level: beginner | intermediate | strong\"\n",
    "    )\n",
    "\n",
    "\n",
    "class ResponsibilityItem(BaseModel):\n",
    "    description: str = Field(\n",
    "        ...,\n",
    "        description=\"Key responsibility or task expected from the candidate\"\n",
    "    )\n",
    "\n",
    "\n",
    "class RequirementItem(BaseModel):\n",
    "    description: str = Field(\n",
    "        ...,\n",
    "        description=\"Qualification or requirement such as education, availability, etc.\"\n",
    "    )\n",
    "\n",
    "\n",
    "class ConstraintItem(BaseModel):\n",
    "    type: str = Field(\n",
    "        ...,\n",
    "        description=\"Constraint type such as location, duration, eligibility\"\n",
    "    )\n",
    "    value: str = Field(\n",
    "        ...,\n",
    "        description=\"Constraint value (e.g., 'Pune only', '6 months', 'Fresher')\"\n",
    "    )\n",
    "\n",
    "\n",
    "\n",
    "class JobDescriptionExtract(BaseModel):\n",
    "    job_title: Optional[str] = Field(\n",
    "        None,\n",
    "        description=\"Job role/title (e.g., AI/ML Intern, Web Developer)\"\n",
    "    )\n",
    "\n",
    "    company_name: Optional[str] = Field(\n",
    "        None,\n",
    "        description=\"Company offering the job\"\n",
    "    )\n",
    "\n",
    "    location: Optional[str] = Field(\n",
    "        None,\n",
    "        description=\"Job location if specified\"\n",
    "    )\n",
    "\n",
    "    employment_type: Optional[str] = Field(\n",
    "        None,\n",
    "        description=\"Type of job: internship, full-time, contract\"\n",
    "    )\n",
    "\n",
    "    duration_months: Optional[int] = Field(\n",
    "        None,\n",
    "        description=\"Duration of role in months (for internships/contracts)\"\n",
    "    )\n",
    "\n",
    "    is_fresher_allowed: Optional[bool] = Field(\n",
    "        None,\n",
    "        description=\"Whether freshers are eligible for this role\"\n",
    "    )\n",
    "\n",
    "    skills_required: Optional[List[SkillRequirement]] = Field(\n",
    "        None,\n",
    "        description=\"List of required skills and expected levels\"\n",
    "    )\n",
    "\n",
    "    tools_technologies: Optional[List[str]] = Field(\n",
    "        None,\n",
    "        description=\"Specific tools/frameworks mentioned (e.g., Pandas, WordPress)\"\n",
    "    )\n",
    "\n",
    "    responsibilities: Optional[List[ResponsibilityItem]] = Field(\n",
    "        None,\n",
    "        description=\"Key job responsibilities\"\n",
    "    )\n",
    "\n",
    "    requirements: Optional[List[RequirementItem]] = Field(\n",
    "        None,\n",
    "        description=\"General requirements like availability, qualifications\"\n",
    "    )\n",
    "\n",
    "    constraints: Optional[List[ConstraintItem]] = Field(\n",
    "        None,\n",
    "        description=\"Special constraints like location restriction, duration, etc.\"\n",
    "    )"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4b12a3bc",
   "metadata": {},
   "source": [
    "**Pydantic model for skill gap analysis**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "4f1341e0",
   "metadata": {},
   "outputs": [],
   "source": [
    "class SkillGap(BaseModel):\n",
    "    skill_name: str = Field(\n",
    "        ..., \n",
    "        description=\"The specific technology or tool missing or requiring an upgrade (e.g., 'PostgreSQL')\"\n",
    "    )\n",
    "    \n",
    "    gap_type: Literal[\"missing_foundation\", \"needs_advanced_upgrade\"] = Field(\n",
    "        ...,\n",
    "        description=(\n",
    "            \"missing_foundation: Candidate has no recorded experience in this core requirement. \"\n",
    "            \"needs_advanced_upgrade: Candidate knows the basics but needs role-specific advanced training.\"\n",
    "        )\n",
    "    )\n",
    "    \n",
    "    priority: Literal[\"high\", \"medium\", \"low\"] = Field(\n",
    "        ...,\n",
    "        description=\"How critical this skill is for the target job role.\"\n",
    "    )\n",
    "    \n",
    "    reasoning: str = Field(\n",
    "        ...,\n",
    "        description=(\n",
    "            \"The 'Reasoning Trace'. This MUST be provided for every skill gap identified. \"\n",
    "            \"Explain exactly WHY this gap was flagged based on the resume vs JD comparison. \"\n",
    "            \"Example: 'JD requires FastAPI; candidate has Python experience but no record of using FastAPI framework.'\"\n",
    "        )\n",
    "    )\n",
    "    \n",
    "    target_competency: str = Field(\n",
    "        ...,\n",
    "        description=\"The specific outcome the candidate needs to reach (e.g., 'Build asynchronous database endpoints')\"\n",
    "    )\n",
    "\n",
    "class SkillGapAnalysis(BaseModel):\n",
    "    job_title: str = Field(..., description=\"The target role from the JD\")\n",
    "    candidate_name: Optional[str] = Field(None, description=\"Extracted name from resume\")\n",
    "    \n",
    "    analyzed_gaps: List[SkillGap] = Field(\n",
    "        default_factory=list,\n",
    "        description=\"List of specific technical gaps found between Resume and JD\"\n",
    "    )\n",
    "    \n",
    "    is_fresher_adaptation_needed: bool = Field(\n",
    "        default=False,\n",
    "        description=\"True if foundational corporate/soft-skill modules should be added to the path.\"\n",
    "    )\n",
    "    \n",
    "    executive_summary: str = Field(\n",
    "        ...,\n",
    "        description=\"A 2-3 sentence overview of the candidate's readiness and the primary focus of the onboarding.\"\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "18663bb3",
   "metadata": {},
   "outputs": [],
   "source": [
    "class RoadmapStep(BaseModel):\n",
    "    course_id: str\n",
    "    title: str\n",
    "    reasoning: str = Field(..., description=\"Why this specific course was chosen for this user\")\n",
    "    is_foundation: bool\n",
    "    sequence_order: int = Field(..., description=\"The order in which the course should be taken\")\n",
    "\n",
    "class LearningRoadmap(BaseModel):\n",
    "    candidate_name: str\n",
    "    target_role: str\n",
    "    roadmap: List[RoadmapStep]\n",
    "    onboarding_summary: str"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "679a529f",
   "metadata": {},
   "outputs": [],
   "source": [
    "class SearchCourse(BaseModel):\n",
    "    query:str=Field(..., description=\"The skill to find with  semantic terms (e.g., 'FastAPI', 'PostgreSQL', 'Docker','Enterprise VMS Strategy','Utilization Management')\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "604e9728",
   "metadata": {},
   "source": [
    "**Defining  the agents to be used**"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9036d57e",
   "metadata": {},
   "source": [
    "Resume data extraction agent"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "14dab004",
   "metadata": {},
   "outputs": [],
   "source": [
    "resume_agent=ChatGroq(\n",
    "    model=\"moonshotai/kimi-k2-instruct-0905\",\n",
    "    temperature=0.2,\n",
    ")\n",
    "\n",
    "\n",
    "resume_agent=resume_agent.with_structured_output(\n",
    "\n",
    "    schema=ResumeExtract,\n",
    "    method=\"json_schema\",\n",
    "    include_raw=True,\n",
    "    strict=True\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7683eb69",
   "metadata": {},
   "source": [
    "Job description data extraction agent"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "472dae2f",
   "metadata": {},
   "outputs": [],
   "source": [
    "jd_agent=ChatGroq(\n",
    "    model=\"meta-llama/llama-4-scout-17b-16e-instruct\",\n",
    "    temperature=0.2,\n",
    ")\n",
    "\n",
    "\n",
    "jd_agent=jd_agent.with_structured_output(\n",
    "\n",
    "    schema=JobDescriptionExtract,\n",
    "    method=\"json_schema\",\n",
    "    include_raw=True,\n",
    "    strict=True\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d14736d5",
   "metadata": {},
   "source": [
    "defining the gap analysis agent"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "0d5e3b17",
   "metadata": {},
   "outputs": [],
   "source": [
    "gap_analysis_agent=ChatGroq(\n",
    "    model=\"moonshotai/kimi-k2-instruct-0905\",\n",
    "    temperature=0.2,\n",
    ")\n",
    "\n",
    "\n",
    "gap_analysis_agent=gap_analysis_agent.with_structured_output(\n",
    "    schema=SkillGapAnalysis,\n",
    "    method=\"json_schema\",\n",
    "    include_raw=True,\n",
    "    strict=True\n",
    ")\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "28bc58ad",
   "metadata": {},
   "source": [
    "defining the roadmap planner agent"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "0ccc026b",
   "metadata": {},
   "outputs": [],
   "source": [
    "rd_planner_agent=ChatGroq(\n",
    "    model=\"openai/gpt-oss-120b\",\n",
    "    temperature=0.1,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2bd41131",
   "metadata": {},
   "source": [
    "**Tools**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "c8827093",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Index ready: {'_response_info': {'raw_headers': {'connection': 'keep-alive',\n",
      "                                    'content-length': '187',\n",
      "                                    'content-type': 'application/json',\n",
      "                                    'date': 'Tue, 24 Mar 2026 14:52:30 GMT',\n",
      "                                    'grpc-status': '0',\n",
      "                                    'server': 'envoy',\n",
      "                                    'x-envoy-upstream-service-time': '64',\n",
      "                                    'x-pinecone-request-latency-ms': '67',\n",
      "                                    'x-pinecone-response-duration-ms': '69'}},\n",
      " 'dimension': 384,\n",
      " 'index_fullness': 0.0,\n",
      " 'memoryFullness': 0.0,\n",
      " 'metric': 'dotproduct',\n",
      " 'namespaces': {'__default__': {'vector_count': 47}},\n",
      " 'storageFullness': 0.0,\n",
      " 'total_vector_count': 47,\n",
      " 'vector_type': 'dense'}\n"
     ]
    }
   ],
   "source": [
    "\n",
    "\n",
    "PINECONE_API_KEY = os.getenv(\"PINECONE_API_KEY\")\n",
    "pc = Pinecone(api_key=PINECONE_API_KEY)\n",
    "\n",
    "index_name = \"final-catalog-index\"\n",
    "\n",
    "\n",
    "# Create index if not exists\n",
    "if index_name not in pc.list_indexes().names():\n",
    "    pc.create_index(\n",
    "        name=index_name,\n",
    "        dimension=384,\n",
    "        metric=\"dotproduct\",\n",
    "        spec=ServerlessSpec(\n",
    "            cloud=\"aws\",\n",
    "            region=\"us-east-1\"\n",
    "        )\n",
    "    )\n",
    "    print(\"Index created.\")\n",
    "\n",
    "index = pc.Index(index_name)\n",
    "print(\"Index ready:\", index.describe_index_stats())\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "44180d94",
   "metadata": {},
   "source": [
    "Opening the docs for BM25 retriver"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "7561b3a1",
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "from langchain_core.documents import Document\n",
    "\n",
    "\n",
    "doc_path=r\"C:\\Users\\ATHARVA\\Downloads\\my codes\\web\\AdaptiveEngineService\\app\\utils\\langchain_formatted.json\"\n",
    "\n",
    "\n",
    "documents = []\n",
    "\n",
    "# Load the transformed catalog\n",
    "with open(doc_path, \"r\") as f:\n",
    "    data = json.load(f)\n",
    "    for doc in data:\n",
    "        # Create a LangChain Document object for each entry\n",
    "        documents.append(\n",
    "            Document(\n",
    "                page_content=doc[\"page_content\"], \n",
    "                metadata=doc[\"metadata\"]\n",
    "            )\n",
    "        )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "f0845a99",
   "metadata": {},
   "outputs": [],
   "source": [
    "device=torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "c8e6d2a5",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\ATHARVA\\AppData\\Local\\Temp\\ipykernel_7492\\2526755923.py:1: LangChainDeprecationWarning: The class `HuggingFaceEmbeddings` was deprecated in LangChain 0.2.2 and will be removed in 1.0. An updated version of the class exists in the `langchain-huggingface package and should be used instead. To use it run `pip install -U `langchain-huggingface` and import as `from `langchain_huggingface import HuggingFaceEmbeddings``.\n",
      "  embeddings = HuggingFaceEmbeddings(model_name=\"sentence-transformers/all-MiniLM-L6-v2\", model_kwargs={\"device\": device})\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "86dbcd8effee4deaac275a8cd43f19c3",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Loading weights:   0%|          | 0/103 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "BertModel LOAD REPORT from: sentence-transformers/all-MiniLM-L6-v2\n",
      "Key                     | Status     |  | \n",
      "------------------------+------------+--+-\n",
      "embeddings.position_ids | UNEXPECTED |  | \n",
      "\n",
      "Notes:\n",
      "- UNEXPECTED\t:can be ignored when loading from different task/architecture; not ok if you expect identical arch.\n"
     ]
    }
   ],
   "source": [
    "embeddings = HuggingFaceEmbeddings(model_name=\"sentence-transformers/all-MiniLM-L6-v2\", model_kwargs={\"device\": device})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "6bc7292f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "2c3b9d66d82549a8bd12615b72b8732c",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/50 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "bm25_encoder = BM25Encoder()\n",
    "\n",
    "bm25_encoder.fit([doc.page_content for doc in documents])\n",
    "\n",
    "retriever = PineconeHybridSearchRetriever(\n",
    "    embeddings=embeddings,\n",
    "    sparse_encoder=bm25_encoder,\n",
    "    index=index,\n",
    "    alpha=0.5\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "03c755a1",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_core.tools import tool\n",
    "from typing import Optional\n",
    "\n",
    "@tool(args_schema=SearchCourse)\n",
    "def search_courses(query: str):\n",
    "    \"\"\"\n",
    "    Search the course catalog for relevant modules based on a skill query \n",
    "    Args:query:the skill to find with  semantic terms (e.g., 'FastAPI', 'PostgreSQL', 'Docker','Enterprise VMS Strategy','Utilization Management').\n",
    "    \"\"\"\n",
    "    \n",
    "    results = retriever.invoke(\n",
    "        query\n",
    "    )\n",
    "\n",
    "    if not results:\n",
    "        return f\"No courses found  for '{query}'.\"\n",
    "\n",
    "    formatted_output = []\n",
    "    for doc in results:\n",
    "        course_id = doc.metadata.get('course_id', 'N/A')\n",
    "        \n",
    "        # We include the ID for roadmap generation, followed by the full context\n",
    "        # created during the transformation stage (Title, Desc, Outcomes, Prereqs).\n",
    "        course_block = (\n",
    "            f\"ID: {course_id}\\n\"\n",
    "            f\"{doc.page_content}\\n\"\n",
    "            \"---\"\n",
    "        )\n",
    "        formatted_output.append(course_block)\n",
    "\n",
    "    return \"\\n\".join(formatted_output)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "9db28710",
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "from typing import Optional, Dict, Any\n",
    "from langchain_core.tools import tool\n",
    "\n",
    "class CourseLookup:\n",
    "    def __init__(self, catalog_path: str = \"course_catalog.json\"):\n",
    "        self.catalog_path = catalog_path\n",
    "        self.courses_map = {}\n",
    "        self._load_catalog()\n",
    "\n",
    "    def _load_catalog(self):\n",
    "        \"\"\"Loads the catalog into a dictionary for O(1) lookup speed.\"\"\"\n",
    "        try:\n",
    "            with open(self.catalog_path, 'r') as f:\n",
    "                catalog = json.load(f)\n",
    "                # Key the dictionary by course_id for instant retrieval\n",
    "                self.courses_map = {course['course_id']: course for course in catalog}\n",
    "        except FileNotFoundError:\n",
    "            print(f\"Error: {self.catalog_path} not found.\")\n",
    "        except json.JSONDecodeError:\n",
    "            print(f\"Error: Failed to decode {self.catalog_path}.\")\n",
    "\n",
    "    def get_course_details(self, course_id: str) -> Optional[Dict[str, Any]]:\n",
    "        \"\"\"Retrieves full details of a course by its ID.\"\"\"\n",
    "        return self.courses_map.get(course_id)\n",
    "\n",
    "\n",
    "lookup_service = CourseLookup(r\"C:\\Users\\ATHARVA\\Downloads\\my codes\\web\\AdaptiveEngineService\\app\\tools\\Catalog.json\")\n",
    "\n",
    "@tool\n",
    "def get_course_by_id(course_id: str) -> str:\n",
    "    \"\"\"\n",
    "    Retrieves full details for a specific course using its unique course_id.\n",
    "    Use this tool when you find a prerequisite ID in another course and \n",
    "    need to fetch its title, description, and duration to add to the roadmap.\n",
    "    \"\"\"\n",
    "    details = lookup_service.get_course_details(course_id)\n",
    "    if not details:\n",
    "        return f\"Error: Course with ID {course_id} not found in catalog.\"\n",
    "    \n",
    "    # Return a clean string for the agent to process\n",
    "    return json.dumps(details, indent=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "09d238ab",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "@tool(args_schema=LearningRoadmap)\n",
    "def submit_final_roadmap(candidate_name, target_role, roadmap, onboarding_summary):\n",
    "    \"\"\"\n",
    "    STRICTLY call this tool to submit the final structured learning roadmap.\n",
    "    This saves the data to the global system and the graph state.\n",
    "    \"\"\"\n",
    "    \n",
    "    \n",
    "    # Construct the structured JSON\n",
    "    result = {\n",
    "        \"candidate_name\": candidate_name,\n",
    "        \"target_role\": target_role,\n",
    "        \"onboarding_summary\": onboarding_summary,\n",
    "        \"roadmap\": [\n",
    "            step.model_dump() if hasattr(step, \"model_dump\") else step \n",
    "            for step in roadmap\n",
    "        ]\n",
    "    }\n",
    "    \n",
    "    \n",
    "    \n",
    "    # Return to LangGraph (will be stored in state via a post-processing node)\n",
    "    return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "6ad04bc6",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "@tool\n",
    "def submit_mermaid_visualization(mermaid_code: str):\n",
    "    \"\"\"\n",
    "    STRICTLY call this tool to save the Mermaid.js visualization of the roadmap.\n",
    "    \"\"\"\n",
    "    \n",
    "    \n",
    "    # 2. Now this assignment updates the global variable\n",
    "    mermaid_roadmap_code = mermaid_code\n",
    "    \n",
    "    return \"Mermaid visualization saved successfully.\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "285f74bb",
   "metadata": {},
   "outputs": [],
   "source": [
    "roadmap_planner_agent_tools=[search_courses, get_course_by_id,submit_final_roadmap,submit_mermaid_visualization]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "47564782",
   "metadata": {},
   "outputs": [],
   "source": [
    "# roadmap_planner_agent=roadmap_planner_agent.bind_tools(roadmap_planner_agent_tools)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c311f642",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Replace 'roadmap_planner_agent' with your bound model variable\n",
    "# print(roadmap_planner_agent.kwargs.get(\"tools\"))\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2da3f43b",
   "metadata": {},
   "source": [
    "**Trail resume path**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7cfbfc3a",
   "metadata": {},
   "outputs": [],
   "source": [
    "resumepath=r\"c:\\Users\\ATHARVA\\Downloads\\my codes\\python\\machine_learning\\Learning_Files\\ChirayuResume.pdf\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "14f4946c",
   "metadata": {},
   "source": [
    "**Langgraph agent state**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "5deda2bb",
   "metadata": {},
   "outputs": [],
   "source": [
    "class OnboardingState(TypedDict):\n",
    "    candidate_name: Optional[str]\n",
    "    resume_text: str  \n",
    "    file_path: str \n",
    "    job_description: str \n",
    "    messages: Annotated[Sequence[BaseMessage], add_messages]\n",
    "    \n",
    "    # Analysis & Extraction Data\n",
    "    skill_gap_analysis_data: Optional[SkillGapAnalysis]\n",
    "    resume_data: Optional[ResumeExtract]   \n",
    "    extraction_error: Optional[str]         \n",
    "    JobDescriptionExtract_data: Optional[JobDescriptionExtract]\n",
    "    \n",
    "    # --- NEW KEYS FOR OUTPUT ---\n",
    "    mermaid_code: Optional[str]        # Stores the Mermaid visualization string\n",
    "    final_roadmap: Optional[Dict]      # Stores the final structured JSON roadmap"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e54bac6a",
   "metadata": {},
   "source": [
    "**Prompts**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "c8df9934",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_groq import ChatGroq\n",
    "from langchain_core.prompts import ChatPromptTemplate\n",
    "\n",
    "\n",
    "resume_agent_prompt = \"\"\"\n",
    "<role>\n",
    "You are a precise resume parser. Your only job is to extract structured information from a raw resume text.\n",
    "</role>\n",
    "\n",
    "<rules>\n",
    "- Extract ONLY what is explicitly present in the resume. Do NOT infer or hallucinate missing fields.\n",
    "- current_role: the job title stated at the top of the resume or most recent role. If the candidate is a student with no job, set it to \"Student\".\n",
    "- is_fresher: set True ONLY if the candidate has zero professional work experience. Having projects or certifications does NOT make someone non-fresher.\n",
    "- total_experience_years: total years of professional work only. Set 0.0 for freshers.\n",
    "- skills: extract from the explicit skills section only. Do NOT pull skills from project descriptions here.\n",
    "- experience: each role is a SEPARATE entry. Ignore company name. Focus on job_title, technologies used, and what they did or learned.\n",
    "- projects: extract each project separately. Capture technologies and one line on what was built.\n",
    "- certifications: extract ONLY if present. Set null if none found. Include topics the certification covers.\n",
    "- achievements: extract ONLY if present. Set null if none found. Include the domain (e.g. Hackathon, Quiz, Competitive Programming).\n",
    "\n",
    "</rules>\n",
    "\n",
    "<output_format>\n",
    "Return a single valid JSON object matching the schema. No extra text, no markdown, no explanation.\n",
    "</output_format>\n",
    "\n",
    "\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "608efafd",
   "metadata": {},
   "outputs": [],
   "source": [
    "jd_agent_prompt =\"\"\" \n",
    "<role>\n",
    "You are a precise job description parser.\n",
    "Extract structured information from the given job description.\n",
    "</role>\n",
    "\n",
    "<rules>\n",
    "- Extract ONLY explicitly mentioned information. Do NOT infer or hallucinate.\n",
    "\n",
    "- Follow the provided schema strictly.\n",
    "\n",
    "- If a field is not present, return null (not empty list unless schema default applies).\n",
    "\n",
    "- Keep skills atomic (e.g., Python, SQL, React).\n",
    "\n",
    "- Do NOT mix fields:\n",
    "  - skills = only required skills\n",
    "  - responsibilities = what the candidate will do\n",
    "  - constraints = restrictions like location, duration, eligibility\n",
    "\n",
    "- Convert durations like \"6 months\" into integer months.\n",
    "\n",
    "- is_fresher_allowed:\n",
    "  - True only if explicitly allowed\n",
    "  - False only if explicitly restricted\n",
    " \n",
    "</rules>\n",
    "\n",
    "<output_format>\n",
    "Return a valid JSON object only.\n",
    "</output_format> \"\"\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "8a6c1483",
   "metadata": {},
   "outputs": [],
   "source": [
    "gap_analysis_agent_prompt=\"\"\"\n",
    "<role>\n",
    "You are an expert technical assessor and the core intelligence of an AI-driven, adaptive onboarding engine[cite: 5]. \n",
    "Your objective is to parse a new hire's current capabilities against a target job description and identify precise skill gaps to reach role-specific competency[cite: 5].\n",
    "</role>\n",
    "\n",
    "<context>\n",
    "Current corporate onboarding utilizes static, \"one-size-fits-all\" curricula, resulting in significant inefficiencies[cite: 3]. \n",
    "Your ultimate goal is to solve this: you must ensure experienced hires do NOT waste time on known concepts, while ensuring beginners are NOT overwhelmed by advanced modules[cite: 3, 4].\n",
    "</context>\n",
    "\n",
    "<rules>\n",
    "- Cross-reference the JD's `skills_required` and `tools_technologies` against the candidate's `skills_list`, `experience.technologies`, and `projects.technologies`.\n",
    "- Identify Hard Gaps: Technologies explicitly required by the JD that are completely absent from the candidate's profile.\n",
    "- Apply Adaptive Logic (Proficiency Gaps):\n",
    "  - For Experienced Hires: If they possess the skill, DO NOT flag it for basic training. Only flag a gap if they need an advanced, role-specific upgrade based on low duration of use.\n",
    "  - For Beginners/Freshers: Flag foundational gaps and prerequisites heavily to ensure they are prepared before tackling complex JD requirements.\n",
    "- Keep skills atomic and highly specific (e.g., output \"FastAPI\" or \"PostgreSQL\", do NOT output vague terms like \"Backend Frameworks\").\n",
    "- Do NOT hallucinate requirements that are not explicitly stated in the JD data.\n",
    "- Do NOT attempt to build the curriculum or suggest courses yet. Your sole focus is diagnosing the gaps.\n",
    "- Provide a concise `reasoning` string for each identified gap. This reasoning MUST justify why the gap exists based on the user's experience level to prove the adaptive logic.\n",
    "</rules>\n",
    "<output_format>\n",
    "Return a valid JSON object only.\n",
    "</output_format>\n",
    "\n",
    "\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "059e5f86",
   "metadata": {},
   "outputs": [],
   "source": [
    "roadmap_planner_agent_prompt = \"\"\"\n",
    "<role>\n",
    "You are an expert technical onboarding architect.\n",
    "Transform a Skill Gap Analysis into a minimal, logically sequenced learning roadmap.\n",
    "</role>\n",
    "\n",
    "<strict_workflow>\n",
    "STEP 1 — SEARCH\n",
    "For every  gap → call search_courses.\n",
    "Use ONLY course IDs returned by the tool. Never guess IDs.\n",
    "\n",
    "STEP 2 — RESOLVE PREREQUISITES\n",
    "For each retrieved course inspect its prerequisites list.\n",
    "If candidate's resume does NOT prove mastery → call get_course_by_id for each missing prerequisite.\n",
    "Skip courses the candidate already demonstrates via projects or experience.\n",
    "\n",
    "STEP 3 — SEQUENCE\n",
    "Prerequisites always before target modules.\n",
    "sequence_order must be 1, 2, 3... strictly.\n",
    "If is_fresher_adaptation_needed is True → add a professional fundamentals module first.\n",
    "\n",
    "STEP 4 — SUBMIT (TERMINAL STEP)\n",
    "Call submit_final_roadmap ONCE with the complete roadmap.\n",
    "Call submit_mermaid_visualization ONCE with the Mermaid string.\n",
    "After both return → STOP. Do not call any tool again.\n",
    "</strict_workflow>\n",
    "\n",
    "<mermaid_rules>\n",
    "- gap courses → :::gap\n",
    "- known prerequisites → :::known\n",
    "- start node → :::start\n",
    "- end node → :::done\n",
    "- group by week using subgraph\n",
    "</mermaid_rules>\n",
    "\n",
    "<example_mermaid>\n",
    "flowchart TD\n",
    "    A([Start — Candidate's current skills]):::start\n",
    "    subgraph W1[\"Week 1 — Core gaps\"]\n",
    "      B[CS-DOCKER-101\\nDocker & Containerization]:::gap\n",
    "      C[CS-PY-101\\nPython Fundamentals]:::known\n",
    "    end\n",
    "    subgraph W2[\"Week 2 — Role readiness\"]\n",
    "      D[CS-CICD-201\\nCI/CD with GitHub Actions]:::gap\n",
    "    end\n",
    "    Z([Role-ready — DevOps Engineer]):::done\n",
    "    A --> B & C\n",
    "    B --> D\n",
    "    D --> Z\n",
    "    classDef gap   fill:#EEEDFE,stroke:#534AB7,color:#26215C\n",
    "    classDef known fill:#E1F5EE,stroke:#0F6E56,color:#085041\n",
    "    classDef start fill:#1D9E75,stroke:#0F6E56,color:#E1F5EE\n",
    "    classDef done  fill:#534AB7,stroke:#3C3489,color:#EEEDFE\n",
    "</example_mermaid>\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "9c4dea1e",
   "metadata": {},
   "outputs": [],
   "source": [
    "def input_node(state: OnboardingState):\n",
    "    file_path = state.get(\"file_path\")\n",
    "    \n",
    "    print(f\"📂 File path received: {file_path}\")\n",
    "    print(f\"📂 File exists: {os.path.exists(file_path) if file_path else 'NO PATH'}\")\n",
    "\n",
    "    if not file_path:\n",
    "        return {\"extraction_error\": \"Missing file_path in state\"}\n",
    "\n",
    "    try:\n",
    "        loader = PyMuPDFLoader(file_path)\n",
    "        docs = loader.load()\n",
    "        \n",
    "        print(f\"📄 Pages loaded: {len(docs)}\")\n",
    "        \n",
    "        resume_text = \"\\n\".join([doc.page_content for doc in docs])\n",
    "        \n",
    "        print(f\"📄 Text length: {len(resume_text)}\")\n",
    "\n",
    "        return {\n",
    "            \"resume_text\": resume_text,\n",
    "            \"extraction_error\": None\n",
    "        }\n",
    "\n",
    "    except Exception as e:\n",
    "        print(f\"❌ PyMuPDF failed: {str(e)}\")\n",
    "        return {\n",
    "            \"resume_text\": None,\n",
    "            \"extraction_error\": f\"Failed to load resume: {str(e)}\"\n",
    "        }"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "eb13ffc0",
   "metadata": {},
   "outputs": [],
   "source": [
    "def extractResumeDataNode(state: OnboardingState):\n",
    "    resume_text = state.get(\"resume_text\")\n",
    "\n",
    "    # Guard 1 — empty text\n",
    "    if not resume_text or len(resume_text.strip()) < 10:\n",
    "        print(\"❌ RESUME TEXT EMPTY OR TOO SHORT\")\n",
    "        return {\"resume_data\": None, \"extraction_error\": \"Resume text is empty\"}\n",
    "\n",
    "    print(f\"📄 Resume text length: {len(resume_text)} chars\")\n",
    "\n",
    "    messages = [\n",
    "        SystemMessage(content=resume_agent_prompt),\n",
    "        HumanMessage(content=f\"<resume_text>{resume_text}</resume_text>\")\n",
    "    ]\n",
    "\n",
    "    result = resume_agent.invoke(messages)\n",
    "\n",
    "    # Guard 2 — parsing failed\n",
    "    if result.get(\"parsing_error\"):\n",
    "        print(f\"❌ PARSING ERROR: {result['parsing_error']}\")\n",
    "        return {\"resume_data\": None, \"extraction_error\": str(result[\"parsing_error\"])}\n",
    "\n",
    "    # Guard 3 — parsed is None\n",
    "    if result.get(\"parsed\") is None:\n",
    "        print(f\"❌ PARSED IS NONE. RAW OUTPUT: {result.get('raw')}\")\n",
    "        return {\"resume_data\": None, \"extraction_error\": \"LLM returned null schema\"}\n",
    "\n",
    "    print(f\"✅ Resume extracted: {result['parsed'].job_title}\")\n",
    "    return {\"resume_data\": result[\"parsed\"]}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "330acef6",
   "metadata": {},
   "outputs": [],
   "source": [
    "def extractJDDataNode(state: OnboardingState):\n",
    "    # 1. Safety Check: Is the text even in the state?\n",
    "    jd_text = state.get(\"job_description\", \"\")\n",
    "    \n",
    "    if not jd_text or len(jd_text.strip()) < 5:\n",
    "        print(\"DEBUGGER ERROR: job_description text is MISSING from state!\")\n",
    "        return {\"JobDescriptionExtract_data\": JobDescriptionExtract()}\n",
    "\n",
    "    print(f\"DEBUGGER: Sending {len(jd_text)} characters to JD Agent...\")\n",
    "\n",
    "    messages = [\n",
    "        SystemMessage(content=jd_agent_prompt),\n",
    "        HumanMessage(content=f\"EXTRACT FROM THIS TEXT:\\n\\n{jd_text}\")\n",
    "    ]\n",
    "\n",
    "    try:\n",
    "        # 2. Invoke the agent\n",
    "        result = jd_agent.invoke(messages)\n",
    "        \n",
    "        # 3. Handle the 'parsed' key (ensure your chain is configured correctly)\n",
    "        # If result is already the Pydantic object, use it directly.\n",
    "        # If result is a dict with 'parsed', use result['parsed'].\n",
    "        parsed_data = result.get(\"parsed\") if isinstance(result, dict) else result\n",
    "\n",
    "        # 4. Critical Check: Did it actually find anything?\n",
    "        if parsed_data.job_title is None and parsed_data.tools_technologies is None:\n",
    "            print(\"DEBUGGER WARNING: LLM returned empty schema! Checking prompt...\")\n",
    "        else:\n",
    "            print(f\"DEBUGGER SUCCESS: Extracted {parsed_data.job_title}\")\n",
    "\n",
    "        return {\"JobDescriptionExtract_data\": parsed_data}\n",
    "        \n",
    "    except Exception as e:\n",
    "        print(f\"DEBUGGER CRITICAL: Invoke failed: {str(e)}\")\n",
    "        return {\"JobDescriptionExtract_data\": JobDescriptionExtract()}"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "795e2446",
   "metadata": {},
   "source": [
    "removing this  ->\"skills\": {\"__all__\": {\"category\"}}, # Drops 'category' from every skill\n",
    "                \"experience\": {\"__all__\": {\"responsibilities\"}}, # Drops bullet points\n",
    "               \"projects\": {\"__all__\": {\"what_was_built\"}}, # Drops project descriptions\n",
    "              \"certifications\": {\"__all__\": {\"issuer\"}} # Drops the issuer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "7352181c",
   "metadata": {},
   "outputs": [],
   "source": [
    "def skill_gap_node(state: OnboardingState):\n",
    "    \n",
    "    resume_data = state[\"resume_data\"] \n",
    "    candidate_name = state[\"candidate_name\"]\n",
    "    \n",
    "    # To remove noise and reduce size  of the prompt.\n",
    "    lean_resume_dict = resume_data.model_dump(\n",
    "\n",
    "        exclude_none=True # Bonus: Automatically drops any fields that are None/null!\n",
    "    )\n",
    "\n",
    "    raw_jd = state[\"JobDescriptionExtract_data\"]\n",
    "    \n",
    "    # Strip the HR noise and text bloat\n",
    "    lean_jd_dict = raw_jd.model_dump(\n",
    "        exclude={\n",
    "            \n",
    "            \n",
    "            \n",
    "            \n",
    "            \"responsibilities\": True, # Dropping verbose bullet points\n",
    "            \"requirements\": True,\n",
    "            \"constraints\": True\n",
    "        },\n",
    "        exclude_none=True # Drops any null fields\n",
    "    )\n",
    "    \n",
    "    #Convert back to a JSON string if your prompt template requires it\n",
    "    \n",
    "    lean_resume_json = json.dumps(lean_resume_dict, indent=2)\n",
    "\n",
    "\n",
    "    lean_jd_json = json.dumps(lean_jd_dict, indent=2)\n",
    "\n",
    "    messages = [\n",
    "        SystemMessage(content=gap_analysis_agent_prompt),\n",
    "        HumanMessage(content=f\"Users Resume:<lean_resume_json>{lean_resume_json}</lean_resume_json> Job Description:<lean_jd_json>{lean_jd_json}</lean_jd_json>\"),\n",
    "        \n",
    "    ]\n",
    "\n",
    "    \n",
    "    result = gap_analysis_agent.invoke(messages)\n",
    "    analysis_data = result[\"parsed\"] \n",
    "\n",
    "\n",
    "    task_message = HumanMessage(\n",
    "        content=f\"\"\"\n",
    "        Skill Gap Analysis Completed for {state.get('candidate_name')}.\n",
    "        \n",
    "        Gaps Identified:\n",
    "        {analysis_data.model_dump_json(indent=2)}\n",
    "        \n",
    "        Please proceed to search for courses and build the learning roadmap now.\n",
    "        \"\"\"\n",
    "    )\n",
    "\n",
    "    return {\"skill_gap_analysis_data\": result[\"parsed\"],\"messages\": [task_message]}\n",
    "\n",
    "\n",
    "    \n",
    "\n",
    "   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1fb2f0d1",
   "metadata": {},
   "outputs": [],
   "source": [
    "# def roadmap_planning_node(state: OnboardingState):\n",
    "#     \"\"\"\n",
    "#     The agent's 'thinking' node. It looks at the Skill Gaps and \n",
    "#     decides which tool to call next.\n",
    "#     \"\"\"\n",
    "#     skill_gap_data = state[\"skill_gap_analysis_data\"]\n",
    "\n",
    "#     skill_gap_data= skill_gap_data.model_dump()\n",
    "\n",
    "#     system_prompt = SystemMessage(content=roadmap_planner_agent_prompt)\n",
    "#     input_msg = HumanMessage(content=f\"<skill_gap_data> {skill_gap_data} </skill_gap_data>\")\n",
    "    \n",
    "#     response = roadmap_planner_agent.invoke([system_prompt, input_msg] + state[\"messages\"])\n",
    "\n",
    "    \n",
    "    \n",
    "#     return {\"messages\": [response]}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "cea90664",
   "metadata": {},
   "outputs": [],
   "source": [
    "def finalize_state_node(state: OnboardingState):\n",
    "    \"\"\"\n",
    "    Final node that extracts structured data from the message scratchpad\n",
    "    and populates the main state keys. No global variables needed!\n",
    "    \"\"\"\n",
    "    final_roadmap = None\n",
    "    mermaid_code = None\n",
    "\n",
    "    # We search the messages in reverse to find the LATEST tool calls\n",
    "    for msg in reversed(state[\"messages\"]):\n",
    "        # Check if the message has tool calls (this will be an AIMessage)\n",
    "        if hasattr(msg, \"tool_calls\") and msg.tool_calls:\n",
    "            for tool_call in msg.tool_calls:\n",
    "                \n",
    "                # 1. Extract the Roadmap JSON\n",
    "                if tool_call[\"name\"] == \"submit_final_roadmap\":\n",
    "                    final_roadmap = tool_call[\"args\"]\n",
    "                \n",
    "                # 2. Extract the Mermaid String\n",
    "                elif tool_call[\"name\"] == \"submit_mermaid_visualization\":\n",
    "                    mermaid_code = tool_call[\"args\"].get(\"mermaid_code\")\n",
    "\n",
    "        # Once we have both, we can stop searching\n",
    "        if final_roadmap and mermaid_code:\n",
    "            break\n",
    "\n",
    "    \n",
    "    \n",
    "    return {\n",
    "        \"final_roadmap\": final_roadmap,\n",
    "        \"mermaid_code\": mermaid_code\n",
    "    }"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "ba9f22e1",
   "metadata": {},
   "outputs": [],
   "source": [
    "tool_node = ToolNode(roadmap_planner_agent_tools)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "668b6787",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain.agents import create_agent\n",
    "from langchain.agents.middleware import ToolCallLimitMiddleware\n",
    "\n",
    "\n",
    "plan_agent=create_agent(\n",
    "    model=rd_planner_agent, \n",
    "    tools=roadmap_planner_agent_tools,\n",
    "    system_prompt=roadmap_planner_agent_prompt,\n",
    "    middleware=[\n",
    "        ToolCallLimitMiddleware[Any,None](\n",
    "           tool_name=\"search_courses\",\n",
    "        run_limit=4,\n",
    "            thread_limit=10,\n",
    "\n",
    "\n",
    "        )\n",
    "\n",
    "   ] ,\n",
    "   )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "id": "b5cfe4c3",
   "metadata": {},
   "outputs": [],
   "source": [
    "builder = StateGraph(OnboardingState)\n",
    "\n",
    "# Define Nodes\n",
    "builder.add_node(\"input_node\", input_node)\n",
    "builder.add_node(\"resume_data_extraction\", extractResumeDataNode)\n",
    "builder.add_node(\"jd_data_extraction\", extractJDDataNode)\n",
    "builder.add_node(\"skill_gap_analysis\", skill_gap_node)\n",
    "\n",
    "# The ReAct Agent Node\n",
    "builder.add_node(\"roadmap_planning_agent\", plan_agent)\n",
    "\n",
    "# The Tool Execution Node (Required for the loop)\n",
    "builder.add_node(\"tools\", ToolNode(roadmap_planner_agent_tools))\n",
    "\n",
    "builder.add_node(\"finalize_state\", finalize_state_node)\n",
    "\n",
    "# 5. Define Edges and Workflow\n",
    "builder.add_edge(START, \"input_node\")\n",
    "builder.add_edge(\"input_node\", \"resume_data_extraction\")\n",
    "builder.add_edge(\"input_node\", \"jd_data_extraction\")\n",
    "\n",
    "# Join Parallel Extractions\n",
    "builder.add_edge(\"resume_data_extraction\", \"skill_gap_analysis\")\n",
    "builder.add_edge(\"jd_data_extraction\", \"skill_gap_analysis\")\n",
    "\n",
    "# Start the Planning Phase\n",
    "builder.add_edge(\"skill_gap_analysis\", \"roadmap_planning_agent\")\n",
    "\n",
    "# Agentic ReAct Loop\n",
    "builder.add_conditional_edges(\n",
    "    \"roadmap_planning_agent\",\n",
    "    tools_condition, # Built-in: routes to \"tools\" if the model calls a tool\n",
    "    {\n",
    "        \"tools\": \"tools\",\n",
    "        END: \"finalize_state\" # Routes to finalize if the model gives a final answer\n",
    "    }\n",
    ")\n",
    "\n",
    "# Loop back to agent after tool execution\n",
    "builder.add_edge(\"tools\", \"roadmap_planning_agent\")\n",
    "\n",
    "# 6. Compile\n",
    "graph = builder.compile()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "53588a77",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAawAAAKOCAIAAAB1JrpbAAAQAElEQVR4nOzdBWATZx8G8PeSutLS0pYipbgXZ8CA4TYKw12HDmfocNfBkAGDb/iAAcOGjgEb7gyH4las7m1y3z+5EtI2SdM2SXPp8/v4uuQsl8vdk1cud1Y8zzMAgJzKigEA5GAIQQDI0RCCAJCjIQQBIEdDCAJAjoYQBIAcDSFoMM/uRt6/GhXyJlEm4+UyJpfxUitOlsRzEsZ4JpFK5HI5L6cJORrC8fRfJpye9OksJU4x3Sccp/g/L+etrCRJSbwwSjGQp1l5iZSj5WuYh1e8nPJVPo9SDZFIOFoF9XW2smE2NhJ7F6lvIfsK9dwZQM7D4TzBLPrvTOi1E+FRoUkUNBIrZm0jsXOUUHgxuYSTMl7GhBBkysdMmX2KsKI/9Jcmo6ySC2nFc0I2KlKOS55MzqTWnCxBrsy/5NykRxIphazw+qoATQ47VeR9ClohGxlTS0MVqbViQGKsPCFOLpMxW3sufzGHxt19GECOgRDMvJtnw87t/5CUxHL7WAfUzVW8oisTs6jwhNP7Pr64G5uYIPctah/Y35cB5AAIwUzaNOtJZJiscHnHxl0trdz06GbEyZ0fkuLlrQb7euW3ZwAWDSGYGctHBrl7WXUe68cs15k/313/O6JsLZfarfMwAMuFEMywlaOCAr5yrNEiRzScrfw+qOW3PvmKOTIAC4UQzJiVo4PqdfYsIfLmvwxZNTaoWAW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AEgBwNIQgAOdr/AQAA//+t2zc5AAAABklEQVQDAAfU67jZBd+iAAAAAElFTkSuQmCC",
      "text/plain": [
       "<langgraph.graph.state.CompiledStateGraph object at 0x000002003BEEA360>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(graph)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "0edf8d59",
   "metadata": {},
   "outputs": [],
   "source": [
    "jd_text=\"\"\"Job Title: Backend Developer\n",
    "\n",
    "Company name: CodeForge\n",
    "We are hiring a Backend Developer to build scalable APIs and backend systems.\n",
    "\n",
    "Responsibilities:\n",
    "- Develop REST APIs using FastAPI\n",
    "- Design and manage PostgreSQL databases\n",
    "- Implement authentication and authorization systems\n",
    "- Optimize performance and scalability\n",
    "\n",
    "Requirements:\n",
    "- Strong knowledge of Python\n",
    "- Experience with FastAPI or Django\n",
    "- Good understanding of SQL and database design\n",
    "- Familiarity with Docker\n",
    "\n",
    "Constraints:\n",
    "- Location: Pune only\n",
    "- Full-time role \"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "da3df5a4",
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "\n",
    "# Define the keys your React frontend actually needs\n",
    "REQUIRED_KEYS = [\"candidate_name\", \"skill_gap_analysis_data\", \"mermaid_code\", \"final_roadmap\"]\n",
    "\n",
    "def export_ui_payload(state, filename=\"hook_output.json\"):\n",
    "    \"\"\"\n",
    "    Extracts specific keys from the graph state and ensures \n",
    "    Pydantic objects are dumped to dicts for JSON compatibility.\n",
    "    \"\"\"\n",
    "    ui_data = {}\n",
    "\n",
    "    for key in REQUIRED_KEYS:\n",
    "        # Get the value from the state\n",
    "        val = state.get(key)\n",
    "        \n",
    "        if val is None:\n",
    "            continue\n",
    "\n",
    "        # Check if the value is a Pydantic object (has .model_dump())\n",
    "        # This fixes the \"skill_gap_analysis_data as a string\" issue\n",
    "        if hasattr(val, \"model_dump\"):\n",
    "            ui_data[key] = val.model_dump()\n",
    "        else:\n",
    "            # If it's already a dict (final_roadmap) or string (mermaid_code)\n",
    "            ui_data[key] = val\n",
    "\n",
    "    # Save to the local file\n",
    "    with open(filename, \"w\", encoding=\"utf-8\") as f:\n",
    "        json.dump(ui_data, f, indent=2)\n",
    "    \n",
    "    print(f\"✅ UI Payload successfully exported to {filename}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "a95b4db7",
   "metadata": {},
   "outputs": [],
   "source": [
    "initial_input = {\n",
    "    \"candidate_name\": \"Chirayu Jain\",\n",
    "    \"resume_text\": None,\n",
    "    \"job_description\": jd_text,\n",
    "    \"file_path\": r\"C:\\Users\\ATHARVA\\Downloads\\my codes\\web\\AdaptiveEngineService\\AI_Engine_Evaluation\\Testcases\\Testresume\\ChirayuResume.pdf\",\n",
    "    \"resume_data\": None,\n",
    "    \"extraction_error\": None,\n",
    "    \"JobDescriptionExtract_data\": None,\n",
    "    \"skill_gap_analysis_data\": None\n",
    "    \n",
    "    \n",
    "}\n",
    "import uuid\n",
    "\n",
    "\n",
    "checkpointer = MemorySaver()  \n",
    "graph = builder.compile(checkpointer=checkpointer)\n",
    "\n",
    "THREAD_ID = str(uuid.uuid4())\n",
    "\n",
    "\n",
    "\n",
    "config = {\"configurable\": {\"thread_id\": THREAD_ID,\"langgraph_user_id\": \"Chirayu Jain\"}}\n",
    "\n",
    "# final_state = graph.invoke(initial_input, config=config)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "id": "093bdd6e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "\n",
    "def run_graph_with_stream(graph, initial_input, config):\n",
    "    \"\"\"\n",
    "    Executes the graph in streaming mode to visualize the 'under the hood' \n",
    "    process of node transitions and data updates.\n",
    "    \"\"\"\n",
    "    print(\"🚀 Starting Graph Stream...\\n\")\n",
    "    \n",
    "    # Using stream_mode=\"updates\" to see exactly what each node returns\n",
    "    for event in graph.stream(initial_input, config, stream_mode=\"updates\"):\n",
    "        for node_name, node_update in event.items():\n",
    "            print(f\"--- 📍 Node: {node_name} ---\")\n",
    "            \n",
    "            # 1. Check for Tool Calls (The 'ReAct' thinking process)\n",
    "            if \"messages\" in node_update:\n",
    "                last_msg = node_update[\"messages\"][-1]\n",
    "                if hasattr(last_msg, \"tool_calls\") and last_msg.tool_calls:\n",
    "                    for tool in last_msg.tool_calls:\n",
    "                        print(f\"🛠️  AGENT CALLING TOOL: {tool['name']}\")\n",
    "                        print(f\"📝 ARGS: {json.dumps(tool['args'], indent=2)}\")\n",
    "                elif hasattr(last_msg, \"content\") and last_msg.content:\n",
    "                    # Show a snippet of the AI's internal reasoning\n",
    "                    content_snippet = last_msg.content[:150].replace('\\n', ' ')\n",
    "                    print(f\"🧠 AI THOUGHT: {content_snippet}...\")\n",
    "\n",
    "            # 2. Check for Data Extraction (JD/Resume results)\n",
    "            if \"JobDescriptionExtract_data\" in node_update:\n",
    "                jd = node_update[\"JobDescriptionExtract_data\"]\n",
    "                print(f\"✅ Extracted JD: {getattr(jd, 'job_title', 'Unknown')}\")\n",
    "            \n",
    "            if \"resume_data\" in node_update:\n",
    "                res = node_update[\"resume_data\"]\n",
    "                print(f\"✅ Extracted Resume for: {getattr(res, 'candidate_name', 'Unknown')}\")\n",
    "\n",
    "            # 3. Check for the final output keys\n",
    "            if \"skill_gap_analysis_data\" in node_update:\n",
    "                print(\"🎯 Skill Gap Analysis Completed.\")\n",
    "                \n",
    "            if \"learning_roadmap\" in node_update or \"final_roadmap\" in node_update:\n",
    "                print(\"🏁 Final Roadmap Constructed.\")\n",
    "\n",
    "            print(\"\\n\" + \"=\"*50 + \"\\n\")\n",
    "\n",
    "    # Access the final state after the stream ends\n",
    "    final_state = graph.get_state(config)\n",
    "    print(\"✨ Stream Finished. Final state captured.\")\n",
    "    return final_state.values\n",
    "\n",
    "# --- Example Usage ---\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "db595a54",
   "metadata": {},
   "outputs": [],
   "source": [
    "///break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7a36ecb1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "🚀 Starting Graph Stream...\n",
      "\n",
      "📂 File path received: C:\\Users\\ATHARVA\\Downloads\\my codes\\web\\AdaptiveEngineService\\AI_Engine_Evaluation\\Testcases\\Testresume\\ChirayuResume.pdf\n",
      "📂 File exists: True\n",
      "📄 Pages loaded: 1\n",
      "📄 Text length: 3156\n",
      "--- 📍 Node: input_node ---\n",
      "\n",
      "==================================================\n",
      "\n",
      "DEBUGGER: Sending 525 characters to JD Agent...\n",
      "📄 Resume text length: 3156 chars\n",
      "DEBUGGER SUCCESS: Extracted Backend Developer\n",
      "✅ Resume extracted: Software Developer\n",
      "--- 📍 Node: jd_data_extraction ---\n",
      "✅ Extracted JD: Backend Developer\n",
      "\n",
      "==================================================\n",
      "\n",
      "--- 📍 Node: resume_data_extraction ---\n",
      "✅ Extracted Resume for: Chirayu Jain\n",
      "\n",
      "==================================================\n",
      "\n",
      "--- 📍 Node: skill_gap_analysis ---\n",
      "🧠 AI THOUGHT:          Skill Gap Analysis Completed for Chirayu Jain.          Gaps Identified:         {   \"job_title\": \"Backend Developer\",   \"candidate_name\": \"C...\n",
      "🎯 Skill Gap Analysis Completed.\n",
      "\n",
      "==================================================\n",
      "\n",
      "--- 📍 Node: roadmap_planning_agent ---\n",
      "🧠 AI THOUGHT: The learning roadmap for **Chirayu Jain** has been finalized and visualized.  **Roadmap Summary** - **Target Role:** Backend Developer   - **Onboardin...\n",
      "\n",
      "==================================================\n",
      "\n",
      "--- 📍 Node: finalize_state ---\n",
      "🏁 Final Roadmap Constructed.\n",
      "\n",
      "==================================================\n",
      "\n",
      "✨ Stream Finished. Final state captured.\n"
     ]
    }
   ],
   "source": [
    "config = {\"configurable\": {\"thread_id\": \"gyujj\"}}\n",
    "final_result = run_graph_with_stream(graph, initial_input, config)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "4e502949",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'candidate_name': 'Chirayu Jain',\n",
       " 'resume_text': 'Chirayu Jain\\nSOFTWARE DEVELOPER\\n+91-9462128878 | chirayujain93@gmail.com | LinkedIn | GitHub | CodeChef | Leetcode\\nEDUCATION\\nIndian Institute of Information Technology, Kota (CGPA-8.1)\\nKota, Rajasthan\\nB.Tech in Electronics and Communication Engineering\\n2022 - Present\\nWORK EXPERIENCE\\nNAV India\\nJan 2026 - Present\\nTechnology Intern\\nOnsite – Jaipur, Rajasthan\\n• As part of the AI/ML team, built Flask API for the RTA investor verification team, implementing 2\\nconfidence-scoring pipelines using OCR extraction (PyMuPDF, Docling) to parse PDF/forms and\\nextract 3 key KYC investor attributes, reducing verification time from 20–30 minutes to 2–3 minutes.\\n• Developed a scalable document intelligence pipeline with parallel CPU processing using Docling OCR,\\nsemantic chunking, and LLM-based extraction to process 60+ page financial documents and identify\\ninvestor/investee details, reducing extraction time by 35%.\\n• Implementing Cron-based background workers to generate automated weekly email analytics reports\\ntracking API accuracy and confidence match-mismatch scores, improving scoring precision and reducing\\noverall document processing latency by 40%.\\nVestbox\\nApril 2025 - May 2025\\nSoftware Development intern\\nRemote\\n• Developed Groceazy app in Flutter (MVVM), integrating 10+ modules for grocery service , order management\\nand Applied clean code practices (SOLID, modular design) for scalability.\\n• Implemented secure user authentication and role-based access, ensuring smooth login and data protection.\\n• Built image-to-item price matcher using APIs across 5+ platforms, enabling best-price suggestions.\\nPROJECTS\\nHostel Bites – IIITK Canteen App | Flutter, Dart, Firebase, Cloud Firestore, Mapbox API\\n• Developed a Flutter app for hostel residents to order food, increasing canteen efficiency by 35%.\\n• Implemented role-based access for students, staff, and admin, increasing operational efficiency by 40%.\\n• Integrated Firebase Auth, Firestore, Storage, and Mapbox API for secure logins, and live order tracking.\\n• GitHub: Live link\\nJobShield - Fake Job Detector | Flutter, Dart, Python, Flask, SQLite\\n• Developed a Flask+Python fake job detection API with a custom NLP model, with 95% classification accuracy.\\n• Built a responsive web interface using Flutter (Web), integrated with the backend, enabling seamless real-time\\ndetection for 500+ job postings.\\n• Github: Live Link\\nTECHNICAL SKILLS\\nLanguages: C/C++ , Java , Python , JavaScript, Dart\\nFrontend: Flutter, HTML/CSS, ReactJS\\nBackend: Firebase, REST APIs, Flask, Django, NodeJS, ExpressJS\\nDatabase Management: MySQL, MongoDB, SQLite\\nTools and Frameworks: GitHub, Android Studio, Visual Studio Code, MATLAB, Cursor, Github Copilot\\nLibraries: Provider, Bloc, Scikit-learn, tensorflow\\nACHIEVEMENTS & CERTIFICATIONS\\n• Ranked 81 in Inter IIIT Coding Contest Optigo, competing against top-tier programmers - View credential.\\n• Obtained Certification in Graph Algorithms from AlgoUniversity - View credential.\\n• Achieved a 4-star CodeChef rating and earned the Knight(Max. 1888) badge on LeetCode.\\n• Developed an e-waste facility locator application for SIH’23, successfully advancing to the regionals.',\n",
       " 'file_path': 'C:\\\\Users\\\\ATHARVA\\\\Downloads\\\\my codes\\\\web\\\\AdaptiveEngineService\\\\AI_Engine_Evaluation\\\\Testcases\\\\Testresume\\\\ChirayuResume.pdf',\n",
       " 'job_description': 'Job Title: Backend Developer\\n\\nCompany name: CodeForge\\nWe are hiring a Backend Developer to build scalable APIs and backend systems.\\n\\nResponsibilities:\\n- Develop REST APIs using FastAPI\\n- Design and manage PostgreSQL databases\\n- Implement authentication and authorization systems\\n- Optimize performance and scalability\\n\\nRequirements:\\n- Strong knowledge of Python\\n- Experience with FastAPI or Django\\n- Good understanding of SQL and database design\\n- Familiarity with Docker\\n\\nConstraints:\\n- Location: Pune only\\n- Full-time role ',\n",
       " 'messages': [HumanMessage(content='\\n        Skill Gap Analysis Completed for Chirayu Jain.\\n\\n        Gaps Identified:\\n        {\\n  \"job_title\": \"Backend Developer\",\\n  \"candidate_name\": \"Chirayu Jain\",\\n  \"analyzed_gaps\": [\\n    {\\n      \"skill_name\": \"FastAPI\",\\n      \"gap_type\": \"missing_foundation\",\\n      \"priority\": \"high\",\\n      \"reasoning\": \"JD explicitly lists FastAPI; resume shows Flask/Django but no exposure to FastAPI, creating a core framework gap.\",\\n      \"target_competency\": \"Build async REST endpoints with FastAPI, Pydantic models and dependency injection\"\\n    },\\n    {\\n      \"skill_name\": \"PostgreSQL\",\\n      \"gap_type\": \"missing_foundation\",\\n      \"priority\": \"high\",\\n      \"reasoning\": \"JD requires PostgreSQL; candidate only lists MySQL, SQLite and MongoDB, so no evidence of PostgreSQL-specific features or deployment experience.\",\\n      \"target_competency\": \"Design relational schemas, write optimized queries and manage transactions in PostgreSQL\"\\n    },\\n    {\\n      \"skill_name\": \"Docker\",\\n      \"gap_type\": \"missing_foundation\",\\n      \"priority\": \"high\",\\n      \"reasoning\": \"Docker appears in JD but is absent from skills, experience and projects, indicating no containerization background.\",\\n      \"target_competency\": \"Containerize FastAPI services, write Dockerfiles and orchestrate multi-container dev environments\"\\n    }\\n  ],\\n  \"is_fresher_adaptation_needed\": false,\\n  \"executive_summary\": \"Chirayu is a near-ready backend candidate with solid Python, Django and SQL experience, but must quickly add FastAPI, PostgreSQL and Docker to meet CodeForge’s stack requirements.\"\\n}\\n\\n        Please proceed to search for courses and build the learning roadmap now.\\n        ', additional_kwargs={}, response_metadata={}, id='61350c0a-f333-4b0b-bce8-b002d5c13832'),\n",
       "  AIMessage(content='', additional_kwargs={'reasoning_content': \"We need to follow workflow.\\n\\nStep 1: For each gap skill, call search_courses with query.\\n\\nWe have three gaps: FastAPI, PostgreSQL, Docker.\\n\\nWe need to get course IDs.\\n\\nLet's call search_courses for FastAPI.\", 'tool_calls': [{'id': 'fc_6c1f8c83-94ad-438c-8ff4-772fc7e3a5a2', 'function': {'arguments': '{\"query\":\"FastAPI\"}', 'name': 'search_courses'}, 'type': 'function'}]}, response_metadata={'token_usage': {'completion_tokens': 78, 'prompt_tokens': 1285, 'total_tokens': 1363, 'completion_time': 0.167971032, 'completion_tokens_details': {'reasoning_tokens': 50}, 'prompt_time': 0.061565999, 'prompt_tokens_details': None, 'queue_time': 0.04593067, 'total_time': 0.229537031}, 'model_name': 'openai/gpt-oss-120b', 'system_fingerprint': 'fp_a09bde29de', 'service_tier': 'on_demand', 'finish_reason': 'tool_calls', 'logprobs': None, 'model_provider': 'groq'}, id='lc_run--019d206b-c546-75f2-9bee-3a75dc5dc28a-0', tool_calls=[{'name': 'search_courses', 'args': {'query': 'FastAPI'}, 'id': 'fc_6c1f8c83-94ad-438c-8ff4-772fc7e3a5a2', 'type': 'tool_call'}], invalid_tool_calls=[], usage_metadata={'input_tokens': 1285, 'output_tokens': 78, 'total_tokens': 1363, 'output_token_details': {'reasoning': 50}}),\n",
       "  ToolMessage(content=\"ID: CS-FAST-101\\nCourse Title: REST API Development with FastAPI\\nCategory: Backend\\nDescription: A project-driven course for building production-quality REST APIs with Python's FastAPI framework. Students learn to define typed routes with path and query parameters, leverage Pydantic models for automatic request validation and serialization, implement dependency injection, and secure endpoints using JWT-based Bearer token authentication.\\nLearning Outcomes: Create REST endpoints with path and query params, Validate request/response with Pydantic models, Implement JWT-based authentication\\nPrerequisites: CS-PY-101\\n---\\nID: CS-FAST-201\\nCourse Title: Advanced API Design with FastAPI\\nCategory: Backend\\nDescription: An advanced course for engineers building high-performance, secure backend services with FastAPI. Students implement full OAuth2 authorization code and client credentials flows, build async database CRUD endpoints using SQLAlchemy 2.0 with asyncpg, design layered dependency injection architectures, create custom middleware for logging and rate limiting, and run Celery background task queues.\\nLearning Outcomes: Implement OAuth2 authentication flows, Build async database endpoints with SQLAlchemy, Use dependency injection and middleware patterns\\nPrerequisites: CS-PY-101, CS-DB-101, CS-FAST-101\\n---\\nID: CS-MLOPS-301\\nCourse Title: MLOps — Model Deployment & Monitoring\\nCategory: AI Engineering\\nDescription: An end-to-end MLOps course covering the full lifecycle of production machine learning systems. Students track experiments and version datasets and models using MLflow, build model serving APIs with FastAPI, containerize inference services with Docker, set up automated retraining pipelines triggered by data drift detection using Evidently AI, and monitor prediction quality and infrastructure health with Grafana dashboards.\\nLearning Outcomes: Track experiments and version models with MLflow, Serve ML models via FastAPI and Docker, Monitor model drift and set up retraining triggers\\nPrerequisites: CS-ML-101, CS-DOCKER-101, CS-FAST-101\\n---\\nID: OPS-K8S-101\\nCourse Title: Kubernetes for AI Workloads\\nCategory: MLOps\\nDescription: An introduction to K8s specifically for ML engineers. Covers pod orchestration, GPU resource allocation, and scaling FastAPI backends on clusters.\\nLearning Outcomes: Deploy ML models as K8s services, Configure GPU-enabled worker nodes, Manage cluster auto-scaling for inference bursts\\nPrerequisites: None\\n---\", name='search_courses', id='be522420-9402-497c-b37a-55f859017f39', tool_call_id='fc_6c1f8c83-94ad-438c-8ff4-772fc7e3a5a2'),\n",
       "  AIMessage(content='', additional_kwargs={'reasoning_content': 'We have FastAPI courses. Need also PostgreSQL and Docker courses. Search for PostgreSQL.', 'tool_calls': [{'id': 'fc_cfcddbeb-b919-4f79-98e2-2000cdf9c354', 'function': {'arguments': '{\"query\":\"PostgreSQL\"}', 'name': 'search_courses'}, 'type': 'function'}]}, response_metadata={'token_usage': {'completion_tokens': 45, 'prompt_tokens': 1809, 'total_tokens': 1854, 'completion_time': 0.09460185, 'completion_tokens_details': {'reasoning_tokens': 20}, 'prompt_time': 0.614039222, 'prompt_tokens_details': {'cached_tokens': 768}, 'queue_time': 0.045160052, 'total_time': 0.708641072}, 'model_name': 'openai/gpt-oss-120b', 'system_fingerprint': 'fp_626f3fc5e0', 'service_tier': 'on_demand', 'finish_reason': 'tool_calls', 'logprobs': None, 'model_provider': 'groq'}, id='lc_run--019d206b-dc84-7312-8d72-172aa51c0a1b-0', tool_calls=[{'name': 'search_courses', 'args': {'query': 'PostgreSQL'}, 'id': 'fc_cfcddbeb-b919-4f79-98e2-2000cdf9c354', 'type': 'tool_call'}], invalid_tool_calls=[], usage_metadata={'input_tokens': 1809, 'output_tokens': 45, 'total_tokens': 1854, 'input_token_details': {'cache_read': 768}, 'output_token_details': {'reasoning': 20}}),\n",
       "  ToolMessage(content='ID: CS-DB-101\\nCourse Title: SQL Fundamentals for Backend Developers\\nCategory: Database\\nDescription: A hands-on introduction to relational database theory and practice using SQLite and PostgreSQL. Students learn to model data with schemas, enforce referential integrity through primary and foreign keys, and interact with data using full CRUD operations and multi-table JOINs.\\nLearning Outcomes: Write basic SELECT queries with filters, Understand Primary and Foreign Keys, Perform data insertion, updates, and deletions\\nPrerequisites: None\\n---\\nID: CS-DB-201\\nCourse Title: Advanced SQL — Indexing, Transactions & Query Optimization\\nCategory: Database\\nDescription: A deep dive into production-grade SQL performance and reliability. Students master analytical window functions, Common Table Expressions (CTEs), query execution plan analysis using EXPLAIN/ANALYZE, B-tree and partial index strategies, and ACID-compliant transaction management including deadlock detection and prevention.\\nLearning Outcomes: Use window functions and CTEs, Analyze and optimize slow queries with EXPLAIN, Manage ACID transactions and deadlock prevention\\nPrerequisites: CS-DB-101\\n---\\nID: BUS-SQL-201\\nCourse Title: SQL for Workforce Analytics\\nCategory: Data Science\\nDescription: Learn to query internal talent databases. Covers JOINs, aggregations, and subqueries to find hiring trends and predict churn.\\nLearning Outcomes: Write SQL queries to extract talent metrics, Analyze historical hiring data for trends, Build basic labor supply reports\\nPrerequisites: BUS-DATA-101\\n---\\nID: CS-DB-301\\nCourse Title: NoSQL Databases — MongoDB & Redis\\nCategory: Database\\nDescription: Practical training in document and key-value store paradigms for modern applications. Covers MongoDB schema design, flexible document modeling, the aggregation pipeline for complex data transformations, and Redis as both a high-speed caching layer and a pub/sub message broker with TTL-based eviction strategies.\\nLearning Outcomes: Design document schemas in MongoDB, Build aggregation pipelines, Implement caching with Redis TTL strategies\\nPrerequisites: CS-DB-101\\n---', name='search_courses', id='5f602c21-b2c8-4611-9f68-1e4f127958cb', tool_call_id='fc_cfcddbeb-b919-4f79-98e2-2000cdf9c354'),\n",
       "  AIMessage(content='', additional_kwargs={'reasoning_content': 'We have three gaps: FastAPI, PostgreSQL, Docker.\\n\\nWe need to search for Docker courses.', 'tool_calls': [{'id': 'fc_68440688-509a-4a4d-ae5f-b46d16b4a8fc', 'function': {'arguments': '{\"query\":\"Docker\"}', 'name': 'search_courses'}, 'type': 'function'}]}, response_metadata={'token_usage': {'completion_tokens': 45, 'prompt_tokens': 2260, 'total_tokens': 2305, 'completion_time': 0.095418158, 'completion_tokens_details': {'reasoning_tokens': 22}, 'prompt_time': 0.28257033, 'prompt_tokens_details': {'cached_tokens': 1280}, 'queue_time': 0.045485127, 'total_time': 0.377988488}, 'model_name': 'openai/gpt-oss-120b', 'system_fingerprint': 'fp_a09bde29de', 'service_tier': 'on_demand', 'finish_reason': 'tool_calls', 'logprobs': None, 'model_provider': 'groq'}, id='lc_run--019d206b-e355-7100-8e37-9e09f7cf0a97-0', tool_calls=[{'name': 'search_courses', 'args': {'query': 'Docker'}, 'id': 'fc_68440688-509a-4a4d-ae5f-b46d16b4a8fc', 'type': 'tool_call'}], invalid_tool_calls=[], usage_metadata={'input_tokens': 2260, 'output_tokens': 45, 'total_tokens': 2305, 'input_token_details': {'cache_read': 1280}, 'output_token_details': {'reasoning': 22}}),\n",
       "  ToolMessage(content='ID: CS-DOCKER-101\\nCourse Title: Docker & Containerization Fundamentals\\nCategory: DevOps\\nDescription: A practical guide to application containerization using Docker. Students learn to write optimized multi-stage Dockerfiles, manage images and container lifecycles, configure bridge and overlay networking, use named volumes for data persistence, and orchestrate multi-service applications with Docker Compose for local and staging environments.\\nLearning Outcomes: Write efficient multi-stage Dockerfiles, Manage container lifecycle and networking, Orchestrate multi-service apps with Docker Compose\\nPrerequisites: None\\n---\\nID: CS-CICD-201\\nCourse Title: CI/CD Pipelines with GitHub Actions\\nCategory: DevOps\\nDescription: A hands-on course in automating the full software delivery lifecycle using GitHub Actions. Students define multi-job workflows with matrix builds, integrate linting and pytest test suites as required CI checks, automate Docker image builds and pushes to registries, and manage environment secrets and deployment approvals for staging and production environments.\\nLearning Outcomes: Create GitHub Actions workflows for CI/CD, Automate Docker image builds and pushes, Manage secrets and environment variables securely\\nPrerequisites: CS-DOCKER-101\\n---\\nID: CS-MLOPS-301\\nCourse Title: MLOps — Model Deployment & Monitoring\\nCategory: AI Engineering\\nDescription: An end-to-end MLOps course covering the full lifecycle of production machine learning systems. Students track experiments and version datasets and models using MLflow, build model serving APIs with FastAPI, containerize inference services with Docker, set up automated retraining pipelines triggered by data drift detection using Evidently AI, and monitor prediction quality and infrastructure health with Grafana dashboards.\\nLearning Outcomes: Track experiments and version models with MLflow, Serve ML models via FastAPI and Docker, Monitor model drift and set up retraining triggers\\nPrerequisites: CS-ML-101, CS-DOCKER-101, CS-FAST-101\\n---\\nID: CS-K8S-301\\nCourse Title: Kubernetes — Container Orchestration at Scale\\nCategory: DevOps\\nDescription: A comprehensive course on running containerized workloads in production with Kubernetes. Students deploy stateless and stateful applications using Deployments and StatefulSets, expose services through ClusterIP, NodePort, and Ingress controllers, manage configuration and secrets with ConfigMaps and Secrets, autoscale workloads with HPA, and package applications for repeatable releases using Helm charts.\\nLearning Outcomes: Deploy applications using Deployments and StatefulSets, Configure Services, Ingress, and ConfigMaps, Manage releases with Helm charts\\nPrerequisites: CS-DOCKER-101, CS-CICD-201\\n---', name='search_courses', id='00e1a0f1-f97e-46b6-9f4d-ee55fc23c17d', tool_call_id='fc_68440688-509a-4a4d-ae5f-b46d16b4a8fc'),\n",
       "  AIMessage(content='', additional_kwargs={'reasoning_content': 'We have identified gaps: FastAPI, PostgreSQL, Docker. Need to search for courses for each. Already have courses:\\n\\nFastAPI: CS-FAST-101 (prereq CS-PY-101). Also CS-FAST-201 (prereq CS-PY-101, CS-DB-101, CS-FAST-101). Likely choose CS-FAST-101 as foundation.\\n\\nPostgreSQL: CS-DB-101 covers SQLite and PostgreSQL fundamentals. No explicit prerequisite. Also CS-DB-201 advanced. Choose CS-DB-101.\\n\\nDocker: CS-DOCKER-101 fundamentals, no prereq.\\n\\nNow need to resolve prerequisites: For CS-FAST-101, prerequisite CS-PY-101 (Python Fundamentals). Candidate has solid Python, Django experience. Likely resume shows Python mastery, so we can consider that as known. The instruction: \"Skip courses the candidate already demonstrates via projects or experience.\" So we can treat CS-PY-101 as known, not needed to include.\\n\\nCheck other courses for prerequisites: none else.\\n\\nThus roadmap includes three courses: CS-FAST-101, CS-DB-101, CS-DOCKER-101. Sequence: prerequisites before target modules. Since no dependencies among these three (except maybe Docker before FastAPI? Not required). Could order logically: start with Docker fundamentals (foundation for containerizing FastAPI later), then PostgreSQL fundamentals, then FastAPI. Or any order. We\\'ll assign sequence_order 1,2,3.\\n\\nis_fresher_adaptation_needed false, so no professional fundamentals module.\\n\\nNow need to build roadmap array with fields: course_id, is_foundation (boolean). Probably true for foundation courses? Let\\'s set is_foundation true for all three as they are foundational.\\n\\nReasoning: brief.\\n\\nNow need to create mermaid visualization following rules: gap courses ::gap, known prerequisites ::known, start node ::start, end node ::done. Since we are not adding known courses (CS-PY-101) as nodes, but we could include as known? The rules: known prerequisites should be marked ::known. Since we are skipping CS-PY-101, maybe we don\\'t include it. But we could include it as known to show prerequisite satisfied. Let\\'s include a node for CS-PY-101 as known.\\n\\nAlso start node: candidate\\'s current skills.\\n\\nEnd node: Role-ready — Backend Developer.\\n\\nGroup by week using subgraph. Let\\'s assign weeks: Week 1 Docker, Week 2 PostgreSQL, Week 3 FastAPI.\\n\\nMermaid code accordingly.\\n\\nNow need to call submit_final_roadmap with candidate_name, onboarding_summary (maybe executive summary), roadmap array, target_role \"Backend Developer\".\\n\\nThen submit_mermaid_visualization with code.\\n\\nProceed.', 'tool_calls': [{'id': 'fc_e1fad88b-3a4b-4877-a3df-369362707126', 'function': {'arguments': '{\"candidate_name\":\"Chirayu Jain\",\"onboarding_summary\":\"Chirayu is a near-ready backend candidate with solid Python, Django and SQL experience, but must quickly add FastAPI, PostgreSQL and Docker to meet CodeForge’s stack requirements.\",\"roadmap\":[{\"course_id\":\"CS-DOCKER-101\",\"is_foundation\":true,\"reasoning\":\"Provides essential containerization skills required to package FastAPI services for deployment.\",\"sequence_order\":1,\"title\":\"Docker \\\\u0026 Containerization Fundamentals\"},{\"course_id\":\"CS-DB-101\",\"is_foundation\":true,\"reasoning\":\"Covers PostgreSQL fundamentals, enabling design of relational schemas and optimized queries for the target role.\",\"sequence_order\":2,\"title\":\"SQL Fundamentals for Backend Developers\"},{\"course_id\":\"CS-FAST-101\",\"is_foundation\":true,\"reasoning\":\"Introduces FastAPI, the primary framework listed in the JD, building async REST endpoints and Pydantic models.\",\"sequence_order\":3,\"title\":\"REST API Development with FastAPI\"}],\"target_role\":\"Backend Developer\"}', 'name': 'submit_final_roadmap'}, 'type': 'function'}]}, response_metadata={'token_usage': {'completion_tokens': 864, 'prompt_tokens': 2825, 'total_tokens': 3689, 'completion_time': 1.891397937, 'completion_tokens_details': {'reasoning_tokens': 564}, 'prompt_time': 0.145777084, 'prompt_tokens_details': {'cached_tokens': 1792}, 'queue_time': 0.045268224, 'total_time': 2.037175021}, 'model_name': 'openai/gpt-oss-120b', 'system_fingerprint': 'fp_626f3fc5e0', 'service_tier': 'on_demand', 'finish_reason': 'tool_calls', 'logprobs': None, 'model_provider': 'groq'}, id='lc_run--019d206b-ee19-7900-a734-70259374603f-0', tool_calls=[{'name': 'submit_final_roadmap', 'args': {'candidate_name': 'Chirayu Jain', 'onboarding_summary': 'Chirayu is a near-ready backend candidate with solid Python, Django and SQL experience, but must quickly add FastAPI, PostgreSQL and Docker to meet CodeForge’s stack requirements.', 'roadmap': [{'course_id': 'CS-DOCKER-101', 'is_foundation': True, 'reasoning': 'Provides essential containerization skills required to package FastAPI services for deployment.', 'sequence_order': 1, 'title': 'Docker & Containerization Fundamentals'}, {'course_id': 'CS-DB-101', 'is_foundation': True, 'reasoning': 'Covers PostgreSQL fundamentals, enabling design of relational schemas and optimized queries for the target role.', 'sequence_order': 2, 'title': 'SQL Fundamentals for Backend Developers'}, {'course_id': 'CS-FAST-101', 'is_foundation': True, 'reasoning': 'Introduces FastAPI, the primary framework listed in the JD, building async REST endpoints and Pydantic models.', 'sequence_order': 3, 'title': 'REST API Development with FastAPI'}], 'target_role': 'Backend Developer'}, 'id': 'fc_e1fad88b-3a4b-4877-a3df-369362707126', 'type': 'tool_call'}], invalid_tool_calls=[], usage_metadata={'input_tokens': 2825, 'output_tokens': 864, 'total_tokens': 3689, 'input_token_details': {'cache_read': 1792}, 'output_token_details': {'reasoning': 564}}),\n",
       "  ToolMessage(content='{\"candidate_name\": \"Chirayu Jain\", \"target_role\": \"Backend Developer\", \"onboarding_summary\": \"Chirayu is a near-ready backend candidate with solid Python, Django and SQL experience, but must quickly add FastAPI, PostgreSQL and Docker to meet CodeForge’s stack requirements.\", \"roadmap\": [{\"course_id\": \"CS-DOCKER-101\", \"title\": \"Docker & Containerization Fundamentals\", \"reasoning\": \"Provides essential containerization skills required to package FastAPI services for deployment.\", \"is_foundation\": true, \"sequence_order\": 1}, {\"course_id\": \"CS-DB-101\", \"title\": \"SQL Fundamentals for Backend Developers\", \"reasoning\": \"Covers PostgreSQL fundamentals, enabling design of relational schemas and optimized queries for the target role.\", \"is_foundation\": true, \"sequence_order\": 2}, {\"course_id\": \"CS-FAST-101\", \"title\": \"REST API Development with FastAPI\", \"reasoning\": \"Introduces FastAPI, the primary framework listed in the JD, building async REST endpoints and Pydantic models.\", \"is_foundation\": true, \"sequence_order\": 3}]}', name='submit_final_roadmap', id='5fb8c861-d353-4034-a0c8-d1c17aeabcd6', tool_call_id='fc_e1fad88b-3a4b-4877-a3df-369362707126'),\n",
       "  AIMessage(content='', additional_kwargs={'reasoning_content': \"We have submitted final roadmap. Need to also submit mermaid visualization. Must follow rules: gap courses ::gap, known prerequisites ::known, start ::start, end ::done. In this case all three are gaps (they are missing foundations). However they have prerequisites: CS-FAST-101 prerequisite CS-PY-101, CS-DB-101 has none, CS-DOCKER-101 none. Candidate already has Python foundation, so we can treat CS-PY-101 as known prerequisite. Need to include it as known node. Sequence: start -> CS-DOCKER-101 (gap) -> CS-DB-101 (gap) -> CS-FAST-101 (gap) -> end. Also include CS-PY-101 as known prerequisite for FastAPI, placed before FastAPI maybe in same week or earlier. Since FastAPI depends on Python fundamentals, we should include known node before FastAPI. Could be in same week as FastAPI but as known. We'll create weeks: Week1 Docker, Week2 PostgreSQL, Week3 Python fundamentals (known) and FastAPI (gap). Or maybe include known before gap in same week.\\n\\nMermaid format: flowchart TD. Use subgraph W1, W2, W3.\\n\\nAdd class definitions.\\n\\nNow call submit_mermaid_visualization.\", 'tool_calls': [{'id': 'fc_ea8b8113-e478-45dd-a8b4-bf2eae927d9a', 'function': {'arguments': '{\"mermaid_code\":\"flowchart TD\\\\n    A([Start — Current Skills]):::start\\\\n    subgraph W1[\\\\\"Week 1 — Containerization\\\\\"]\\\\n        B[CS-DOCKER-101\\\\\\\\nDocker \\\\u0026 Containerization Fundamentals]:::gap\\\\n    end\\\\n    subgraph W2[\\\\\"Week 2 — Relational DB\\\\\"]\\\\n        C[CS-DB-101\\\\\\\\nSQL Fundamentals for Backend Developers]:::gap\\\\n    end\\\\n    subgraph W3[\\\\\"Week 3 — API Development\\\\\"]\\\\n        D[CS-PY-101\\\\\\\\nPython Fundamentals]:::known\\\\n        E[CS-FAST-101\\\\\\\\nREST API Development with FastAPI]:::gap\\\\n    end\\\\n    Z([Backend Developer — Role Ready]):::done\\\\n    A --\\\\u003e B --\\\\u003e C --\\\\u003e D --\\\\u003e E --\\\\u003e Z\\\\n    classDef gap   fill:#EEEDFE,stroke:#534AB7,color:#26215C\\\\n    classDef known fill:#E1F5EE,stroke:#0F6E56,color:#085041\\\\n    classDef start fill:#1D9E75,stroke:#0F6E56,color:#E1F5EE\\\\n    classDef done  fill:#534AB7,stroke:#3C3489,color:#EEEDFE\"}', 'name': 'submit_mermaid_visualization'}, 'type': 'function'}]}, response_metadata={'token_usage': {'completion_tokens': 557, 'prompt_tokens': 3339, 'total_tokens': 3896, 'completion_time': 1.196030062, 'completion_tokens_details': {'reasoning_tokens': 266}, 'prompt_time': 0.160108793, 'prompt_tokens_details': None, 'queue_time': 0.046081046, 'total_time': 1.356138855}, 'model_name': 'openai/gpt-oss-120b', 'system_fingerprint': 'fp_8a618bed98', 'service_tier': 'on_demand', 'finish_reason': 'tool_calls', 'logprobs': None, 'model_provider': 'groq'}, id='lc_run--019d206b-f96f-7ad0-9a9e-fc4e668a8516-0', tool_calls=[{'name': 'submit_mermaid_visualization', 'args': {'mermaid_code': 'flowchart TD\\n    A([Start — Current Skills]):::start\\n    subgraph W1[\"Week 1 — Containerization\"]\\n        B[CS-DOCKER-101\\\\nDocker & Containerization Fundamentals]:::gap\\n    end\\n    subgraph W2[\"Week 2 — Relational DB\"]\\n        C[CS-DB-101\\\\nSQL Fundamentals for Backend Developers]:::gap\\n    end\\n    subgraph W3[\"Week 3 — API Development\"]\\n        D[CS-PY-101\\\\nPython Fundamentals]:::known\\n        E[CS-FAST-101\\\\nREST API Development with FastAPI]:::gap\\n    end\\n    Z([Backend Developer — Role Ready]):::done\\n    A --> B --> C --> D --> E --> Z\\n    classDef gap   fill:#EEEDFE,stroke:#534AB7,color:#26215C\\n    classDef known fill:#E1F5EE,stroke:#0F6E56,color:#085041\\n    classDef start fill:#1D9E75,stroke:#0F6E56,color:#E1F5EE\\n    classDef done  fill:#534AB7,stroke:#3C3489,color:#EEEDFE'}, 'id': 'fc_ea8b8113-e478-45dd-a8b4-bf2eae927d9a', 'type': 'tool_call'}], invalid_tool_calls=[], usage_metadata={'input_tokens': 3339, 'output_tokens': 557, 'total_tokens': 3896, 'output_token_details': {'reasoning': 266}}),\n",
       "  ToolMessage(content='Mermaid visualization saved successfully.', name='submit_mermaid_visualization', id='e07fe033-a45e-41ee-b421-caa15afa997d', tool_call_id='fc_ea8b8113-e478-45dd-a8b4-bf2eae927d9a'),\n",
       "  AIMessage(content='The learning roadmap for **Chirayu Jain** has been finalized and visualized.\\n\\n**Roadmap Summary**\\n- **Target Role:** Backend Developer  \\n- **Onboarding Summary:** Near‑ready backend candidate with solid Python, Django and SQL experience; needs FastAPI, PostgreSQL, and Docker to meet CodeForge’s stack.  \\n\\n**Course Sequence**\\n1. **CS-DOCKER-101 – Docker & Containerization Fundamentals** (Foundation)  \\n2. **CS-DB-101 – SQL Fundamentals for Backend Developers** (Foundation)  \\n3. **CS-FAST-101 – REST API Development with FastAPI** (Foundation)  \\n\\n**Mermaid Visualization**\\n```mermaid\\nflowchart TD\\n    A([Start — Current Skills]):::start\\n    subgraph W1[\"Week 1 — Containerization\"]\\n        B[CS-DOCKER-101\\\\nDocker & Containerization Fundamentals]:::gap\\n    end\\n    subgraph W2[\"Week 2 — Relational DB\"]\\n        C[CS-DB-101\\\\nSQL Fundamentals for Backend Developers]:::gap\\n    end\\n    subgraph W3[\"Week 3 — API Development\"]\\n        D[CS-PY-101\\\\nPython Fundamentals]:::known\\n        E[CS-FAST-101\\\\nREST API Development with FastAPI]:::gap\\n    end\\n    Z([Backend Developer — Role Ready]):::done\\n    A --> B --> C --> D --> E --> Z\\n    classDef gap   fill:#EEEDFE,stroke:#534AB7,color:#26215C\\n    classDef known fill:#E1F5EE,stroke:#0F6E56,color:#085041\\n    classDef start fill:#1D9E75,stroke:#0F6E56,color:#E1F5EE\\n    classDef done  fill:#534AB7,stroke:#3C3489,color:#EEEDFE\\n```\\n\\nAll steps are complete.', additional_kwargs={}, response_metadata={'token_usage': {'completion_tokens': 406, 'prompt_tokens': 3646, 'total_tokens': 4052, 'completion_time': 1.438615073, 'completion_tokens_details': None, 'prompt_time': 0.141632128, 'prompt_tokens_details': {'cached_tokens': 2816}, 'queue_time': 0.04638064, 'total_time': 1.5802472010000002}, 'model_name': 'openai/gpt-oss-120b', 'system_fingerprint': 'fp_626f3fc5e0', 'service_tier': 'on_demand', 'finish_reason': 'stop', 'logprobs': None, 'model_provider': 'groq'}, id='lc_run--019d206c-010d-7133-92a9-18ed936df441-0', tool_calls=[], invalid_tool_calls=[], usage_metadata={'input_tokens': 3646, 'output_tokens': 406, 'total_tokens': 4052, 'input_token_details': {'cache_read': 2816}})],\n",
       " 'skill_gap_analysis_data': SkillGapAnalysis(job_title='Backend Developer', candidate_name='Chirayu Jain', analyzed_gaps=[SkillGap(skill_name='FastAPI', gap_type='missing_foundation', priority='high', reasoning='JD explicitly lists FastAPI; resume shows Flask/Django but no exposure to FastAPI, creating a core framework gap.', target_competency='Build async REST endpoints with FastAPI, Pydantic models and dependency injection'), SkillGap(skill_name='PostgreSQL', gap_type='missing_foundation', priority='high', reasoning='JD requires PostgreSQL; candidate only lists MySQL, SQLite and MongoDB, so no evidence of PostgreSQL-specific features or deployment experience.', target_competency='Design relational schemas, write optimized queries and manage transactions in PostgreSQL'), SkillGap(skill_name='Docker', gap_type='missing_foundation', priority='high', reasoning='Docker appears in JD but is absent from skills, experience and projects, indicating no containerization background.', target_competency='Containerize FastAPI services, write Dockerfiles and orchestrate multi-container dev environments')], is_fresher_adaptation_needed=False, executive_summary='Chirayu is a near-ready backend candidate with solid Python, Django and SQL experience, but must quickly add FastAPI, PostgreSQL and Docker to meet CodeForge’s stack requirements.'),\n",
       " 'resume_data': ResumeExtract(candidate_name='Chirayu Jain', job_title='Software Developer', skills=[Skill(name='C/C++', category='Other'), Skill(name='Java', category='Other'), Skill(name='Python', category='Backend'), Skill(name='JavaScript', category='Frontend'), Skill(name='Dart', category='Frontend'), Skill(name='Flutter', category='Frontend'), Skill(name='HTML/CSS', category='Frontend'), Skill(name='ReactJS', category='Frontend'), Skill(name='Firebase', category='Backend'), Skill(name='REST APIs', category='Backend'), Skill(name='Flask', category='Backend'), Skill(name='Django', category='Backend'), Skill(name='NodeJS', category='Backend'), Skill(name='ExpressJS', category='Backend'), Skill(name='MySQL', category='Other'), Skill(name='MongoDB', category='Other'), Skill(name='SQLite', category='Other'), Skill(name='GitHub', category='Other'), Skill(name='Android Studio', category='Other'), Skill(name='Visual Studio Code', category='Other'), Skill(name='MATLAB', category='Other'), Skill(name='Cursor', category='Other'), Skill(name='Github Copilot', category='Other'), Skill(name='Provider', category='Other'), Skill(name='Bloc', category='Other'), Skill(name='Scikit-learn', category='ML'), Skill(name='tensorflow', category='ML')], experience=[ExperienceItem(job_title='Technology Intern', experience_type='internship', technologies=['Flask', 'PyMuPDF', 'Docling', 'OCR', 'Python'], responsibilities=['Built Flask API for RTA investor verification with confidence-scoring pipelines', 'Developed document intelligence pipeline with parallel CPU processing', 'Implementing Cron-based background workers for weekly email analytics reports']), ExperienceItem(job_title='Software Development Intern', experience_type='internship', technologies=['Flutter', 'MVVM', 'Dart'], responsibilities=['Developed Grocezy app in Flutter with 10+ modules', 'Implemented secure user authentication and role-based access', 'Built image-to-item price matcher using APIs'])], projects=[ProjectItem(name='Hostel Bites – IIITK Canteen App', technologies=['Flutter', 'Dart', 'Firebase', 'Cloud Firestore', 'Mapbox API']), ProjectItem(name='JobShield - Fake Job Detector', technologies=['Flutter', 'Dart', 'Python', 'Flask', 'SQLite'])], certifications=[CertificationItem(name='Graph Algorithms Certification from AlgoUniversity', topics_covered=['Graph Algorithms'])], is_fresher=False),\n",
       " 'extraction_error': None,\n",
       " 'JobDescriptionExtract_data': JobDescriptionExtract(job_title='Backend Developer', company_name='CodeForge', location='Pune', employment_type='Full-time role', duration_months=None, is_fresher_allowed=None, skills_required=[SkillRequirement(name='Python', level=None), SkillRequirement(name='FastAPI', level=None), SkillRequirement(name='Django', level=None), SkillRequirement(name='SQL', level=None), SkillRequirement(name='PostgreSQL', level=None), SkillRequirement(name='Docker', level=None)], tools_technologies=None, responsibilities=[ResponsibilityItem(description='Develop REST APIs using FastAPI'), ResponsibilityItem(description='Design and manage PostgreSQL databases'), ResponsibilityItem(description='Implement authentication and authorization systems'), ResponsibilityItem(description='Optimize performance and scalability')], requirements=[RequirementItem(description='Strong knowledge of Python'), RequirementItem(description='Experience with FastAPI or Django'), RequirementItem(description='Good understanding of SQL and database design'), RequirementItem(description='Familiarity with Docker')], constraints=[ConstraintItem(type='location', value='Pune only'), ConstraintItem(type='employment type', value='Full-time role')]),\n",
       " 'mermaid_code': 'flowchart TD\\n    A([Start — Current Skills]):::start\\n    subgraph W1[\"Week 1 — Containerization\"]\\n        B[CS-DOCKER-101\\\\nDocker & Containerization Fundamentals]:::gap\\n    end\\n    subgraph W2[\"Week 2 — Relational DB\"]\\n        C[CS-DB-101\\\\nSQL Fundamentals for Backend Developers]:::gap\\n    end\\n    subgraph W3[\"Week 3 — API Development\"]\\n        D[CS-PY-101\\\\nPython Fundamentals]:::known\\n        E[CS-FAST-101\\\\nREST API Development with FastAPI]:::gap\\n    end\\n    Z([Backend Developer — Role Ready]):::done\\n    A --> B --> C --> D --> E --> Z\\n    classDef gap   fill:#EEEDFE,stroke:#534AB7,color:#26215C\\n    classDef known fill:#E1F5EE,stroke:#0F6E56,color:#085041\\n    classDef start fill:#1D9E75,stroke:#0F6E56,color:#E1F5EE\\n    classDef done  fill:#534AB7,stroke:#3C3489,color:#EEEDFE',\n",
       " 'final_roadmap': {'candidate_name': 'Chirayu Jain',\n",
       "  'onboarding_summary': 'Chirayu is a near-ready backend candidate with solid Python, Django and SQL experience, but must quickly add FastAPI, PostgreSQL and Docker to meet CodeForge’s stack requirements.',\n",
       "  'roadmap': [{'course_id': 'CS-DOCKER-101',\n",
       "    'is_foundation': True,\n",
       "    'reasoning': 'Provides essential containerization skills required to package FastAPI services for deployment.',\n",
       "    'sequence_order': 1,\n",
       "    'title': 'Docker & Containerization Fundamentals'},\n",
       "   {'course_id': 'CS-DB-101',\n",
       "    'is_foundation': True,\n",
       "    'reasoning': 'Covers PostgreSQL fundamentals, enabling design of relational schemas and optimized queries for the target role.',\n",
       "    'sequence_order': 2,\n",
       "    'title': 'SQL Fundamentals for Backend Developers'},\n",
       "   {'course_id': 'CS-FAST-101',\n",
       "    'is_foundation': True,\n",
       "    'reasoning': 'Introduces FastAPI, the primary framework listed in the JD, building async REST endpoints and Pydantic models.',\n",
       "    'sequence_order': 3,\n",
       "    'title': 'REST API Development with FastAPI'}],\n",
       "  'target_role': 'Backend Developer'}}"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "final_result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "53ba21aa",
   "metadata": {},
   "outputs": [],
   "source": [
    "///break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "5afbce5b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[HumanMessage(content='\\n        Skill Gap Analysis Completed for Chirayu Jain.\\n\\n        Gaps Identified:\\n        {\\n  \"job_title\": \"Backend Developer\",\\n  \"candidate_name\": \"Chirayu Jain\",\\n  \"analyzed_gaps\": [\\n    {\\n      \"skill_name\": \"FastAPI\",\\n      \"gap_type\": \"missing_foundation\",\\n      \"priority\": \"high\",\\n      \"reasoning\": \"JD explicitly lists FastAPI; resume shows Flask/Django but no exposure to FastAPI, creating a core framework gap.\",\\n      \"target_competency\": \"Build async REST endpoints with FastAPI, Pydantic models and dependency injection\"\\n    },\\n    {\\n      \"skill_name\": \"PostgreSQL\",\\n      \"gap_type\": \"missing_foundation\",\\n      \"priority\": \"high\",\\n      \"reasoning\": \"JD requires PostgreSQL; candidate only lists MySQL, SQLite and MongoDB, so no evidence of PostgreSQL-specific features or deployment experience.\",\\n      \"target_competency\": \"Design relational schemas, write optimized queries and manage transactions in PostgreSQL\"\\n    },\\n    {\\n      \"skill_name\": \"Docker\",\\n      \"gap_type\": \"missing_foundation\",\\n      \"priority\": \"high\",\\n      \"reasoning\": \"Docker appears in JD but is absent from skills, experience and projects, indicating no containerization background.\",\\n      \"target_competency\": \"Containerize FastAPI services, write Dockerfiles and orchestrate multi-container dev environments\"\\n    }\\n  ],\\n  \"is_fresher_adaptation_needed\": false,\\n  \"executive_summary\": \"Chirayu is a near-ready backend candidate with solid Python, Django and SQL experience, but must quickly add FastAPI, PostgreSQL and Docker to meet CodeForge’s stack requirements.\"\\n}\\n\\n        Please proceed to search for courses and build the learning roadmap now.\\n        ', additional_kwargs={}, response_metadata={}, id='61350c0a-f333-4b0b-bce8-b002d5c13832'),\n",
       " AIMessage(content='', additional_kwargs={'reasoning_content': \"We need to follow workflow.\\n\\nStep 1: For each gap skill, call search_courses with query.\\n\\nWe have three gaps: FastAPI, PostgreSQL, Docker.\\n\\nWe need to get course IDs.\\n\\nLet's call search_courses for FastAPI.\", 'tool_calls': [{'id': 'fc_6c1f8c83-94ad-438c-8ff4-772fc7e3a5a2', 'function': {'arguments': '{\"query\":\"FastAPI\"}', 'name': 'search_courses'}, 'type': 'function'}]}, response_metadata={'token_usage': {'completion_tokens': 78, 'prompt_tokens': 1285, 'total_tokens': 1363, 'completion_time': 0.167971032, 'completion_tokens_details': {'reasoning_tokens': 50}, 'prompt_time': 0.061565999, 'prompt_tokens_details': None, 'queue_time': 0.04593067, 'total_time': 0.229537031}, 'model_name': 'openai/gpt-oss-120b', 'system_fingerprint': 'fp_a09bde29de', 'service_tier': 'on_demand', 'finish_reason': 'tool_calls', 'logprobs': None, 'model_provider': 'groq'}, id='lc_run--019d206b-c546-75f2-9bee-3a75dc5dc28a-0', tool_calls=[{'name': 'search_courses', 'args': {'query': 'FastAPI'}, 'id': 'fc_6c1f8c83-94ad-438c-8ff4-772fc7e3a5a2', 'type': 'tool_call'}], invalid_tool_calls=[], usage_metadata={'input_tokens': 1285, 'output_tokens': 78, 'total_tokens': 1363, 'output_token_details': {'reasoning': 50}}),\n",
       " ToolMessage(content=\"ID: CS-FAST-101\\nCourse Title: REST API Development with FastAPI\\nCategory: Backend\\nDescription: A project-driven course for building production-quality REST APIs with Python's FastAPI framework. Students learn to define typed routes with path and query parameters, leverage Pydantic models for automatic request validation and serialization, implement dependency injection, and secure endpoints using JWT-based Bearer token authentication.\\nLearning Outcomes: Create REST endpoints with path and query params, Validate request/response with Pydantic models, Implement JWT-based authentication\\nPrerequisites: CS-PY-101\\n---\\nID: CS-FAST-201\\nCourse Title: Advanced API Design with FastAPI\\nCategory: Backend\\nDescription: An advanced course for engineers building high-performance, secure backend services with FastAPI. Students implement full OAuth2 authorization code and client credentials flows, build async database CRUD endpoints using SQLAlchemy 2.0 with asyncpg, design layered dependency injection architectures, create custom middleware for logging and rate limiting, and run Celery background task queues.\\nLearning Outcomes: Implement OAuth2 authentication flows, Build async database endpoints with SQLAlchemy, Use dependency injection and middleware patterns\\nPrerequisites: CS-PY-101, CS-DB-101, CS-FAST-101\\n---\\nID: CS-MLOPS-301\\nCourse Title: MLOps — Model Deployment & Monitoring\\nCategory: AI Engineering\\nDescription: An end-to-end MLOps course covering the full lifecycle of production machine learning systems. Students track experiments and version datasets and models using MLflow, build model serving APIs with FastAPI, containerize inference services with Docker, set up automated retraining pipelines triggered by data drift detection using Evidently AI, and monitor prediction quality and infrastructure health with Grafana dashboards.\\nLearning Outcomes: Track experiments and version models with MLflow, Serve ML models via FastAPI and Docker, Monitor model drift and set up retraining triggers\\nPrerequisites: CS-ML-101, CS-DOCKER-101, CS-FAST-101\\n---\\nID: OPS-K8S-101\\nCourse Title: Kubernetes for AI Workloads\\nCategory: MLOps\\nDescription: An introduction to K8s specifically for ML engineers. Covers pod orchestration, GPU resource allocation, and scaling FastAPI backends on clusters.\\nLearning Outcomes: Deploy ML models as K8s services, Configure GPU-enabled worker nodes, Manage cluster auto-scaling for inference bursts\\nPrerequisites: None\\n---\", name='search_courses', id='be522420-9402-497c-b37a-55f859017f39', tool_call_id='fc_6c1f8c83-94ad-438c-8ff4-772fc7e3a5a2'),\n",
       " AIMessage(content='', additional_kwargs={'reasoning_content': 'We have FastAPI courses. Need also PostgreSQL and Docker courses. Search for PostgreSQL.', 'tool_calls': [{'id': 'fc_cfcddbeb-b919-4f79-98e2-2000cdf9c354', 'function': {'arguments': '{\"query\":\"PostgreSQL\"}', 'name': 'search_courses'}, 'type': 'function'}]}, response_metadata={'token_usage': {'completion_tokens': 45, 'prompt_tokens': 1809, 'total_tokens': 1854, 'completion_time': 0.09460185, 'completion_tokens_details': {'reasoning_tokens': 20}, 'prompt_time': 0.614039222, 'prompt_tokens_details': {'cached_tokens': 768}, 'queue_time': 0.045160052, 'total_time': 0.708641072}, 'model_name': 'openai/gpt-oss-120b', 'system_fingerprint': 'fp_626f3fc5e0', 'service_tier': 'on_demand', 'finish_reason': 'tool_calls', 'logprobs': None, 'model_provider': 'groq'}, id='lc_run--019d206b-dc84-7312-8d72-172aa51c0a1b-0', tool_calls=[{'name': 'search_courses', 'args': {'query': 'PostgreSQL'}, 'id': 'fc_cfcddbeb-b919-4f79-98e2-2000cdf9c354', 'type': 'tool_call'}], invalid_tool_calls=[], usage_metadata={'input_tokens': 1809, 'output_tokens': 45, 'total_tokens': 1854, 'input_token_details': {'cache_read': 768}, 'output_token_details': {'reasoning': 20}}),\n",
       " ToolMessage(content='ID: CS-DB-101\\nCourse Title: SQL Fundamentals for Backend Developers\\nCategory: Database\\nDescription: A hands-on introduction to relational database theory and practice using SQLite and PostgreSQL. Students learn to model data with schemas, enforce referential integrity through primary and foreign keys, and interact with data using full CRUD operations and multi-table JOINs.\\nLearning Outcomes: Write basic SELECT queries with filters, Understand Primary and Foreign Keys, Perform data insertion, updates, and deletions\\nPrerequisites: None\\n---\\nID: CS-DB-201\\nCourse Title: Advanced SQL — Indexing, Transactions & Query Optimization\\nCategory: Database\\nDescription: A deep dive into production-grade SQL performance and reliability. Students master analytical window functions, Common Table Expressions (CTEs), query execution plan analysis using EXPLAIN/ANALYZE, B-tree and partial index strategies, and ACID-compliant transaction management including deadlock detection and prevention.\\nLearning Outcomes: Use window functions and CTEs, Analyze and optimize slow queries with EXPLAIN, Manage ACID transactions and deadlock prevention\\nPrerequisites: CS-DB-101\\n---\\nID: BUS-SQL-201\\nCourse Title: SQL for Workforce Analytics\\nCategory: Data Science\\nDescription: Learn to query internal talent databases. Covers JOINs, aggregations, and subqueries to find hiring trends and predict churn.\\nLearning Outcomes: Write SQL queries to extract talent metrics, Analyze historical hiring data for trends, Build basic labor supply reports\\nPrerequisites: BUS-DATA-101\\n---\\nID: CS-DB-301\\nCourse Title: NoSQL Databases — MongoDB & Redis\\nCategory: Database\\nDescription: Practical training in document and key-value store paradigms for modern applications. Covers MongoDB schema design, flexible document modeling, the aggregation pipeline for complex data transformations, and Redis as both a high-speed caching layer and a pub/sub message broker with TTL-based eviction strategies.\\nLearning Outcomes: Design document schemas in MongoDB, Build aggregation pipelines, Implement caching with Redis TTL strategies\\nPrerequisites: CS-DB-101\\n---', name='search_courses', id='5f602c21-b2c8-4611-9f68-1e4f127958cb', tool_call_id='fc_cfcddbeb-b919-4f79-98e2-2000cdf9c354'),\n",
       " AIMessage(content='', additional_kwargs={'reasoning_content': 'We have three gaps: FastAPI, PostgreSQL, Docker.\\n\\nWe need to search for Docker courses.', 'tool_calls': [{'id': 'fc_68440688-509a-4a4d-ae5f-b46d16b4a8fc', 'function': {'arguments': '{\"query\":\"Docker\"}', 'name': 'search_courses'}, 'type': 'function'}]}, response_metadata={'token_usage': {'completion_tokens': 45, 'prompt_tokens': 2260, 'total_tokens': 2305, 'completion_time': 0.095418158, 'completion_tokens_details': {'reasoning_tokens': 22}, 'prompt_time': 0.28257033, 'prompt_tokens_details': {'cached_tokens': 1280}, 'queue_time': 0.045485127, 'total_time': 0.377988488}, 'model_name': 'openai/gpt-oss-120b', 'system_fingerprint': 'fp_a09bde29de', 'service_tier': 'on_demand', 'finish_reason': 'tool_calls', 'logprobs': None, 'model_provider': 'groq'}, id='lc_run--019d206b-e355-7100-8e37-9e09f7cf0a97-0', tool_calls=[{'name': 'search_courses', 'args': {'query': 'Docker'}, 'id': 'fc_68440688-509a-4a4d-ae5f-b46d16b4a8fc', 'type': 'tool_call'}], invalid_tool_calls=[], usage_metadata={'input_tokens': 2260, 'output_tokens': 45, 'total_tokens': 2305, 'input_token_details': {'cache_read': 1280}, 'output_token_details': {'reasoning': 22}}),\n",
       " ToolMessage(content='ID: CS-DOCKER-101\\nCourse Title: Docker & Containerization Fundamentals\\nCategory: DevOps\\nDescription: A practical guide to application containerization using Docker. Students learn to write optimized multi-stage Dockerfiles, manage images and container lifecycles, configure bridge and overlay networking, use named volumes for data persistence, and orchestrate multi-service applications with Docker Compose for local and staging environments.\\nLearning Outcomes: Write efficient multi-stage Dockerfiles, Manage container lifecycle and networking, Orchestrate multi-service apps with Docker Compose\\nPrerequisites: None\\n---\\nID: CS-CICD-201\\nCourse Title: CI/CD Pipelines with GitHub Actions\\nCategory: DevOps\\nDescription: A hands-on course in automating the full software delivery lifecycle using GitHub Actions. Students define multi-job workflows with matrix builds, integrate linting and pytest test suites as required CI checks, automate Docker image builds and pushes to registries, and manage environment secrets and deployment approvals for staging and production environments.\\nLearning Outcomes: Create GitHub Actions workflows for CI/CD, Automate Docker image builds and pushes, Manage secrets and environment variables securely\\nPrerequisites: CS-DOCKER-101\\n---\\nID: CS-MLOPS-301\\nCourse Title: MLOps — Model Deployment & Monitoring\\nCategory: AI Engineering\\nDescription: An end-to-end MLOps course covering the full lifecycle of production machine learning systems. Students track experiments and version datasets and models using MLflow, build model serving APIs with FastAPI, containerize inference services with Docker, set up automated retraining pipelines triggered by data drift detection using Evidently AI, and monitor prediction quality and infrastructure health with Grafana dashboards.\\nLearning Outcomes: Track experiments and version models with MLflow, Serve ML models via FastAPI and Docker, Monitor model drift and set up retraining triggers\\nPrerequisites: CS-ML-101, CS-DOCKER-101, CS-FAST-101\\n---\\nID: CS-K8S-301\\nCourse Title: Kubernetes — Container Orchestration at Scale\\nCategory: DevOps\\nDescription: A comprehensive course on running containerized workloads in production with Kubernetes. Students deploy stateless and stateful applications using Deployments and StatefulSets, expose services through ClusterIP, NodePort, and Ingress controllers, manage configuration and secrets with ConfigMaps and Secrets, autoscale workloads with HPA, and package applications for repeatable releases using Helm charts.\\nLearning Outcomes: Deploy applications using Deployments and StatefulSets, Configure Services, Ingress, and ConfigMaps, Manage releases with Helm charts\\nPrerequisites: CS-DOCKER-101, CS-CICD-201\\n---', name='search_courses', id='00e1a0f1-f97e-46b6-9f4d-ee55fc23c17d', tool_call_id='fc_68440688-509a-4a4d-ae5f-b46d16b4a8fc'),\n",
       " AIMessage(content='', additional_kwargs={'reasoning_content': 'We have identified gaps: FastAPI, PostgreSQL, Docker. Need to search for courses for each. Already have courses:\\n\\nFastAPI: CS-FAST-101 (prereq CS-PY-101). Also CS-FAST-201 (prereq CS-PY-101, CS-DB-101, CS-FAST-101). Likely choose CS-FAST-101 as foundation.\\n\\nPostgreSQL: CS-DB-101 covers SQLite and PostgreSQL fundamentals. No explicit prerequisite. Also CS-DB-201 advanced. Choose CS-DB-101.\\n\\nDocker: CS-DOCKER-101 fundamentals, no prereq.\\n\\nNow need to resolve prerequisites: For CS-FAST-101, prerequisite CS-PY-101 (Python Fundamentals). Candidate has solid Python, Django experience. Likely resume shows Python mastery, so we can consider that as known. The instruction: \"Skip courses the candidate already demonstrates via projects or experience.\" So we can treat CS-PY-101 as known, not needed to include.\\n\\nCheck other courses for prerequisites: none else.\\n\\nThus roadmap includes three courses: CS-FAST-101, CS-DB-101, CS-DOCKER-101. Sequence: prerequisites before target modules. Since no dependencies among these three (except maybe Docker before FastAPI? Not required). Could order logically: start with Docker fundamentals (foundation for containerizing FastAPI later), then PostgreSQL fundamentals, then FastAPI. Or any order. We\\'ll assign sequence_order 1,2,3.\\n\\nis_fresher_adaptation_needed false, so no professional fundamentals module.\\n\\nNow need to build roadmap array with fields: course_id, is_foundation (boolean). Probably true for foundation courses? Let\\'s set is_foundation true for all three as they are foundational.\\n\\nReasoning: brief.\\n\\nNow need to create mermaid visualization following rules: gap courses ::gap, known prerequisites ::known, start node ::start, end node ::done. Since we are not adding known courses (CS-PY-101) as nodes, but we could include as known? The rules: known prerequisites should be marked ::known. Since we are skipping CS-PY-101, maybe we don\\'t include it. But we could include it as known to show prerequisite satisfied. Let\\'s include a node for CS-PY-101 as known.\\n\\nAlso start node: candidate\\'s current skills.\\n\\nEnd node: Role-ready — Backend Developer.\\n\\nGroup by week using subgraph. Let\\'s assign weeks: Week 1 Docker, Week 2 PostgreSQL, Week 3 FastAPI.\\n\\nMermaid code accordingly.\\n\\nNow need to call submit_final_roadmap with candidate_name, onboarding_summary (maybe executive summary), roadmap array, target_role \"Backend Developer\".\\n\\nThen submit_mermaid_visualization with code.\\n\\nProceed.', 'tool_calls': [{'id': 'fc_e1fad88b-3a4b-4877-a3df-369362707126', 'function': {'arguments': '{\"candidate_name\":\"Chirayu Jain\",\"onboarding_summary\":\"Chirayu is a near-ready backend candidate with solid Python, Django and SQL experience, but must quickly add FastAPI, PostgreSQL and Docker to meet CodeForge’s stack requirements.\",\"roadmap\":[{\"course_id\":\"CS-DOCKER-101\",\"is_foundation\":true,\"reasoning\":\"Provides essential containerization skills required to package FastAPI services for deployment.\",\"sequence_order\":1,\"title\":\"Docker \\\\u0026 Containerization Fundamentals\"},{\"course_id\":\"CS-DB-101\",\"is_foundation\":true,\"reasoning\":\"Covers PostgreSQL fundamentals, enabling design of relational schemas and optimized queries for the target role.\",\"sequence_order\":2,\"title\":\"SQL Fundamentals for Backend Developers\"},{\"course_id\":\"CS-FAST-101\",\"is_foundation\":true,\"reasoning\":\"Introduces FastAPI, the primary framework listed in the JD, building async REST endpoints and Pydantic models.\",\"sequence_order\":3,\"title\":\"REST API Development with FastAPI\"}],\"target_role\":\"Backend Developer\"}', 'name': 'submit_final_roadmap'}, 'type': 'function'}]}, response_metadata={'token_usage': {'completion_tokens': 864, 'prompt_tokens': 2825, 'total_tokens': 3689, 'completion_time': 1.891397937, 'completion_tokens_details': {'reasoning_tokens': 564}, 'prompt_time': 0.145777084, 'prompt_tokens_details': {'cached_tokens': 1792}, 'queue_time': 0.045268224, 'total_time': 2.037175021}, 'model_name': 'openai/gpt-oss-120b', 'system_fingerprint': 'fp_626f3fc5e0', 'service_tier': 'on_demand', 'finish_reason': 'tool_calls', 'logprobs': None, 'model_provider': 'groq'}, id='lc_run--019d206b-ee19-7900-a734-70259374603f-0', tool_calls=[{'name': 'submit_final_roadmap', 'args': {'candidate_name': 'Chirayu Jain', 'onboarding_summary': 'Chirayu is a near-ready backend candidate with solid Python, Django and SQL experience, but must quickly add FastAPI, PostgreSQL and Docker to meet CodeForge’s stack requirements.', 'roadmap': [{'course_id': 'CS-DOCKER-101', 'is_foundation': True, 'reasoning': 'Provides essential containerization skills required to package FastAPI services for deployment.', 'sequence_order': 1, 'title': 'Docker & Containerization Fundamentals'}, {'course_id': 'CS-DB-101', 'is_foundation': True, 'reasoning': 'Covers PostgreSQL fundamentals, enabling design of relational schemas and optimized queries for the target role.', 'sequence_order': 2, 'title': 'SQL Fundamentals for Backend Developers'}, {'course_id': 'CS-FAST-101', 'is_foundation': True, 'reasoning': 'Introduces FastAPI, the primary framework listed in the JD, building async REST endpoints and Pydantic models.', 'sequence_order': 3, 'title': 'REST API Development with FastAPI'}], 'target_role': 'Backend Developer'}, 'id': 'fc_e1fad88b-3a4b-4877-a3df-369362707126', 'type': 'tool_call'}], invalid_tool_calls=[], usage_metadata={'input_tokens': 2825, 'output_tokens': 864, 'total_tokens': 3689, 'input_token_details': {'cache_read': 1792}, 'output_token_details': {'reasoning': 564}}),\n",
       " ToolMessage(content='{\"candidate_name\": \"Chirayu Jain\", \"target_role\": \"Backend Developer\", \"onboarding_summary\": \"Chirayu is a near-ready backend candidate with solid Python, Django and SQL experience, but must quickly add FastAPI, PostgreSQL and Docker to meet CodeForge’s stack requirements.\", \"roadmap\": [{\"course_id\": \"CS-DOCKER-101\", \"title\": \"Docker & Containerization Fundamentals\", \"reasoning\": \"Provides essential containerization skills required to package FastAPI services for deployment.\", \"is_foundation\": true, \"sequence_order\": 1}, {\"course_id\": \"CS-DB-101\", \"title\": \"SQL Fundamentals for Backend Developers\", \"reasoning\": \"Covers PostgreSQL fundamentals, enabling design of relational schemas and optimized queries for the target role.\", \"is_foundation\": true, \"sequence_order\": 2}, {\"course_id\": \"CS-FAST-101\", \"title\": \"REST API Development with FastAPI\", \"reasoning\": \"Introduces FastAPI, the primary framework listed in the JD, building async REST endpoints and Pydantic models.\", \"is_foundation\": true, \"sequence_order\": 3}]}', name='submit_final_roadmap', id='5fb8c861-d353-4034-a0c8-d1c17aeabcd6', tool_call_id='fc_e1fad88b-3a4b-4877-a3df-369362707126'),\n",
       " AIMessage(content='', additional_kwargs={'reasoning_content': \"We have submitted final roadmap. Need to also submit mermaid visualization. Must follow rules: gap courses ::gap, known prerequisites ::known, start ::start, end ::done. In this case all three are gaps (they are missing foundations). However they have prerequisites: CS-FAST-101 prerequisite CS-PY-101, CS-DB-101 has none, CS-DOCKER-101 none. Candidate already has Python foundation, so we can treat CS-PY-101 as known prerequisite. Need to include it as known node. Sequence: start -> CS-DOCKER-101 (gap) -> CS-DB-101 (gap) -> CS-FAST-101 (gap) -> end. Also include CS-PY-101 as known prerequisite for FastAPI, placed before FastAPI maybe in same week or earlier. Since FastAPI depends on Python fundamentals, we should include known node before FastAPI. Could be in same week as FastAPI but as known. We'll create weeks: Week1 Docker, Week2 PostgreSQL, Week3 Python fundamentals (known) and FastAPI (gap). Or maybe include known before gap in same week.\\n\\nMermaid format: flowchart TD. Use subgraph W1, W2, W3.\\n\\nAdd class definitions.\\n\\nNow call submit_mermaid_visualization.\", 'tool_calls': [{'id': 'fc_ea8b8113-e478-45dd-a8b4-bf2eae927d9a', 'function': {'arguments': '{\"mermaid_code\":\"flowchart TD\\\\n    A([Start — Current Skills]):::start\\\\n    subgraph W1[\\\\\"Week 1 — Containerization\\\\\"]\\\\n        B[CS-DOCKER-101\\\\\\\\nDocker \\\\u0026 Containerization Fundamentals]:::gap\\\\n    end\\\\n    subgraph W2[\\\\\"Week 2 — Relational DB\\\\\"]\\\\n        C[CS-DB-101\\\\\\\\nSQL Fundamentals for Backend Developers]:::gap\\\\n    end\\\\n    subgraph W3[\\\\\"Week 3 — API Development\\\\\"]\\\\n        D[CS-PY-101\\\\\\\\nPython Fundamentals]:::known\\\\n        E[CS-FAST-101\\\\\\\\nREST API Development with FastAPI]:::gap\\\\n    end\\\\n    Z([Backend Developer — Role Ready]):::done\\\\n    A --\\\\u003e B --\\\\u003e C --\\\\u003e D --\\\\u003e E --\\\\u003e Z\\\\n    classDef gap   fill:#EEEDFE,stroke:#534AB7,color:#26215C\\\\n    classDef known fill:#E1F5EE,stroke:#0F6E56,color:#085041\\\\n    classDef start fill:#1D9E75,stroke:#0F6E56,color:#E1F5EE\\\\n    classDef done  fill:#534AB7,stroke:#3C3489,color:#EEEDFE\"}', 'name': 'submit_mermaid_visualization'}, 'type': 'function'}]}, response_metadata={'token_usage': {'completion_tokens': 557, 'prompt_tokens': 3339, 'total_tokens': 3896, 'completion_time': 1.196030062, 'completion_tokens_details': {'reasoning_tokens': 266}, 'prompt_time': 0.160108793, 'prompt_tokens_details': None, 'queue_time': 0.046081046, 'total_time': 1.356138855}, 'model_name': 'openai/gpt-oss-120b', 'system_fingerprint': 'fp_8a618bed98', 'service_tier': 'on_demand', 'finish_reason': 'tool_calls', 'logprobs': None, 'model_provider': 'groq'}, id='lc_run--019d206b-f96f-7ad0-9a9e-fc4e668a8516-0', tool_calls=[{'name': 'submit_mermaid_visualization', 'args': {'mermaid_code': 'flowchart TD\\n    A([Start — Current Skills]):::start\\n    subgraph W1[\"Week 1 — Containerization\"]\\n        B[CS-DOCKER-101\\\\nDocker & Containerization Fundamentals]:::gap\\n    end\\n    subgraph W2[\"Week 2 — Relational DB\"]\\n        C[CS-DB-101\\\\nSQL Fundamentals for Backend Developers]:::gap\\n    end\\n    subgraph W3[\"Week 3 — API Development\"]\\n        D[CS-PY-101\\\\nPython Fundamentals]:::known\\n        E[CS-FAST-101\\\\nREST API Development with FastAPI]:::gap\\n    end\\n    Z([Backend Developer — Role Ready]):::done\\n    A --> B --> C --> D --> E --> Z\\n    classDef gap   fill:#EEEDFE,stroke:#534AB7,color:#26215C\\n    classDef known fill:#E1F5EE,stroke:#0F6E56,color:#085041\\n    classDef start fill:#1D9E75,stroke:#0F6E56,color:#E1F5EE\\n    classDef done  fill:#534AB7,stroke:#3C3489,color:#EEEDFE'}, 'id': 'fc_ea8b8113-e478-45dd-a8b4-bf2eae927d9a', 'type': 'tool_call'}], invalid_tool_calls=[], usage_metadata={'input_tokens': 3339, 'output_tokens': 557, 'total_tokens': 3896, 'output_token_details': {'reasoning': 266}}),\n",
       " ToolMessage(content='Mermaid visualization saved successfully.', name='submit_mermaid_visualization', id='e07fe033-a45e-41ee-b421-caa15afa997d', tool_call_id='fc_ea8b8113-e478-45dd-a8b4-bf2eae927d9a'),\n",
       " AIMessage(content='The learning roadmap for **Chirayu Jain** has been finalized and visualized.\\n\\n**Roadmap Summary**\\n- **Target Role:** Backend Developer  \\n- **Onboarding Summary:** Near‑ready backend candidate with solid Python, Django and SQL experience; needs FastAPI, PostgreSQL, and Docker to meet CodeForge’s stack.  \\n\\n**Course Sequence**\\n1. **CS-DOCKER-101 – Docker & Containerization Fundamentals** (Foundation)  \\n2. **CS-DB-101 – SQL Fundamentals for Backend Developers** (Foundation)  \\n3. **CS-FAST-101 – REST API Development with FastAPI** (Foundation)  \\n\\n**Mermaid Visualization**\\n```mermaid\\nflowchart TD\\n    A([Start — Current Skills]):::start\\n    subgraph W1[\"Week 1 — Containerization\"]\\n        B[CS-DOCKER-101\\\\nDocker & Containerization Fundamentals]:::gap\\n    end\\n    subgraph W2[\"Week 2 — Relational DB\"]\\n        C[CS-DB-101\\\\nSQL Fundamentals for Backend Developers]:::gap\\n    end\\n    subgraph W3[\"Week 3 — API Development\"]\\n        D[CS-PY-101\\\\nPython Fundamentals]:::known\\n        E[CS-FAST-101\\\\nREST API Development with FastAPI]:::gap\\n    end\\n    Z([Backend Developer — Role Ready]):::done\\n    A --> B --> C --> D --> E --> Z\\n    classDef gap   fill:#EEEDFE,stroke:#534AB7,color:#26215C\\n    classDef known fill:#E1F5EE,stroke:#0F6E56,color:#085041\\n    classDef start fill:#1D9E75,stroke:#0F6E56,color:#E1F5EE\\n    classDef done  fill:#534AB7,stroke:#3C3489,color:#EEEDFE\\n```\\n\\nAll steps are complete.', additional_kwargs={}, response_metadata={'token_usage': {'completion_tokens': 406, 'prompt_tokens': 3646, 'total_tokens': 4052, 'completion_time': 1.438615073, 'completion_tokens_details': None, 'prompt_time': 0.141632128, 'prompt_tokens_details': {'cached_tokens': 2816}, 'queue_time': 0.04638064, 'total_time': 1.5802472010000002}, 'model_name': 'openai/gpt-oss-120b', 'system_fingerprint': 'fp_626f3fc5e0', 'service_tier': 'on_demand', 'finish_reason': 'stop', 'logprobs': None, 'model_provider': 'groq'}, id='lc_run--019d206c-010d-7133-92a9-18ed936df441-0', tool_calls=[], invalid_tool_calls=[], usage_metadata={'input_tokens': 3646, 'output_tokens': 406, 'total_tokens': 4052, 'input_token_details': {'cache_read': 2816}})]"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "final_result['messages']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "25a6b5b4",
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "\n",
    "# Define the keys your React frontend actually needs\n",
    "REQUIRED_KEYS = [\"candidate_name\", \"skill_gap_analysis_data\", \"mermaid_code\", \"final_roadmap\"]\n",
    "\n",
    "def export_ui_payload(state, filename=\"ai_output.json\"):\n",
    "    \"\"\"\n",
    "    Extracts specific keys from the graph state and ensures \n",
    "    Pydantic objects are dumped to dicts for JSON compatibility.\n",
    "    \"\"\"\n",
    "    ui_data = {}\n",
    "\n",
    "    for key in REQUIRED_KEYS:\n",
    "        # Get the value from the state\n",
    "        val = state.get(key)\n",
    "        \n",
    "        if val is None:\n",
    "            continue\n",
    "\n",
    "        # Check if the value is a Pydantic object (has .model_dump())\n",
    "        # This fixes the \"skill_gap_analysis_data as a string\" issue\n",
    "        if hasattr(val, \"model_dump\"):\n",
    "            ui_data[key] = val.model_dump()\n",
    "        else:\n",
    "            # If it's already a dict (final_roadmap) or string (mermaid_code)\n",
    "            ui_data[key] = val\n",
    "\n",
    "    # Save to the local file\n",
    "    with open(filename, \"w\", encoding=\"utf-8\") as f:\n",
    "        json.dump(ui_data, f, indent=2)\n",
    "    \n",
    "    print(f\"✅ UI Payload successfully exported to {filename}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "478f19dd",
   "metadata": {},
   "outputs": [],
   "source": [
    "test_data=['atgdata.json','buisnessdata.json','chefdata.json','casemanager.json']\n",
    "test_resumes=['ATGPDF.pdf','Business.pdf','CHEF.pdf','casemanager.pdf']\n",
    "\n",
    "\n",
    "test_resume_path=r\"C:\\Users\\ATHARVA\\Downloads\\my codes\\web\\AdaptiveEngineService\\AI_Engine_Evaluation\\Testcases\\Testresume\\{test_resumes}\"\n",
    "test_data_path=r\"C:\\Users\\ATHARVA\\Downloads\\my codes\\web\\AdaptiveEngineService\\AI_Engine_Evaluation\\Testcases\\data\\{test_data}\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "83f3bd72",
   "metadata": {},
   "outputs": [],
   "source": [
    "store_state=[]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "id": "5b29b7ea",
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "import uuid\n",
    "import os\n",
    "from langgraph.checkpoint.memory import MemorySaver\n",
    "\n",
    "# --- Configuration & Paths ---\n",
    "\n",
    "test_map = [\n",
    "    {\"resume\": \"ATGPDF.pdf\", \"data\": \"atgdata.json\", \"name\": \"Atharva_Gaykar\"},\n",
    "]\n",
    "\n",
    "RESUME_DIR = r\"C:\\Users\\ATHARVA\\Downloads\\my codes\\web\\AdaptiveEngineService\\AI_Engine_Evaluation\\Testcases\\Testresume\"\n",
    "DATA_DIR = r\"C:\\Users\\ATHARVA\\Downloads\\my codes\\web\\AdaptiveEngineService\\AI_Engine_Evaluation\\Testcases\\data\"\n",
    "\n",
    "# Windows-safe absolute output path\n",
    "OUTPUT_DIR = os.path.join(os.getcwd(), \"predictions\")\n",
    "if not os.path.exists(OUTPUT_DIR):\n",
    "    os.makedirs(OUTPUT_DIR)\n",
    "\n",
    "# Global list to store final states if needed for debugging\n",
    "store_state = []\n",
    "\n",
    "# --- Helper Functions ---\n",
    "\n",
    "def get_job_description_string(data_filename: str) -> str | None:\n",
    "    path = os.path.join(DATA_DIR, data_filename)\n",
    "    if not os.path.exists(path):\n",
    "        print(f\"⚠️  Data file not found: {path}\")\n",
    "        return None\n",
    "    try:\n",
    "        with open(path, \"r\", encoding=\"utf-8\") as f:\n",
    "            suite = json.load(f)\n",
    "        jd_obj = suite.get(\"job_description\") or suite.get(\"job_description_requirements\")\n",
    "        if not jd_obj:\n",
    "            return None\n",
    "        title = jd_obj.get(\"title\") or jd_obj.get(\"job_title\", \"N/A\")\n",
    "        desc = jd_obj.get(\"description\", \"\")\n",
    "        reqs = jd_obj.get(\"requirements\", [])\n",
    "        jd_string = f\"JOB TITLE: {title}\\n\\n\"\n",
    "        if desc: jd_string += f\"OVERVIEW: {desc}\\n\\n\"\n",
    "        jd_string += \"REQUIREMENTS:\\n\" + \"\\n\".join([f\"- {r}\" for r in reqs])\n",
    "        return jd_string\n",
    "    except Exception as e:\n",
    "        print(f\"❌ Error loading JD: {e}\")\n",
    "        return None\n",
    "\n",
    "def export_ui_payload(state: dict) -> dict:\n",
    "    REQUIRED_KEYS = [\"candidate_name\", \"skill_gap_analysis_data\", \"mermaid_code\", \"final_roadmap\"]\n",
    "    ui_data = {}\n",
    "    for key in REQUIRED_KEYS:\n",
    "        val = state.get(key)\n",
    "        if val is None: continue\n",
    "        ui_data[key] = val.model_dump() if hasattr(val, \"model_dump\") else val\n",
    "    return ui_data\n",
    "\n",
    "# --- Execution Loop ---\n",
    "\n",
    "def run_evaluation_suite(graph_instance):\n",
    "    print(f\"\\n📁 Output directory: {OUTPUT_DIR}\\n\")\n",
    "\n",
    "    for case in test_map:\n",
    "        print(f\"🚀 Processing: {case['resume']}...\")\n",
    "        resume_path = os.path.join(RESUME_DIR, case[\"resume\"])\n",
    "        if not os.path.exists(resume_path):\n",
    "            print(f\"⚠️  Resume not found: {resume_path}\")\n",
    "            continue\n",
    "\n",
    "        jd_content = get_job_description_string(case[\"data\"])\n",
    "        if not jd_content:\n",
    "            print(f\"⚠️  JD not found in {case['data']}\")\n",
    "            continue\n",
    "\n",
    "        initial_input = {\n",
    "            \"candidate_name\": case[\"name\"].replace(\"_\", \" \"),\n",
    "            \"file_path\": resume_path,\n",
    "            \"job_description\": jd_content,\n",
    "            \"resume_text\": None,\n",
    "            \"resume_data\": None,\n",
    "            \"extraction_error\": None,\n",
    "            \"JobDescriptionExtract_data\": None,\n",
    "            \"skill_gap_analysis_data\": None,\n",
    "            \"messages\": [],\n",
    "            \"mermaid_code\": None,\n",
    "            \"final_roadmap\": None,\n",
    "        }\n",
    "\n",
    "        config = {\"configurable\": {\"thread_id\": str(uuid.uuid4())}}\n",
    "\n",
    "        try:\n",
    "            print(f\"--- 🛰️  Starting Stream for {case['name']} ---\")\n",
    "            final_state = initial_input.copy()\n",
    "\n",
    "            # The stream loop MUST be indented inside the try block\n",
    "            for chunk in graph_instance.stream(initial_input, config=config, stream_mode=\"updates\"):\n",
    "                for node_name, node_update in chunk.items():\n",
    "                    print(f\"\\n📍 [NODE]: {node_name}\")\n",
    "                    \n",
    "                    # Update local final_state with changes from the node\n",
    "                    final_state.update(node_update)\n",
    "\n",
    "                    # Monitor agent messages for tool calls\n",
    "                    if \"messages\" in node_update and node_update[\"messages\"]:\n",
    "                        last_msg = node_update[\"messages\"][-1]\n",
    "                        if hasattr(last_msg, \"content\") and last_msg.content:\n",
    "                            print(f\"💬 Thought: {last_msg.content[:100]}...\")\n",
    "                        if hasattr(last_msg, \"tool_calls\") and last_msg.tool_calls:\n",
    "                            print(f\"🛠️  TOOL CALL DETECTED: {last_msg.tool_calls}\")\n",
    "\n",
    "            store_state.append(final_state)\n",
    "            print(f\"✅ Graph finished for {case['name']}\\n\")\n",
    "\n",
    "            # Save the result\n",
    "            prediction = export_ui_payload(final_state)\n",
    "            output_file = f\"predicted_{case['name'].lower()}.json\"\n",
    "            output_path = os.path.join(OUTPUT_DIR, output_file)\n",
    "            with open(output_path, \"w\", encoding=\"utf-8\") as f:\n",
    "                json.dump(prediction, f, indent=2, ensure_ascii=False)\n",
    "            print(f\"💾 Saved: {output_path}\\n\")\n",
    "\n",
    "        except Exception as e:\n",
    "            print(f\"❌ Error during graph execution for {case['resume']}: {e}\")\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "c1638a3f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "📁 Output directory: c:\\Users\\ATHARVA\\Downloads\\my codes\\web\\AdaptiveEngineService\\Notebooks\\predictions\n",
      "\n",
      "🚀 Processing: ATGPDF.pdf...\n",
      "--- 🛰️  Starting Stream for Atharva_Gaykar ---\n",
      "📂 File path received: C:\\Users\\ATHARVA\\Downloads\\my codes\\web\\AdaptiveEngineService\\AI_Engine_Evaluation\\Testcases\\Testresume\\ATGPDF.pdf\n",
      "📂 File exists: True\n",
      "📄 Pages loaded: 1\n",
      "📄 Text length: 2671\n",
      "\n",
      "📍 [NODE]: input_node\n",
      "DEBUGGER: Sending 995 characters to JD Agent...\n",
      "📄 Resume text length: 2671 chars\n",
      "DEBUGGER SUCCESS: Extracted Senior ML & MLOps Architect\n",
      "\n",
      "📍 [NODE]: jd_data_extraction\n",
      "✅ Resume extracted: AI Engineer\n",
      "\n",
      "📍 [NODE]: resume_data_extraction\n",
      "\n",
      "📍 [NODE]: skill_gap_analysis\n",
      "💬 Thought: \n",
      "        Skill Gap Analysis Completed for Atharva Gaykar.\n",
      "\n",
      "        Gaps Identified:\n",
      "        {\n",
      "  \"job...\n",
      "\n",
      "📍 [NODE]: roadmap_planning_agent\n",
      "💬 Thought: The learning roadmap for **Atharva Gaykar** has been finalized and saved, along with its Mermaid vis...\n",
      "\n",
      "📍 [NODE]: finalize_state\n",
      "✅ Graph finished for Atharva_Gaykar\n",
      "\n",
      "💾 Saved: c:\\Users\\ATHARVA\\Downloads\\my codes\\web\\AdaptiveEngineService\\Notebooks\\predictions\\predicted_atharva_gaykar.json\n",
      "\n"
     ]
    }
   ],
   "source": [
    "if __name__ == \"__main__\":\n",
    "    # Assuming your graph is already compiled and named 'graph'\n",
    "    run_evaluation_suite(graph)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "id": "d6b44b85",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "flowchart TD\n",
      "    A([Start — Current Skills]):::start\n",
      "    subgraph W1[\"Week 1 — Kubernetes Foundations\"]\n",
      "        B[OPS-K8S-101\\nKubernetes for AI Workloads]:::gap\n",
      "    end\n",
      "    subgraph W2[\"Week 2 — GPU Inference Serving\"]\n",
      "        C[OPS-TRITON-201\\nHigh-Performance Serving with Triton]:::gap\n",
      "    end\n",
      "    subgraph W3[\"Week 3 — Self‑Hosted Vector DB (Milvus)\"]\n",
      "        D[DTA-MIL-401\\nBillion-Scale Vector Ops]:::gap\n",
      "    end\n",
      "    subgraph W4[\"Week 4 — Open‑Source Vector DB (Weaviate)\"]\n",
      "        E[CS-VEC-101\\nVector Databases & Semantic Search]:::gap\n",
      "    end\n",
      "    subgraph W5[\"Week 5 — LLM Security & Red‑Teaming\"]\n",
      "        F[SEC-LLM-301\\nLLM Red Teaming & Guardrails]:::gap\n",
      "    end\n",
      "    subgraph W6[\"Week 6 — End‑to‑End MLOps & Observability\"]\n",
      "        G[CS-MLOPS-301\\nMLOps — Model Deployment & Monitoring]:::gap\n",
      "    end\n",
      "    Z([Role‑Ready — Senior ML & MLOps Architect]):::done\n",
      "    A --> B --> C --> D --> E --> F --> G --> Z\n",
      "    classDef gap fill:#EEEDFE,stroke:#534AB7,color:#26215C\n",
      "    classDef known fill:#E1F5EE,stroke:#0F6E56,color:#085041\n",
      "    classDef start fill:#1D9E75,stroke:#0F6E56,color:#E1F5EE\n",
      "    classDef done fill:#534AB7,stroke:#3C3489,color:#EEEDFE\n"
     ]
    }
   ],
   "source": [
    "print(store_state[0]['mermaid_code'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0910b325",
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "import uuid\n",
    "import os\n",
    "from langgraph.checkpoint.memory import MemorySaver\n",
    "\n",
    "# --- Configuration & Paths ---\n",
    "# Mapping resumes to the JSON files containing the Ground Truth data we created\n",
    "test_map = [\n",
    "   \n",
    "    {\"resume\": \"casemanager.pdf\", \"data\": \"casemanagerdata.json\", \"name\": \"Case_Manager\"}\n",
    "]\n",
    "\n",
    "# Update these to your actual local paths where the files are stored\n",
    "RESUME_DIR = r\"C:\\Users\\ATHARVA\\Downloads\\my codes\\web\\AdaptiveEngineService\\AI_Engine_Evaluation\\Testcases\\Testresume\"\n",
    "DATA_DIR = r\"C:\\Users\\ATHARVA\\Downloads\\my codes\\web\\AdaptiveEngineService\\AI_Engine_Evaluation\\Testcases\\data\"\n",
    "OUTPUT_DIR = \"./predictions\" \n",
    "\n",
    "if not os.path.exists(OUTPUT_DIR):\n",
    "    os.makedirs(OUTPUT_DIR)\n",
    "\n",
    "# --- Helper Functions ---\n",
    "\n",
    "def get_job_description_string(data_filename):\n",
    "    \"\"\"\n",
    "    Extracts the Job Description from the test data and formats it as a clean \n",
    "    string for the Extraction Node. Handles both 'job_description' and \n",
    "    'job_description_requirements' keys.\n",
    "    \"\"\"\n",
    "    path = os.path.join(DATA_DIR, data_filename)\n",
    "    try:\n",
    "        with open(path, 'r', encoding='utf-8') as f:\n",
    "            suite = json.load(f)\n",
    "            \n",
    "            # Extract from 'job_description' or 'job_description_requirements'\n",
    "            jd_obj = suite.get(\"job_description\") or suite.get(\"job_description_requirements\")\n",
    "            \n",
    "            if not jd_obj:\n",
    "                return None\n",
    "                \n",
    "            title = jd_obj.get(\"title\") or jd_obj.get(\"job_title\", \"N/A\")\n",
    "            desc = jd_obj.get(\"description\", \"\")\n",
    "            reqs = jd_obj.get(\"requirements\", [])\n",
    "            \n",
    "            # Format as a clean string for the LLM to analyze\n",
    "            jd_string = f\"JOB TITLE: {title}\\n\\n\"\n",
    "            if desc:\n",
    "                jd_string += f\"OVERVIEW: {desc}\\n\\n\"\n",
    "            jd_string += \"REQUIREMENTS:\\n\" + \"\\n\".join([f\"- {r}\" for r in reqs])\n",
    "            \n",
    "            return jd_string\n",
    "    except Exception as e:\n",
    "        print(f\"Error loading JD from {data_filename}: {e}\")\n",
    "        return None\n",
    "\n",
    "def export_ui_payload(state):\n",
    "    \"\"\"\n",
    "    Extracts and formats state data for the UI payload.\n",
    "    Ensures Pydantic objects are converted to dicts using .model_dump().\n",
    "    \"\"\"\n",
    "    REQUIRED_KEYS = [\"candidate_name\", \"skill_gap_analysis_data\", \"mermaid_code\", \"final_roadmap\"]\n",
    "    ui_data = {}\n",
    "\n",
    "    for key in REQUIRED_KEYS:\n",
    "        val = state.get(key)\n",
    "        if val is None:\n",
    "            continue\n",
    "            \n",
    "        # If it's a Pydantic object, dump it to a dict\n",
    "        if hasattr(val, \"model_dump\"):\n",
    "            ui_data[key] = val.model_dump()\n",
    "        else:\n",
    "            # If it's already a dict, list, or string (like mermaid_code)\n",
    "            ui_data[key] = val\n",
    "    return ui_data\n",
    "\n",
    "# --- Execution Loop ---\n",
    "\n",
    "def run_evaluation_suite_re(graph_instance):\n",
    "    \"\"\"\n",
    "    Automates the graph execution for every resume in the test suite.\n",
    "    Saves the final UI-ready payloads as 'predicted_{name}.json'.\n",
    "    \"\"\"\n",
    "    for case in test_map:\n",
    "        print(f\"🚀 Processing: {case['resume']}...\")\n",
    "        \n",
    "        # 1. Prepare Inputs\n",
    "        jd_content = get_job_description_string(case['data'])\n",
    "        \n",
    "        if not jd_content:\n",
    "            print(f\"⚠️ Skipping {case['resume']}: JD not found in {case['data']}\")\n",
    "            continue\n",
    "\n",
    "        # The 'job_description' key must match your extraction node's expectation\n",
    "        initial_input = {\n",
    "            \"candidate_name\": case['name'].replace(\"_\", \" \"),\n",
    "            \"resume_path\": os.path.join(RESUME_DIR, case['resume']),\n",
    "            \"job_description\": jd_content, \n",
    "            \"resume_text\": None # Assuming input_node or extraction node loads the PDF\n",
    "        }\n",
    "\n",
    "        # 2. Invoke Graph with a unique thread\n",
    "        thread_id = str(uuid.uuid4())\n",
    "        config = {\"configurable\": {\"thread_id\": thread_id}}\n",
    "        \n",
    "        try:\n",
    "            # Execution\n",
    "            final_state = graph_instance.invoke(initial_input, config=config)\n",
    "            \n",
    "            # 3. Process and Save UI Payload\n",
    "            prediction = export_ui_payload(final_state)\n",
    "            output_file = f\"predicted_{case['name'].lower()}.json\"\n",
    "            output_path = os.path.join(OUTPUT_DIR, output_file)\n",
    "            \n",
    "            with open(output_path, \"w\", encoding=\"utf-8\") as f:\n",
    "                json.dump(prediction, f, indent=2)\n",
    "                \n",
    "            print(f\"✅ Success! Prediction saved to: {output_path}\")\n",
    "            \n",
    "        except Exception as e:\n",
    "            print(f\"❌ Error during graph execution for {case['resume']}: {e}\")\n",
    "\n",
    "# --- Example of Triggering ---\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a8ef7f0b",
   "metadata": {},
   "outputs": [],
   "source": [
    "if __name__ == \"__main__\":\n",
    "    # Assuming your graph is already compiled and named 'graph'\n",
    "    run_evaluation_suite_re(graph)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e37e4370",
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "import os\n",
    "import re\n",
    "from rouge_score import rouge_scorer\n",
    "\n",
    "def normalize(text):\n",
    "    if not text: return \"\"\n",
    "    return re.sub(r'\\W+', ' ', str(text).lower()).strip()\n",
    "\n",
    "def calculate_f1(target_set, predicted_set):\n",
    "    if not target_set and not predicted_set: return 1.0\n",
    "    if not target_set or not predicted_set: return 0.0\n",
    "    intersection = target_set.intersection(predicted_set)\n",
    "    precision = len(intersection) / len(predicted_set)\n",
    "    recall = len(intersection) / len(target_set)\n",
    "    if (precision + recall) == 0:\n",
    "        return 0.0\n",
    "    return 2 * (precision * recall) / (precision + recall)\n",
    "\n",
    "# ← replaces your manual calculate_lcs + get_rouge_l\n",
    "scorer = rouge_scorer.RougeScorer(['rougeL'], use_stemmer=True)\n",
    "\n",
    "def get_rouge_l(reference, candidate):\n",
    "    if not reference or not candidate:\n",
    "        return 0.0\n",
    "    scores = scorer.score(reference, candidate)\n",
    "    return scores['rougeL'].fmeasure     # F1 score directly\n",
    "\n",
    "\n",
    "def run_benchmarking_report(target_data_dir, predicted_data_dir, mapping):\n",
    "    print(\"\\n📊 --- AI ENGINE PERFORMANCE REPORT ---\")\n",
    "    print(f\"{'Test Case':<20} | {'Skill F1':<10} | {'Reasoning (RG-L)':<15} | {'Retrieval (Hit)':<15}\")\n",
    "    print(\"-\" * 75)\n",
    "\n",
    "    final_report = {}\n",
    "\n",
    "    for case in mapping:\n",
    "        name = case['name']\n",
    "        target_path = os.path.join(target_data_dir, case['data'])\n",
    "        pred_path = os.path.join(predicted_data_dir, f\"predicted_{name.lower()}.json\")\n",
    "\n",
    "        if not os.path.exists(target_path) or not os.path.exists(pred_path):\n",
    "            print(f\"⚠️  Skipping {name} — file not found\")\n",
    "            continue\n",
    "\n",
    "        try:\n",
    "            with open(target_path, 'r', encoding='utf-8') as f:\n",
    "                target_json = json.load(f)[\"ai_target\"]\n",
    "            with open(pred_path, 'r', encoding='utf-8') as f:\n",
    "                pred_json = json.load(f)\n",
    "\n",
    "            # 1. Skill Extraction F1\n",
    "            target_skills = {normalize(g['skill_name']) for g in target_json['skill_gap_analysis_data']['analyzed_gaps']}\n",
    "            pred_skills   = {normalize(g['skill_name']) for g in pred_json['skill_gap_analysis_data']['analyzed_gaps']}\n",
    "            skill_f1 = calculate_f1(target_skills, pred_skills)\n",
    "\n",
    "            # 2. Reasoning Quality — ROUGE-L via library\n",
    "            reasoning_rouge = get_rouge_l(\n",
    "                target_json['skill_gap_analysis_data']['executive_summary'],\n",
    "                pred_json['skill_gap_analysis_data']['executive_summary']\n",
    "            )\n",
    "\n",
    "            # 3. Retrieval Hit Rate\n",
    "            target_ids = {normalize(c['course_id']) for c in target_json['final_roadmap']['roadmap']}\n",
    "            pred_ids   = {normalize(c['course_id']) for c in pred_json['final_roadmap']['roadmap']}\n",
    "            hit_count  = len(target_ids.intersection(pred_ids))\n",
    "            hit_rate   = hit_count / len(target_ids) if target_ids else 0.0\n",
    "\n",
    "            print(f\"{name:<20} | {skill_f1:>8.2%} | {reasoning_rouge:>15.2%} | {hit_rate:>15.2%}\")\n",
    "\n",
    "            final_report[name] = {\n",
    "                \"skill_extraction_f1\": round(skill_f1, 4),\n",
    "                \"reasoning_rouge_l\":   round(reasoning_rouge, 4),\n",
    "                \"retrieval_hit_rate\":  round(hit_rate, 4),\n",
    "            }\n",
    "\n",
    "        except Exception as e:\n",
    "            print(f\"⚠️  Error processing {name}: {e}\")\n",
    "\n",
    "    # Average across all test cases\n",
    "    if final_report:\n",
    "        avg_f1     = sum(v[\"skill_extraction_f1\"] for v in final_report.values()) / len(final_report)\n",
    "        avg_rouge  = sum(v[\"reasoning_rouge_l\"]   for v in final_report.values()) / len(final_report)\n",
    "        avg_hit    = sum(v[\"retrieval_hit_rate\"]   for v in final_report.values()) / len(final_report)\n",
    "        print(\"-\" * 75)\n",
    "        print(f\"{'AVERAGE':<20} | {avg_f1:>8.2%} | {avg_rouge:>15.2%} | {avg_hit:>15.2%}\")\n",
    "\n",
    "    return final_report\n",
    "\n",
    "\n",
    "# --- Mapping & Paths ---\n",
    "mapping = [\n",
    "    {\"data\": \"atgdata.json\",      \"name\": \"Atharva_Gaykar\"},\n",
    "    \n",
    "]\n",
    "\n",
    "DATA_DIR = r\"C:\\Users\\ATHARVA\\Downloads\\my codes\\web\\AdaptiveEngineService\\AI_Engine_Evaluation\\Testcases\\data\"\n",
    "PRED_DIR = \"./predictions\"\n",
    "\n",
    "report = run_benchmarking_report(DATA_DIR, PRED_DIR, mapping)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "70ced174",
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "import os\n",
    "import re\n",
    "\n",
    "def normalize(text):\n",
    "    \"\"\"Clean and normalize text for comparison.\"\"\"\n",
    "    if not text: return \"\"\n",
    "    return re.sub(r'\\W+', ' ', str(text).lower()).strip()\n",
    "\n",
    "def calculate_lcs(X, Y):\n",
    "    \"\"\"Calculates the length of the Longest Common Subsequence.\"\"\"\n",
    "    m, n = len(X), len(Y)\n",
    "    L = [[0] * (n + 1) for _ in range(m + 1)]\n",
    "    for i in range(m + 1):\n",
    "        for j in range(n + 1):\n",
    "            if i == 0 or j == 0:\n",
    "                L[i][j] = 0\n",
    "            elif X[i-1] == Y[j-1]:\n",
    "                L[i][j] = L[i-1][j-1] + 1\n",
    "            else:\n",
    "                L[i][j] = max(L[i-1][j], L[i][j-1])\n",
    "    return L[m][n]\n",
    "\n",
    "def get_rouge_l(reference, candidate):\n",
    "    \"\"\"Calculates ROUGE-L F1 score using LCS.\"\"\"\n",
    "    if not reference or not candidate:\n",
    "        return 0.0\n",
    "    ref_tokens = normalize(reference).split()\n",
    "    cand_tokens = normalize(candidate).split()\n",
    "    if not ref_tokens or not cand_tokens:\n",
    "        return 0.0\n",
    "    lcs_count = calculate_lcs(ref_tokens, cand_tokens)\n",
    "    recall = lcs_count / len(ref_tokens)\n",
    "    precision = lcs_count / len(cand_tokens)\n",
    "    if (recall + precision) == 0:\n",
    "        return 0.0\n",
    "    f1 = (2 * recall * precision) / (recall + precision)\n",
    "    return f1\n",
    "\n",
    "def calculate_f1(target_set, predicted_set):\n",
    "    \"\"\"Calculates Precision, Recall, and F1 for sets of entities (Skills/IDs).\"\"\"\n",
    "    if not target_set and not predicted_set: return 1.0\n",
    "    if not target_set or not predicted_set: return 0.0\n",
    "    intersection = target_set.intersection(predicted_set)\n",
    "    precision = len(intersection) / len(predicted_set)\n",
    "    recall = len(intersection) / len(target_set)\n",
    "    if (precision + recall) == 0:\n",
    "        return 0.0\n",
    "    return 2 * (precision * recall) / (precision + recall)\n",
    "\n",
    "def run_benchmarking_report(target_data_dir, predicted_data_dir, mapping):\n",
    "    \"\"\"\n",
    "    Main evaluation loop benchmarking predictions against ground truth.\n",
    "    Handles missing keys and files gracefully.\n",
    "    \"\"\"\n",
    "    print(\"\\n📊 --- AI ENGINE PERFORMANCE REPORT ---\")\n",
    "    print(f\"{'Test Case':<20} | {'Skill F1':<10} | {'Reasoning (RG-L)':<15} | {'Retrieval (Hit)':<15}\")\n",
    "    print(\"-\" * 75)\n",
    "\n",
    "    final_report = {}\n",
    "\n",
    "    for case in mapping:\n",
    "        name = case['name']\n",
    "        target_path = os.path.join(target_data_dir, case['data'])\n",
    "        # Look for the predicted file (lowercase name mapper)\n",
    "        pred_filename = f\"predicted_{name.lower()}.json\"\n",
    "        pred_path = os.path.join(predicted_data_dir, pred_filename)\n",
    "        \n",
    "        # 1. Check for File Existence\n",
    "        if not os.path.exists(target_path):\n",
    "            print(f\"⚠️  Skipping {name} — Target file '{case['data']}' not found.\")\n",
    "            continue\n",
    "        if not os.path.exists(pred_path):\n",
    "            print(f\"⚠️  Skipping {name} — Prediction file '{pred_filename}' not found.\")\n",
    "            continue\n",
    "            \n",
    "        try:\n",
    "            with open(target_path, 'r', encoding='utf-8') as f:\n",
    "                target_json = json.load(f).get(\"ai_target\", {})\n",
    "            with open(pred_path, 'r', encoding='utf-8') as f:\n",
    "                pred_json = json.load(f)\n",
    "                \n",
    "            # --- Metric 1: Skill Extraction Accuracy (F1) ---\n",
    "            target_gap_data = target_json.get('skill_gap_analysis_data', {})\n",
    "            pred_gap_data = pred_json.get('skill_gap_analysis_data', {})\n",
    "            \n",
    "            target_skills = {normalize(g.get('skill_name')) for g in target_gap_data.get('analyzed_gaps', [])}\n",
    "            pred_skills = {normalize(g.get('skill_name')) for g in pred_gap_data.get('analyzed_gaps', [])}\n",
    "            skill_f1 = calculate_f1(target_skills, pred_skills)\n",
    "            \n",
    "            # --- Metric 2: Reasoning Quality (ROUGE-L) ---\n",
    "            target_summary = target_gap_data.get('executive_summary', \"\")\n",
    "            pred_summary = pred_gap_data.get('executive_summary', \"\")\n",
    "            reasoning_rouge = get_rouge_l(target_summary, pred_summary)\n",
    "            \n",
    "            # --- Metric 3: Retrieval Precision (Top-1 Hit Rate) ---\n",
    "            # Extract expected IDs from target\n",
    "            target_roadmap = target_json.get('final_roadmap', {}).get('roadmap', [])\n",
    "            target_ids = {normalize(c.get('course_id')) for c in target_roadmap}\n",
    "            \n",
    "            # Extract predicted IDs from prediction (Checking common possible keys)\n",
    "            pred_roadmap_obj = pred_json.get('final_roadmap', {})\n",
    "            # If final_roadmap is a list directly in some versions\n",
    "            if isinstance(pred_roadmap_obj, list):\n",
    "                pred_roadmap = pred_roadmap_obj\n",
    "            else:\n",
    "                pred_roadmap = pred_roadmap_obj.get('roadmap', [])\n",
    "            \n",
    "            pred_ids = {normalize(c.get('course_id')) for c in pred_roadmap}\n",
    "            \n",
    "            if target_ids:\n",
    "                hit_count = len(target_ids.intersection(pred_ids))\n",
    "                hit_rate = hit_count / len(target_ids)\n",
    "            else:\n",
    "                hit_rate = 0.0\n",
    "            \n",
    "            # Print status row\n",
    "            print(f\"{name:<20} | {skill_f1:>8.2%} | {reasoning_rouge:>15.2%} | {hit_rate:>15.2%}\")\n",
    "            \n",
    "            final_report[name] = {\n",
    "                \"skill_extraction_f1\": skill_f1,\n",
    "                \"reasoning_rouge_l\": reasoning_rouge,\n",
    "                \"retrieval_hit_rate\": hit_rate\n",
    "            }\n",
    "        except Exception as e:\n",
    "            print(f\"⚠️  Error processing {name}: {str(e)}\")\n",
    "\n",
    "    return final_report\n",
    "\n",
    "# --- Mapping & Paths ---\n",
    "mapping = [\n",
    "    {\"data\": \"atgdata.json\", \"name\": \"Atharva_Gaykar\"},\n",
    "    {\"data\": \"buisnessdata.json\", \"name\": \"Business_Manager\"},\n",
    "    {\"data\": \"chefdata.json\", \"name\": \"Executive_Chef\"},\n",
    "    {\"data\": \"casemanagerdata.json\", \"name\": \"Case_Manager\"}\n",
    "]\n",
    "\n",
    "# Note: Ensure these paths are correct for your local environment\n",
    "DATA_DIR = r\"C:\\Users\\ATHARVA\\Downloads\\my codes\\web\\AdaptiveEngineService\\AI_Engine_Evaluation\\Testcases\\data\"\n",
    "PRED_DIR = \"./predictions\"\n",
    "\n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "    report = run_benchmarking_report(DATA_DIR, PRED_DIR, mapping)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "73a45cfd",
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "import os\n",
    "import re\n",
    "from rouge_score import rouge_scorer\n",
    "\n",
    "# -----------------------------\n",
    "# Scorer instance (created once)\n",
    "# -----------------------------\n",
    "scorer = rouge_scorer.RougeScorer(['rougeL'], use_stemmer=True)\n",
    "\n",
    "\n",
    "def normalize(text):\n",
    "    if not text: return \"\"\n",
    "    return re.sub(r'\\W+', ' ', str(text).lower()).strip()\n",
    "\n",
    "\n",
    "def get_rouge_l(reference, candidate):\n",
    "    if not reference or not candidate:\n",
    "        return 0.0\n",
    "    return scorer.score(reference, candidate)['rougeL'].fmeasure\n",
    "\n",
    "\n",
    "def calculate_skill_f1(target_skills, pred_skills):\n",
    "    if not target_skills and not pred_skills: return 1.0\n",
    "    if not target_skills or not pred_skills: return 0.0\n",
    "\n",
    "    tp = 0\n",
    "    matched_targets = set()\n",
    "\n",
    "    for p in pred_skills:\n",
    "        for t in target_skills:\n",
    "            if t in matched_targets: continue\n",
    "            if p in t or t in p:\n",
    "                tp += 1\n",
    "                matched_targets.add(t)\n",
    "                break\n",
    "\n",
    "    precision = tp / len(pred_skills)\n",
    "    recall = tp / len(target_skills)\n",
    "\n",
    "    if (precision + recall) == 0:\n",
    "        return 0.0\n",
    "    return 2 * (precision * recall) / (precision + recall)\n",
    "\n",
    "\n",
    "def calculate_retrieval_hit(target_ids, pred_ids):\n",
    "    if not target_ids: return 0.0\n",
    "    if not pred_ids: return 0.0\n",
    "    return len(target_ids.intersection(pred_ids)) / len(target_ids)\n",
    "\n",
    "\n",
    "def run_benchmarking_report(target_data_dir, predicted_data_dir, mapping):\n",
    "    print(\"\\n📊 --- AI ENGINE PERFORMANCE REPORT ---\")\n",
    "    print(f\"{'Test Case':<20} | {'Skill F1':<10} | {'Reasoning (RG-L)':<15} | {'Retrieval (Hit)':<15}\")\n",
    "    print(\"-\" * 75)\n",
    "\n",
    "    final_report = {}\n",
    "\n",
    "    for case in mapping:\n",
    "        name = case['name']\n",
    "        target_path = os.path.join(target_data_dir, case['data'])\n",
    "        pred_path = os.path.join(predicted_data_dir, f\"predicted_{name.lower()}.json\")\n",
    "\n",
    "        if not os.path.exists(target_path) or not os.path.exists(pred_path):\n",
    "            if not os.path.exists(pred_path):\n",
    "                print(f\"{name:<20} | SKIPPED — prediction file not found\")\n",
    "            continue\n",
    "\n",
    "        try:\n",
    "            with open(target_path, 'r', encoding='utf-8') as f:\n",
    "                target_json = json.load(f).get(\"ai_target\", {})\n",
    "            with open(pred_path, 'r', encoding='utf-8') as f:\n",
    "                pred_json = json.load(f)\n",
    "\n",
    "            # --- Metric 1: Skill F1 ---\n",
    "            target_gap = target_json.get('skill_gap_analysis_data', {})\n",
    "            pred_gap   = pred_json.get('skill_gap_analysis_data', {})\n",
    "\n",
    "            target_skills = {normalize(g.get('skill_name')) for g in target_gap.get('analyzed_gaps', [])}\n",
    "            pred_skills   = {normalize(g.get('skill_name')) for g in pred_gap.get('analyzed_gaps', [])}\n",
    "            skill_f1      = calculate_skill_f1(target_skills, pred_skills)\n",
    "\n",
    "            # --- Metric 2: ROUGE-L ---\n",
    "            reasoning_rouge = get_rouge_l(\n",
    "                target_gap.get('executive_summary', \"\"),\n",
    "                pred_gap.get('executive_summary', \"\")\n",
    "            )\n",
    "\n",
    "            # --- Metric 3: Retrieval Hit Rate ---\n",
    "            target_ids = {normalize(c.get('course_id')) for c in target_json.get('final_roadmap', {}).get('roadmap', [])}\n",
    "\n",
    "            pred_roadmap_obj = pred_json.get('final_roadmap', {})\n",
    "            pred_roadmap     = pred_roadmap_obj if isinstance(pred_roadmap_obj, list) else pred_roadmap_obj.get('roadmap', [])\n",
    "            pred_ids         = {normalize(c.get('course_id')) for c in pred_roadmap}\n",
    "\n",
    "            hit_rate = calculate_retrieval_hit(target_ids, pred_ids)\n",
    "\n",
    "            print(f\"{name:<20} | {skill_f1:>8.2%} | {reasoning_rouge:>15.2%} | {hit_rate:>15.2%}\")\n",
    "\n",
    "            final_report[name] = {\n",
    "                \"skill_extraction_f1\": round(skill_f1, 4),\n",
    "                \"reasoning_rouge_l\":   round(reasoning_rouge, 4),\n",
    "                \"retrieval_hit_rate\":  round(hit_rate, 4),\n",
    "            }\n",
    "\n",
    "        except Exception as e:\n",
    "            print(f\"⚠️  Error processing {name}: {str(e)}\")\n",
    "\n",
    "    # --- Average Row ---\n",
    "    if final_report:\n",
    "        avg_f1    = sum(v[\"skill_extraction_f1\"] for v in final_report.values()) / len(final_report)\n",
    "        avg_rouge = sum(v[\"reasoning_rouge_l\"]   for v in final_report.values()) / len(final_report)\n",
    "        avg_hit   = sum(v[\"retrieval_hit_rate\"]   for v in final_report.values()) / len(final_report)\n",
    "        print(\"-\" * 75)\n",
    "        print(f\"{'AVERAGE':<20} | {avg_f1:>8.2%} | {avg_rouge:>15.2%} | {avg_hit:>15.2%}\")\n",
    "\n",
    "    return final_report\n",
    "\n",
    "\n",
    "# --- Mapping & Paths ---\n",
    "mapping = [\n",
    "    {\"data\": \"atgdata.json\",      \"name\": \"Atharva_Gaykar\"},\n",
    "    {\"data\": \"buisnessdata.json\", \"name\": \"Business_Manager\"},\n",
    "    {\"data\": \"chefdata.json\",     \"name\": \"Executive_Chef\"},\n",
    "    {\"data\": \"casemanager.json\",  \"name\": \"Case_Manager\"}\n",
    "]\n",
    "\n",
    "DATA_DIR = r\"C:\\Users\\ATHARVA\\Downloads\\my codes\\web\\AdaptiveEngineService\\AI_Engine_Evaluation\\Testcases\\data\"\n",
    "PRED_DIR = \"./predictions\"\n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "    run_benchmarking_report(DATA_DIR, PRED_DIR, mapping)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "pro_env",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}