File size: 95,185 Bytes
067f7d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CrewAI Learning Platform & Cheatsheet</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.0/css/all.min.css">
    <style>

        body {

            font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;

            line-height: 1.6;

            color: #333;

        }

        .section {

            padding: 2rem 0;

            margin-bottom: 1.5rem;

        }

        .code-block {

            font-family: monospace;

            font-size: 0.9rem;

            white-space: pre-wrap;

            padding: 1rem;

            margin: 1rem 0;

            background-color: black;

            border-radius: 0.5rem;

            overflow-x: auto;

        }

        .reference-table {

            width: 100%;

            border-collapse: collapse;

            margin: 1rem 0;

        }

        .reference-table th, .reference-table td {

            padding: 0.75rem;

            text-align: left;

            border: 1px solid #e5e7eb;

        }

        .reference-table th {

            background-color: #f9fafb;

            font-weight: 600;

        }

        .reference-table tr:nth-child(even) {

            background-color: #f9fafb;

        }

        .toc-link {

            display: block;

            padding: 0.5rem 0;

            text-decoration: none;

            color: #4b5563;

            border-left: 2px solid transparent;

            padding-left: 0.75rem;

            margin-bottom: 0.25rem;

            transition: all 0.2s;

        }

        .toc-link:hover {

            color: #3b82f6;

            border-left-color: #3b82f6;

            background-color: #f3f4f6;

        }

        .toc-active {

            color: #1e40af;

            border-left-color: #1e40af;

            font-weight: 600;

        }

        .card {

            border: 1px solid #e5e7eb;

            border-radius: 0.5rem;

            padding: 1rem;

            margin-bottom: 1rem;

            transition: transform 0.2s, box-shadow 0.2s;

        }

        .card:hover {

            transform: translateY(-2px);

            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

        }

        h1, h2, h3, h4 {

            font-weight: 700;

        }

        h1 {

            font-size: 2rem;

            margin-bottom: 1.5rem;

        }

        h2 {

            font-size: 1.5rem;

            margin: 2rem 0 1rem 0;

            padding-bottom: 0.5rem;

            border-bottom: 2px solid #e5e7eb;

        }

        h3 {

            font-size: 1.25rem;

            margin: 1.5rem 0 1rem 0;

        }

        h4 {

            font-size: 1.1rem;

            margin: 1.25rem 0 0.75rem 0;

        }

        .banner {

            background: linear-gradient(to right, #3b82f6, #2563eb);

            color: white;

            padding: 2rem;

            border-radius: 0.5rem;

            margin-bottom: 2rem;

        }

        .step {

            position: relative;

            padding-left: 2.5rem;

            margin-bottom: 1.5rem;

        }

        .step-number {

            position: absolute;

            left: 0;

            top: 0;

            width: 2rem;

            height: 2rem;

            background-color: #3b82f6;

            color: white;

            border-radius: 50%;

            display: flex;

            align-items: center;

            justify-content: center;

            font-weight: 700;

        }

        .tip {

            background-color: #dbeafe;

            border-left: 4px solid #3b82f6;

            padding: 1rem;

            margin: 1rem 0;

            border-radius: 0.25rem;

        }

        .warning {

            background-color: #fef3c7;

            border-left: 4px solid #d97706;

            padding: 1rem;

            margin: 1rem 0;

            border-radius: 0.25rem;

        }

        .success-box {

            background-color: #d1fae5;

            border-left: 4px solid #10b981;

            padding: 1rem;

            margin: 1rem 0;

            border-radius: 0.25rem;

        }

    </style>
</head>
<body class="bg-black-50">
    <header class="bg-white shadow-md">
        <div class="container mx-auto px-4 py-6">
            <h1 class="text-4xl font-bold text-center text-blue-800">CrewAI Learning Platform & Cheatsheet</h1>
            <p class="text-center text-gray-600 mt-2">A comprehensive guide to building multi-agent systems with CrewAI</p>
        </div>
    </header>

    <div class="container mx-auto px-4 py-8">
        <div class="flex flex-col md:flex-row">
            <!-- Table of Contents - Fixed on larger screens -->
            <div class="md:w-1/4 md:sticky md:top-0 md:h-screen md:pt-8 md:overflow-y-auto pr-4">
                <div class="bg-white p-4 rounded-lg shadow mb-6">
                    <h3 class="text-lg font-semibold mb-4 text-blue-800">Table of Contents</h3>
                    <nav class="toc">
                        <a href="#introduction" class="toc-link">1. Introduction to CrewAI</a>
                        <a href="#installation" class="toc-link">2. Installation & Setup</a>
                        <a href="#core-concepts" class="toc-link">3. Core Concepts</a>
                        <a href="#agents" class="toc-link ml-4">3.1 Agents</a>
                        <a href="#tasks" class="toc-link ml-4">3.2 Tasks</a>
                        <a href="#crews" class="toc-link ml-4">3.3 Crews</a>
                        <a href="#tools" class="toc-link ml-4">3.4 Tools</a>
                        <a href="#first-crew" class="toc-link">4. Building Your First Crew</a>
                        <a href="#advanced-features" class="toc-link">5. Advanced Features</a>
                        <a href="#examples" class="toc-link">6. Example Applications</a>
                        <a href="#cheatsheet" class="toc-link">7. CrewAI Cheatsheet</a>
                        <a href="#best-practices" class="toc-link">8. Best Practices</a>
                        <a href="#resources" class="toc-link">9. Additional Resources</a>
                    </nav>
                </div>
            </div>

            <!-- Main Content -->
            <div class="md:w-3/4">
                <div class="banner rounded-lg">
                    <h2 class="text-3xl font-bold mb-4">Master Multi-Agent Systems with CrewAI</h2>
                    <p class="text-xl">Create powerful, collaborative AI systems that can tackle complex tasks through agent cooperation and specialization</p>
                </div>

                <!-- Introduction Section -->
                <section id="introduction" class="section bg-white p-6 rounded-lg shadow">
                    <h2 class="text-2xl font-bold text-blue-800">1. Introduction to CrewAI</h2>

                    <h3 class="text-xl font-semibold mt-6">What is CrewAI?</h3>
                    <p class="mt-3">
                        CrewAI is a cutting-edge Python framework designed for orchestrating role-playing, autonomous AI agents. It enables the creation of specialized AI teams where agents can take on different roles, make autonomous decisions, and collaborate to solve complex problems. Unlike single-agent systems, CrewAI focuses on collaborative intelligence, allowing for more sophisticated problem-solving through agent specialization and teamwork.
                    </p>

                    <h3 class="text-xl font-semibold mt-6">Why Use CrewAI?</h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-3">
                        <div class="card">
                            <h4 class="font-semibold text-blue-700"><i class="fas fa-users mr-2"></i>Role-Playing Agents</h4>
                            <p>Agents can assume specific personas with unique goals, backstories, and expertise areas, enabling more specialized task performance.</p>
                        </div>
                        <div class="card">
                            <h4 class="font-semibold text-blue-700"><i class="fas fa-robot mr-2"></i>Autonomous Decision Making</h4>
                            <p>Agents can make decisions independently based on their goals and available information, reducing the need for human intervention.</p>
                        </div>
                        <div class="card">
                            <h4 class="font-semibold text-blue-700"><i class="fas fa-comments mr-2"></i>Seamless Collaboration</h4>
                            <p>Agents can work together, sharing information and building upon each other's outputs to tackle complex, multi-stage tasks.</p>
                        </div>
                        <div class="card">
                            <h4 class="font-semibold text-blue-700"><i class="fas fa-puzzle-piece mr-2"></i>Complex Problem Solving</h4>
                            <p>The framework is designed to handle intricate workflows, decision trees, and multi-stage problems that would be challenging for single agents.</p>
                        </div>
                    </div>

                    <h3 class="text-xl font-semibold mt-6">Key Features of CrewAI</h3>
                    <ul class="list-disc pl-6 mt-3">
                        <li class="mb-2"><span class="font-semibold">Independent Framework:</span> Built from scratch without dependencies on other agent frameworks like LangChain.</li>
                        <li class="mb-2"><span class="font-semibold">Flexible Agent Design:</span> Create agents with customized roles, goals, tools, and personalities.</li>
                        <li class="mb-2"><span class="font-semibold">Process Flexibility:</span> Choose between sequential and hierarchical process flows for task execution.</li>
                        <li class="mb-2"><span class="font-semibold">Tool Integration:</span> Integrate a wide range of tools to enhance agent capabilities for specific tasks.</li>
                        <li class="mb-2"><span class="font-semibold">Memory Systems:</span> Incorporate short-term and long-term memory to enhance agent performance over time.</li>
                        <li class="mb-2"><span class="font-semibold">Output Formatting:</span> Structured outputs in various formats including raw text, JSON, and Pydantic models.</li>
                    </ul>
                </section>

                <!-- Installation Section -->
                <section id="installation" class="section bg-white p-6 rounded-lg shadow">
                    <h2 class="text-2xl font-bold text-blue-800">2. Installation & Setup</h2>

                    <h3 class="text-xl font-semibold mt-4">Installing CrewAI</h3>
                    <p class="mt-2">Install CrewAI using pip:</p>
                    <div class="code-block bg-black-800 text-white">pip install crewai</div>

                    <p class="mt-3">For additional tools support:</p>
                    <div class="code-block bg-black-800 text-white">pip install crewai-tools</div>

                    <h3 class="text-xl font-semibold mt-6">Environment Setup</h3>
                    <p class="mt-2">CrewAI works with various language models. For OpenAI models, set up your API key:</p>
                    <div class="code-block bg-black-800 text-white"># In your .env file
OPENAI_API_KEY=your-api-key-here</div>

                    <p class="mt-3">For local models using Ollama:</p>
                    <div class="code-block bg-black-800 text-white"># Example setup for Ollama
from langchain.llms import Ollama

local_llm = Ollama(model="llama2")</div>

                    <h3 class="text-xl font-semibold mt-6">Project Creation</h3>
                    <p class="mt-2">Use CrewAI's CLI to create a new project:</p>
                    <div class="code-block bg-black-800 text-white">pip install crewai-cli
crewai create my_crew_project</div>

                    <p class="mt-3">This creates a project structure with the following elements:</p>
                    <div class="code-block bg-black-800 text-white">my_crew_project/
├── src/
│   └── my_crew_project/
│       ├── config/
│       │   ├── agents.yaml
│       │   └── tasks.yaml
│       ├── crew.py
│       └── main.py
├── pyproject.toml
└── README.md</div>

                    <div class="tip mt-4">
                        <strong>Tip:</strong> Use virtual environments to manage your dependencies and avoid conflicts with other projects. Consider using tools like <code>venv</code>, <code>virtualenv</code>, or <code>conda</code>.
                    </div>
                </section>

                <!-- Core Concepts Section -->
                <section id="core-concepts" class="section bg-white p-6 rounded-lg shadow">
                    <h2 class="text-2xl font-bold text-blue-800">3. Core Concepts</h2>
                    <p class="mt-3">
                        CrewAI is built around four main concepts: Agents, Tasks, Crews, and Tools. Understanding these components and how they interact is essential for building effective multi-agent systems.
                    </p>
                </section>

                <!-- Agents Section -->
                <section id="agents" class="section bg-white p-6 rounded-lg shadow">
                    <h3 class="text-xl font-bold text-blue-800">3.1 Agents</h3>
                    <p class="mt-3">
                        An agent in CrewAI is an autonomous unit programmed to perform tasks, make decisions, and communicate with other agents. Each agent has a specific role, goal, and backstory that shape its behavior and decision-making process.
                    </p>

                    <h4 class="text-lg font-semibold mt-4">Key Agent Attributes</h4>
                    <div class="overflow-x-auto">
                        <table class="reference-table">
                            <thead>
                                <tr>
                                    <th>Attribute</th>
                                    <th>Description</th>
                                    <th>Required</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td><code>role</code></td>
                                    <td>Defines the agent's function within the crew</td>
                                    <td>Yes</td>
                                </tr>
                                <tr>
                                    <td><code>goal</code></td>
                                    <td>The individual objective that the agent aims to achieve</td>
                                    <td>Yes</td>
                                </tr>
                                <tr>
                                    <td><code>backstory</code></td>
                                    <td>Provides context to the agent's role and goal</td>
                                    <td>Yes</td>
                                </tr>
                                <tr>
                                    <td><code>llm</code></td>
                                    <td>The language model that powers the agent</td>
                                    <td>No</td>
                                </tr>
                                <tr>
                                    <td><code>tools</code></td>
                                    <td>Functions/capabilities the agent can use</td>
                                    <td>No</td>
                                </tr>
                                <tr>
                                    <td><code>verbose</code></td>
                                    <td>Controls the level of logging detail</td>
                                    <td>No</td>
                                </tr>
                                <tr>
                                    <td><code>allow_delegation</code></td>
                                    <td>Enables the agent to delegate tasks to others</td>
                                    <td>No</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                    <h4 class="text-lg font-semibold mt-6">Creating an Agent</h4>
                    <div class="code-block bg-black-800 text-white">from crewai import Agent

researcher = Agent(
    role="Research Analyst",
    goal="Find the most accurate and up-to-date information on AI trends",
    backstory="You're a senior research analyst with 15 years of experience in technology trends analysis. Your attention to detail and ability to distinguish relevant information from noise is unmatched.",
    tools=[search_tool],  # Optional
    llm=openai_llm,       # Optional
    verbose=True          # Optional
)</div>

                    <h4 class="text-lg font-semibold mt-6">YAML Configuration (Recommended Approach)</h4>
                    <p class="mt-2">Define agents in YAML for better organization:</p>
                    <div class="code-block bg-black-800 text-white"># In agents.yaml
researcher:
  role: "Research Analyst"
  goal: "Find the most accurate and up-to-date information on AI trends"
  backstory: "You're a senior research analyst with 15 years of experience in technology trends analysis. Your attention to detail and ability to distinguish relevant information from noise is unmatched."
  llm: "openai"  # Reference to a defined LLM

writer:
  role: "Technical Writer"
  goal: "Transform complex research into clear, engaging content"
  backstory: "You're an experienced technical writer who can explain complex concepts in simple terms."
  llm: "anthropic"  # Reference to a defined LLM</div>

                    <p class="mt-3">Then in your code:</p>
                    <div class="code-block bg-black-800 text-white">@agent
def researcher(self) -> Agent:
    return Agent(
        config=self.agents_config["researcher"],
        tools=[search_tool]
    )</div>

                    <div class="tip mt-4">
                        <p><strong>Best Practices for Agents:</strong></p>
                        <ul class="list-disc pl-5 mt-2">
                            <li>Give agents clear, specific goals that guide their actions</li>
                            <li>Create detailed backstories that provide context for decision-making</li>
                            <li>Define specialized roles with minimal overlap to improve collaboration</li>
                            <li>Equip agents with appropriate tools for their specific roles</li>
                        </ul>
                    </div>
                </section>

                <!-- Tasks Section -->
                <section id="tasks" class="section bg-white p-6 rounded-lg shadow">
                    <h3 class="text-xl font-bold text-blue-800">3.2 Tasks</h3>
                    <p class="mt-3">
                        Tasks are specific assignments completed by agents. They define what needs to be done, how it should be accomplished, and what the expected output is. Tasks can be assigned to specific agents and can depend on the outputs of other tasks.
                    </p>

                    <h4 class="text-lg font-semibold mt-4">Key Task Attributes</h4>
                    <div class="overflow-x-auto">
                        <table class="reference-table">
                            <thead>
                                <tr>
                                    <th>Attribute</th>
                                    <th>Description</th>
                                    <th>Required</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td><code>description</code></td>
                                    <td>Detailed instructions for the task</td>
                                    <td>Yes</td>
                                </tr>
                                <tr>
                                    <td><code>expected_output</code></td>
                                    <td>Description of what the completed task should produce</td>
                                    <td>Yes</td>
                                </tr>
                                <tr>
                                    <td><code>agent</code></td>
                                    <td>The agent responsible for executing the task</td>
                                    <td>No*</td>
                                </tr>
                                <tr>
                                    <td><code>tools</code></td>
                                    <td>Specific tools available for this task</td>
                                    <td>No</td>
                                </tr>
                                <tr>
                                    <td><code>context</code></td>
                                    <td>Outputs from previous tasks to use as context</td>
                                    <td>No</td>
                                </tr>
                                <tr>
                                    <td><code>async_execution</code></td>
                                    <td>Whether to execute the task asynchronously</td>
                                    <td>No</td>
                                </tr>
                                <tr>
                                    <td><code>human_input</code></td>
                                    <td>Whether human review is required for final answer</td>
                                    <td>No</td>
                                </tr>
                                <tr>
                                    <td><code>output_file</code></td>
                                    <td>File path for storing the task output</td>
                                    <td>No</td>
                                </tr>
                                <tr>
                                    <td><code>output_json</code></td>
                                    <td>Pydantic model for JSON output structure</td>
                                    <td>No</td>
                                </tr>
                                <tr>
                                    <td><code>output_pydantic</code></td>
                                    <td>Pydantic model for output validation</td>
                                    <td>No</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <p class="text-sm mt-1">* Either agent must be specified when creating the task, or assigned when adding the task to a crew.</p>

                    <h4 class="text-lg font-semibold mt-6">Creating a Task</h4>
                    <div class="code-block bg-black-800 text-white">from crewai import Task

research_task = Task(
    description="Research the latest advancements in quantum computing and their potential applications in cryptography. Focus on breakthroughs from the past 12 months.",
    expected_output="A comprehensive 2-page report detailing recent quantum computing advances and their implications for cryptographic systems.",
    agent=researcher,
    tools=[search_tool, browse_tool],  # Optional
    context=[],                        # Optional
    async_execution=False              # Optional
)</div>

                    <h4 class="text-lg font-semibold mt-6">YAML Configuration</h4>
                    <div class="code-block bg-black-800 text-white"># In tasks.yaml
research_task:
  description: "Research the latest advancements in quantum computing and their potential applications in cryptography. Focus on breakthroughs from the past 12 months."
  expected_output: "A comprehensive 2-page report detailing recent quantum computing advances and their implications for cryptographic systems."
  agent: researcher  # Reference to agent defined in agents.yaml

write_article_task:
  description: "Create an engaging blog article about quantum computing advances aimed at a technical audience with some knowledge of cryptography."
  expected_output: "A 1500-word blog article with sections, subheadings, and easily digestible explanations of complex concepts."
  agent: writer
  context:
    - research_task  # Reference to another task whose output will be used</div>

                    <h4 class="text-lg font-semibold mt-6">Task Dependencies & Context</h4>
                    <p class="mt-2">One of CrewAI's powerful features is the ability to create task dependencies:</p>
                    <div class="code-block bg-black-800 text-white">from crewai import Task

research_task = Task(
    description="Research quantum computing advances",
    expected_output="Research report",
    agent=researcher
)

write_article_task = Task(
    description="Write an engaging article based on the research findings",
    expected_output="1500-word article",
    agent=writer,
    context=[research_task]  # This task depends on research_task
)</div>

                    <h4 class="text-lg font-semibold mt-6">Structured Output</h4>
                    <p class="mt-2">For more controlled outputs, use Pydantic models:</p>
                    <div class="code-block bg-black-800 text-white">from pydantic import BaseModel
from crewai import Task

class ResearchReport(BaseModel):
    title: str
    summary: str
    findings: list[str]
    implications: list[str]

research_task = Task(
    description="Research quantum computing advances",
    expected_output="Structured research report",
    agent=researcher,
    output_pydantic=ResearchReport  # Output will conform to this model
)</div>

                    <div class="tip mt-4">
                        <p><strong>Best Practices for Tasks:</strong></p>
                        <ul class="list-disc pl-5 mt-2">
                            <li>Write clear, specific task descriptions with unambiguous instructions</li>
                            <li>Define concrete expected outputs that can be measured</li>
                            <li>Use task context to create logical workflows between agents</li>
                            <li>Consider using structured outputs for complex data</li>
                            <li>Break complex processes into multiple distinct tasks</li>
                        </ul>
                    </div>
                </section>

                <!-- Crews Section -->
                <section id="crews" class="section bg-white p-6 rounded-lg shadow">
                    <h3 class="text-xl font-bold text-blue-800">3.3 Crews</h3>
                    <p class="mt-3">
                        A Crew in CrewAI orchestrates the collaboration between agents to complete a set of tasks. It defines the strategy for task execution, manages the communication between agents, and handles the workflow from start to finish.
                    </p>

                    <h4 class="text-lg font-semibold mt-4">Key Crew Attributes</h4>
                    <div class="overflow-x-auto">
                        <table class="reference-table">
                            <thead>
                                <tr>
                                    <th>Attribute</th>
                                    <th>Description</th>
                                    <th>Required</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td><code>agents</code></td>
                                    <td>List of agents participating in the crew</td>
                                    <td>Yes</td>
                                </tr>
                                <tr>
                                    <td><code>tasks</code></td>
                                    <td>List of tasks to be completed by the crew</td>
                                    <td>Yes</td>
                                </tr>
                                <tr>
                                    <td><code>process</code></td>
                                    <td>Workflow strategy (sequential/hierarchical)</td>
                                    <td>No</td>
                                </tr>
                                <tr>
                                    <td><code>verbose</code></td>
                                    <td>Controls level of logging and output</td>
                                    <td>No</td>
                                </tr>
                                <tr>
                                    <td><code>manager_llm</code></td>
                                    <td>LLM used by the manager in hierarchical process</td>
                                    <td>No*</td>
                                </tr>
                                <tr>
                                    <td><code>function_calling_llm</code></td>
                                    <td>LLM used for function/tool calling</td>
                                    <td>No</td>
                                </tr>
                                <tr>
                                    <td><code>memory</code></td>
                                    <td>Enables storing execution memories</td>
                                    <td>No</td>
                                </tr>
                                <tr>
                                    <td><code>cache</code></td>
                                    <td>Enables caching tool execution results</td>
                                    <td>No</td>
                                </tr>
                                <tr>
                                    <td><code>full_output</code></td>
                                    <td>Return outputs from all tasks, not just the last</td>
                                    <td>No</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <p class="text-sm mt-1">* Required when using hierarchical process</p>

                    <h4 class="text-lg font-semibold mt-6">Creating a Crew</h4>
                    <div class="code-block bg-black-800 text-white">from crewai import Crew

crew = Crew(
    agents=[researcher, writer, editor],
    tasks=[research_task, writing_task, editing_task],
    process="sequential",     # Optional, default is sequential
    verbose=True,             # Optional
    memory=True,              # Optional
    cache=True                # Optional
)</div>

                    <h4 class="text-lg font-semibold mt-6">Process Types</h4>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-3">
                        <div class="card">
                            <h4 class="font-semibold text-blue-700">Sequential Process</h4>
                            <p>Tasks are executed one after another in the order they are defined. This is the default process type.</p>
                            <div class="mt-2">
                                <span class="inline-block bg-black-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2">Simple to understand</span>
                                <span class="inline-block bg-black-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700">Predictable flow</span>
                            </div>
                        </div>
                        <div class="card">
                            <h4 class="font-semibold text-blue-700">Hierarchical Process</h4>
                            <p>A manager agent coordinates the crew, delegating tasks and validating outcomes. Requires a manager_llm.</p>
                            <div class="mt-2">
                                <span class="inline-block bg-black-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2">More flexible</span>
                                <span class="inline-block bg-black-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700">Complex interactions</span>
                            </div>
                        </div>
                    </div>

                    <h4 class="text-lg font-semibold mt-6">Kicking Off a Crew</h4>
                    <div class="code-block bg-black-800 text-white">result = crew.kickoff()
print(result)  # Prints the final output

# For hierarchical process
hierarchical_crew = Crew(
    agents=[manager, researcher, writer, editor],
    tasks=[research_task, writing_task, editing_task],
    process="hierarchical",
    manager_llm=openai_llm  # Required for hierarchical process
)
result = hierarchical_crew.kickoff()</div>

                    <h4 class="text-lg font-semibold mt-6">Working with Crew Outputs</h4>
                    <div class="code-block bg-black-800 text-white">result = crew.kickoff()

# Access the raw text output
print(result.raw)

# If using output_json or output_pydantic in the final task
if result.json_dict:
    print(f"Title: {result.json_dict['title']}")
    print(f"Summary: {result.json_dict['summary']}")

# Access all task outputs (if full_output=True)
for task_output in result.tasks_output:
    print(f"Task: {task_output.description}")
    print(f"Output: {task_output.raw}")

# Check token usage
print(f"Token usage: {result.token_usage}")</div>

                    <div class="tip mt-4">
                        <p><strong>Best Practices for Crews:</strong></p>
                        <ul class="list-disc pl-5 mt-2">
                            <li>Start with sequential processes for simpler workflows</li>
                            <li>Use hierarchical processes when tasks require complex coordination</li>
                            <li>Enable memory for tasks that benefit from context retention</li>
                            <li>Use verbose mode during development for debugging</li>
                            <li>Consider the crew as a reusable workflow that can be applied to different inputs</li>
                        </ul>
                    </div>
                </section>

                <!-- Tools Section -->
                <section id="tools" class="section bg-white p-6 rounded-lg shadow">
                    <h3 class="text-xl font-bold text-blue-800">3.4 Tools</h3>
                    <p class="mt-3">
                        Tools extend the capabilities of agents, allowing them to perform actions like searching the web, analyzing data, or interacting with external systems. CrewAI supports a wide range of tools from both its own toolkit and LangChain.
                    </p>

                    <h4 class="text-lg font-semibold mt-4">Popular CrewAI Tools</h4>
                    <div class="overflow-x-auto">
                        <table class="reference-table">
                            <thead>
                                <tr>
                                    <th>Tool Category</th>
                                    <th>Examples</th>
                                    <th>Use Cases</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>Search Tools</td>
                                    <td>SerperDevTool, WebsiteSearchTool</td>
                                    <td>Information gathering, research</td>
                                </tr>
                                <tr>
                                    <td>Document Tools</td>
                                    <td>PDFSearchTool, CSVSearchTool, DOCXSearchTool</td>
                                    <td>Extracting information from documents</td>
                                </tr>
                                <tr>
                                    <td>Web Tools</td>
                                    <td>ScrapeWebsiteTool, FirecrawlSearchTool</td>
                                    <td>Extracting data from websites</td>
                                </tr>
                                <tr>
                                    <td>Code & Data Tools</td>
                                    <td>CodeInterpreterTool, CodeDocsSearchTool</td>
                                    <td>Processing code, analyzing data</td>
                                </tr>
                                <tr>
                                    <td>Media Tools</td>
                                    <td>DALL-E Tool, Vision Tool, YoutubeVideoSearchTool</td>
                                    <td>Generating and analyzing media</td>
                                </tr>
                                <tr>
                                    <td>RAG Tools</td>
                                    <td>RagTool, Various document search tools</td>
                                    <td>Retrieval augmented generation</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                    <h4 class="text-lg font-semibold mt-6">Installing Tools</h4>
                    <div class="code-block bg-black-800 text-white">pip install crewai-tools</div>

                    <h4 class="text-lg font-semibold mt-6">Using Tools</h4>
                    <div class="code-block bg-black-800 text-white">from crewai_tools import SerperDevTool, ScrapeWebsiteTool

# Initialize tools
search_tool = SerperDevTool()
scrape_tool = ScrapeWebsiteTool()

# Assign tools to an agent
researcher = Agent(
    role="Research Analyst",
    goal="Find accurate information",
    backstory="You're an expert researcher",
    tools=[search_tool, scrape_tool]
)</div>

                    <h4 class="text-lg font-semibold mt-6">Creating Custom Tools</h4>
                    <p class="mt-2">There are two main ways to create custom tools in CrewAI:</p>

                    <h5 class="font-semibold mt-4">1. Using the tool decorator</h5>
                    <div class="code-block bg-black-800 text-white">from crewai.tools import tool

@tool
def calculate_mortgage(principal: float, interest_rate: float, years: int) -> str:
    """
    Calculate the monthly mortgage payment.

    Args:
        principal: Loan amount in dollars
        interest_rate: Annual interest rate (as a decimal, e.g., 0.05 for 5%)
        years: Loan term in years

    Returns:
        Monthly payment amount and total interest paid
    """
    # Tool implementation here
    monthly_rate = interest_rate / 12
    num_payments = years * 12

    # Calculate monthly payment using the mortgage formula
    payment = principal * (monthly_rate * (1 + monthly_rate)**num_payments) / ((1 + monthly_rate)**num_payments - 1)

    total_paid = payment * num_payments
    total_interest = total_paid - principal

    return f"Monthly payment: ${payment:.2f}\nTotal interest paid: ${total_interest:.2f}"</div>

                    <h5 class="font-semibold mt-4">2. Subclassing BaseTool</h5>
                    <div class="code-block bg-black-800 text-white">from crewai.tools import BaseTool
from pydantic import Field
from typing import Dict, Any

class StockPriceTool(BaseTool):
    """Tool for getting stock price information."""

    name: str = "Stock Price Tool"
    description: str = "Get current stock price information for a given ticker symbol"

    def _run(self, ticker: str) -> Dict[str, Any]:
        """
        Get stock price information.

        Args:
            ticker: The stock ticker symbol (e.g., AAPL for Apple)

        Returns:
            Dictionary with stock information
        """
        # Implement API call or data retrieval here
        # This is a simplified example
        import random
        price = round(random.uniform(50, 500), 2)

        return {
            "ticker": ticker,
            "price": price,
            "currency": "USD",
            "timestamp": "2023-10-24T15:30:00Z"
        }</div>

                    <h4 class="text-lg font-semibold mt-6">Tool Caching</h4>
                    <p class="mt-2">CrewAI tools support caching to improve performance:</p>
                    <div class="code-block bg-black-800 text-white">from crewai import Agent

# Enable caching at the agent level
researcher = Agent(
    role="Research Analyst",
    goal="Find accurate information",
    backstory="You're an expert researcher",
    tools=[search_tool, scrape_tool],
    cache=True  # Enable caching for all tools used by this agent
)</div>

                    <div class="warning mt-4">
                        <p><strong>Important:</strong> When using tools that require API keys (like SerperDevTool), make sure to set up the appropriate environment variables before using them.</p>
                    </div>
                </section>

                <!-- First Crew Section -->
                <section id="first-crew" class="section bg-white p-6 rounded-lg shadow">
                    <h2 class="text-2xl font-bold text-blue-800">4. Building Your First Crew</h2>
                    <p class="mt-3">
                        Let's walk through building a basic research crew that will research a topic and create a report. This example demonstrates the key concepts of CrewAI in a practical application.
                    </p>

                    <h3 class="text-xl font-semibold mt-4">Step 1: Project Setup</h3>
                    <div class="step">
                        <div class="step-number">1</div>
                        <p>Create a new project directory and set up your environment:</p>
                        <div class="code-block bg-black-800 text-white">mkdir research-crew
cd research-crew
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install crewai crewai-tools</div>
                    </div>

                    <h3 class="text-xl font-semibold mt-4">Step 2: Define Your Agents</h3>
                    <div class="step">
                        <div class="step-number">2</div>
                        <p>Create a file named <code>agents.py</code> to define your agents:</p>
                        <div class="code-block bg-black-800 text-white">from crewai import Agent

def create_researcher(llm):
    return Agent(
        role="Research Analyst",
        goal="Find comprehensive and accurate information on the given topic",
        backstory="You are an experienced research analyst with a talent for finding reliable information quickly. You're meticulous about fact-checking and always seek multiple sources to confirm information.",
        llm=llm,
        verbose=True
    )

def create_writer(llm):
    return Agent(
        role="Content Writer",
        goal="Transform research findings into clear, engaging, and well-structured reports",
        backstory="You are a talented writer with a knack for explaining complex topics in an accessible way. You have experience creating various types of content including reports, articles, and presentations.",
        llm=llm,
        verbose=True
    )</div>
                    </div>

                    <h3 class="text-xl font-semibold mt-4">Step 3: Define Your Tasks</h3>
                    <div class="step">
                        <div class="step-number">3</div>
                        <p>Create a file named <code>tasks.py</code> to define your tasks:</p>
                        <div class="code-block bg-black-800 text-white">from crewai import Task
from crewai_tools import SerperDevTool

search_tool = SerperDevTool()

def create_research_task(researcher, topic):
    return Task(
        description=f"Research the topic: {topic}. Find key information including recent developments, major concepts, important figures, and relevant statistics. Focus on high-quality sources and make sure to fact-check the information.",
        expected_output="A comprehensive research document with organized sections covering different aspects of the topic. Include a list of sources.",
        agent=researcher,
        tools=[search_tool]
    )

def create_report_task(writer, topic):
    return Task(
        description=f"Create a well-structured report on {topic} based on the research findings. The report should be informative, engaging, and easy to understand.",
        expected_output="A polished report with an executive summary, introduction, main body (with sections and subsections), conclusion, and references.",
        agent=writer
    )</div>
                    </div>

                    <h3 class="text-xl font-semibold mt-4">Step 4: Set Up Your Crew</h3>
                    <div class="step">
                        <div class="step-number">4</div>
                        <p>Create a file named <code>crew.py</code> to set up your crew:</p>
                        <div class="code-block bg-black-800 text-white">from crewai import Crew
from agents import create_researcher, create_writer
from tasks import create_research_task, create_report_task

def create_research_crew(llm, topic):
    # Create agents
    researcher = create_researcher(llm)
    writer = create_writer(llm)

    # Create tasks
    research_task = create_research_task(researcher, topic)
    report_task = create_report_task(writer, topic)
    report_task.context = [research_task]  # Link tasks

    # Create and return the crew
    crew = Crew(
        agents=[researcher, writer],
        tasks=[research_task, report_task],
        verbose=True
    )

    return crew</div>
                    </div>

                    <h3 class="text-xl font-semibold mt-4">Step 5: Create the Main Script</h3>
                    <div class="step">
                        <div class="step-number">5</div>
                        <p>Create a file named <code>main.py</code> to run your crew:</p>
                        <div class="code-block bg-black-800 text-white">import os
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from crew import create_research_crew

def main():
    # Load environment variables
    load_dotenv()

    # Set up the language model
    llm = ChatOpenAI(
        api_key=os.getenv("OPENAI_API_KEY"),
        model="gpt-4",
        temperature=0.5
    )

    # Topic to research
    topic = "Quantum Computing Basics"

    # Create and run the crew
    crew = create_research_crew(llm, topic)
    result = crew.kickoff()

    # Save the output to a file
    with open("report.md", "w") as f:
        f.write(result.raw)

    print(f"Research report saved to report.md")

if __name__ == "__main__":
    main()</div>
                    </div>

                    <h3 class="text-xl font-semibold mt-4">Step 6: Set Up Environment Variables</h3>
                    <div class="step">
                        <div class="step-number">6</div>
                        <p>Create a <code>.env</code> file with your API keys:</p>
                        <div class="code-block bg-black-800 text-white">OPENAI_API_KEY=your_openai_api_key_here
SERPER_API_KEY=your_serper_api_key_here</div>
                    </div>

                    <h3 class="text-xl font-semibold mt-4">Step 7: Run Your Crew</h3>
                    <div class="step">
                        <div class="step-number">7</div>
                        <p>Run the main script to execute your crew:</p>
                        <div class="code-block bg-black-800 text-white">python main.py</div>
                        <p class="mt-2">You'll see the agents working, thinking, and communicating in the terminal output. When complete, check the generated report.md file for the final output.</p>
                    </div>

                    <div class="success-box mt-6">
                        <p class="font-semibold">Success!</p>
                        <p>You've created your first CrewAI crew with:</p>
                        <ul class="list-disc pl-5 mt-2">
                            <li>Two specialized agents with distinct roles</li>
                            <li>A sequential workflow where tasks build on each other</li>
                            <li>Integration of external tools for research</li>
                            <li>A complete end-to-end process from research to report generation</li>
                        </ul>
                    </div>
                </section>

                <!-- Advanced Features Section -->
                <section id="advanced-features" class="section bg-white p-6 rounded-lg shadow">
                    <h2 class="text-2xl font-bold text-blue-800">5. Advanced Features</h2>
                    <p class="mt-3">
                        CrewAI offers several advanced features that can enhance your multi-agent systems. Let's explore some of these powerful capabilities.
                    </p>

                    <h3 class="text-xl font-semibold mt-4">Hierarchical Process</h3>
                    <p class="mt-2">
                        The hierarchical process introduces a manager agent that coordinates the crew's activities, making decisions about task delegation and validation.
                    </p>
                    <div class="code-block bg-black-800 text-white">from crewai import Crew
from langchain_openai import ChatOpenAI

manager_llm = ChatOpenAI(model="gpt-4")

crew = Crew(
    agents=[researcher, writer, editor],
    tasks=[research_task, writing_task, editing_task],
    process="hierarchical",
    manager_llm=manager_llm,  # Required for hierarchical process
    verbose=True
)

result = crew.kickoff()</div>

                    <h3 class="text-xl font-semibold mt-6">Custom Manager Agent</h3>
                    <p class="mt-2">
                        You can define a custom manager agent with specialized expertise for better coordination:
                    </p>
                    <div class="code-block bg-black-800 text-white">from crewai import Agent, Crew

project_manager = Agent(
    role="Project Manager",
    goal="Efficiently coordinate the team to deliver high-quality outputs on time",
    backstory="You're an experienced project manager with a track record of successful project deliveries. You excel at resource allocation, risk management, and ensuring team synergy.",
    llm=openai_llm,
    verbose=True
)

crew = Crew(
    agents=[researcher, writer, editor],
    tasks=[research_task, writing_task, editing_task],
    process="hierarchical",
    manager_agent=project_manager,  # Using custom manager
    verbose=True
)</div>

                    <h3 class="text-xl font-semibold mt-6">Memory Systems</h3>
                    <p class="mt-2">
                        CrewAI supports memory to enable agents to retain information across interactions:
                    </p>
                    <div class="code-block bg-black-800 text-white">from crewai import Crew

crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, writing_task],
    memory=True,  # Enable memory
    verbose=True
)

# Memory is particularly useful for multi-session interactions
result_day1 = crew.kickoff(inputs={"topic": "Quantum Computing Part 1"})
# Later session continues with awareness of previous work
result_day2 = crew.kickoff(inputs={"topic": "Quantum Computing Part 2"})</div>

                    <h3 class="text-xl font-semibold mt-6">Structured Outputs</h3>
                    <p class="mt-2">
                        Get structured data from your crews using Pydantic models:
                    </p>
                    <div class="code-block bg-black-800 text-white">from pydantic import BaseModel, Field
from typing import List
from crewai import Task

class ResearchFindings(BaseModel):
    topic: str = Field(description="The main topic of research")
    key_points: List[str] = Field(description="List of main findings or points")
    sources: List[str] = Field(description="References and sources of information")
    future_directions: List[str] = Field(description="Suggested areas for further research")

research_task = Task(
    description="Research quantum computing advances",
    expected_output="Structured research findings",
    agent=researcher,
    output_pydantic=ResearchFindings
)

result = crew.kickoff()
print(f"Topic: {result.pydantic.topic}")
print(f"Key points: {result.pydantic.key_points}")
print(f"Sources: {result.pydantic.sources}")</div>

                    <h3 class="text-xl font-semibold mt-6">Asynchronous Execution</h3>
                    <p class="mt-2">
                        Run tasks asynchronously for better performance:
                    </p>
                    <div class="code-block bg-black-800 text-white">from crewai import Task, Crew

# Create tasks with async_execution flag
async_research_task = Task(
    description="Research quantum computing",
    expected_output="Research findings",
    agent=researcher,
    async_execution=True  # This task will run asynchronously
)

# Use the async kickoff method
import asyncio

async def run_crew_async():
    crew = Crew(
        agents=[researcher, writer],
        tasks=[async_research_task, writing_task]
    )
    result = await crew.kickoff_async()
    return result

# Run the async function
result = asyncio.run(run_crew_async())</div>

                    <h3 class="text-xl font-semibold mt-6">Task Guardrails</h3>
                    <p class="mt-2">
                        Implement validation for task outputs:
                    </p>
                    <div class="code-block bg-black-800 text-white">from crewai import Task
from typing import Tuple, Any

def validate_research(output: str) -> Tuple[bool, Any]:
    """Validate research output meets quality criteria."""
    # Check for minimum length
    if len(output) < 500:
        return False, "Research output is too short. Please provide more detailed information."

    # Check for sources
    if "References:" not in output and "Sources:" not in output:
        return False, "Missing references or sources. Please include sources for your research."

    # If all checks pass
    return True, output

research_task = Task(
    description="Research quantum computing advances",
    expected_output="Comprehensive research with sources",
    agent=researcher,
    guardrail=validate_research  # Add validation function
)</div>

                    <h3 class="text-xl font-semibold mt-6">Task Callbacks</h3>
                    <p class="mt-2">
                        Execute custom functions after tasks complete:
                    </p>
                    <div class="code-block bg-black-800 text-white">from crewai import Task, Crew

def post_research_callback(task_output):
    """Process research after completion."""
    print(f"Research task completed with {len(task_output.raw)} characters")
    # Save to database, send notification, etc.
    with open("research_results.md", "w") as f:
        f.write(task_output.raw)
    return task_output

research_task = Task(
    description="Research quantum computing advances",
    expected_output="Comprehensive research with sources",
    agent=researcher,
    callback=post_research_callback  # Will execute after task completion
)

# You can also set a callback for the entire crew
def crew_step_callback(step_output):
    """Track each step of crew execution."""
    print(f"Step completed: {step_output}")
    return step_output

crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, writing_task],
    step_callback=crew_step_callback
)</div>

                    <h3 class="text-xl font-semibold mt-6">Planning</h3>
                    <p class="mt-2">
                        Enable automatic planning for more complex workflows:
                    </p>
                    <div class="code-block bg-black-800 text-white">from crewai import Crew

crew = Crew(
    agents=[researcher, writer, editor],
    tasks=[research_task, writing_task, editing_task],
    planning=True,  # Enable automatic planning
    planning_llm=openai_llm,  # Optional, specify LLM for planning
    verbose=True
)

result = crew.kickoff()</div>

                    <div class="tip mt-4">
                        <p><strong>Tip:</strong> Advanced features often require more careful configuration and testing. Start with simpler setups and gradually incorporate advanced features as you become more familiar with CrewAI.</p>
                    </div>
                </section>

                <!-- Example Applications Section -->
                <section id="examples" class="section bg-white p-6 rounded-lg shadow">
                    <h2 class="text-2xl font-bold text-blue-800">6. Example Applications</h2>
                    <p class="mt-3">
                        Let's explore some practical example applications that you can build with CrewAI. These examples demonstrate how to apply CrewAI's capabilities to solve real-world problems.
                    </p>

                    <h3 class="text-xl font-semibold mt-6">Business Plan Generator</h3>
                    <div class="card p-4">
                        <h4 class="font-semibold text-blue-700 text-lg">Use Case: Generate a business plan for a startup idea</h4>
                        <p class="mt-2"><strong>Agents:</strong></p>
                        <ul class="list-disc pl-6 mt-1">
                            <li><strong>Market Research Analyst:</strong> Researches market trends, competitors, and customer needs</li>
                            <li><strong>Technologist:</strong> Evaluates technical feasibility and implementation requirements</li>
                            <li><strong>Business Consultant:</strong> Creates the final business plan with financial projections</li>
                        </ul>
                        <p class="mt-2"><strong>Workflow:</strong></p>
                        <ol class="list-decimal pl-6 mt-1">
                            <li>Market Research Analyst analyzes the market demand for the proposed product</li>
                            <li>Technologist evaluates the technology requirements based on market analysis</li>
                            <li>Business Consultant creates a comprehensive business plan based on both analyses</li>
                        </ol>
                        <p class="mt-3 italic text-sm">Example input: "Generate a business plan for an AI-powered personal fitness coaching app that uses computer vision to track workouts and provide real-time feedback."</p>
                    </div>

                    <h3 class="text-xl font-semibold mt-6">Content Creation System</h3>
                    <div class="card p-4">
                        <h4 class="font-semibold text-blue-700 text-lg">Use Case: Create blog posts, social media content, and email newsletters</h4>
                        <p class="mt-2"><strong>Agents:</strong></p>
                        <ul class="list-disc pl-6 mt-1">
                            <li><strong>Topic Researcher:</strong> Identifies trending topics and key information</li>
                            <li><strong>Content Writer:</strong> Creates the main content in an engaging style</li>
                            <li><strong>Editor:</strong> Reviews content for clarity, accuracy, and SEO optimization</li>
                            <li><strong>Social Media Specialist:</strong> Crafts promotional snippets for different platforms</li>
                        </ul>
                        <p class="mt-2"><strong>Workflow:</strong></p>
                        <ol class="list-decimal pl-6 mt-1">
                            <li>Topic Researcher identifies trending topics and gathers key information</li>
                            <li>Content Writer creates the main content based on research</li>
                            <li>Editor reviews and refines the content</li>
                            <li>Social Media Specialist creates promotional material for different platforms</li>
                        </ol>
                        <p class="mt-3 italic text-sm">Example input: "Create content about sustainable living tips for urban apartment dwellers, including a blog post, Twitter thread, and newsletter."</p>
                    </div>

                    <h3 class="text-xl font-semibold mt-6">Trip Planner</h3>
                    <div class="card p-4">
                        <h4 class="font-semibold text-blue-700 text-lg">Use Case: Create personalized travel itineraries</h4>
                        <p class="mt-2"><strong>Agents:</strong></p>
                        <ul class="list-disc pl-6 mt-1">
                            <li><strong>Destination Researcher:</strong> Researches attractions, accommodations, and local information</li>
                            <li><strong>Travel Logistics Expert:</strong> Plans transportation, timing, and practical arrangements</li>
                            <li><strong>Experience Curator:</strong> Personalizes the itinerary based on traveler preferences</li>
                        </ul>
                        <p class="mt-2"><strong>Workflow:</strong></p>
                        <ol class="list-decimal pl-6 mt-1">
                            <li>Destination Researcher gathers information about the location</li>
                            <li>Travel Logistics Expert creates a feasible schedule with transportation</li>
                            <li>Experience Curator customizes the plan based on preferences and provides the final itinerary</li>
                        </ol>
                        <p class="mt-3 italic text-sm">Example input: "Plan a 5-day trip to Tokyo for a family of four with children aged 8 and 12 who are interested in technology, anime, and outdoor activities. Budget: moderate."</p>
                    </div>

                    <h3 class="text-xl font-semibold mt-6">Market Analysis Report</h3>
                    <div class="card p-4">
                        <h4 class="font-semibold text-blue-700 text-lg">Use Case: Analyze a specific market or industry</h4>
                        <p class="mt-2"><strong>Agents:</strong></p>
                        <ul class="list-disc pl-6 mt-1">
                            <li><strong>Industry Researcher:</strong> Gathers data on market trends, size, and growth</li>
                            <li><strong>Competitive Analyst:</strong> Analyzes key competitors and market dynamics</li>
                            <li><strong>Financial Analyst:</strong> Reviews financial aspects and investment potential</li>
                            <li><strong>Report Writer:</strong> Creates the final comprehensive report</li>
                        </ul>
                        <p class="mt-2"><strong>Workflow:</strong></p>
                        <ol class="list-decimal pl-6 mt-1">
                            <li>Industry Researcher collects market data and trends</li>
                            <li>Competitive Analyst evaluates the competitive landscape</li>
                            <li>Financial Analyst reviews the financial potential and risks</li>
                            <li>Report Writer compiles all analyses into a cohesive report</li>
                        </ol>
                        <p class="mt-3 italic text-sm">Example input: "Create a market analysis report for the electric vehicle charging infrastructure industry in Europe, focusing on growth opportunities for the next 5 years."</p>
                    </div>

                    <div class="tip mt-6">
                        <p><strong>Tip for Implementation:</strong> Start with a simplified version of these examples with just 2-3 agents, then expand as you become more comfortable with CrewAI. Focus on creating well-defined roles and clear task descriptions to ensure effective agent collaboration.</p>
                    </div>
                </section>

                <!-- Cheatsheet Section -->
                <section id="cheatsheet" class="section bg-white p-6 rounded-lg shadow">
                    <h2 class="text-2xl font-bold text-blue-800">7. CrewAI Cheatsheet</h2>
                    <p class="mt-3">
                        This comprehensive cheatsheet provides quick reference for the most common CrewAI patterns and configurations.
                    </p>

                    <h3 class="text-xl font-semibold mt-4">Agent Creation Patterns</h3>
                    <div class="code-block bg-black-800 text-white"># Basic Agent
from crewai import Agent

basic_agent = Agent(
    role="Researcher",
    goal="Find accurate information",
    backstory="You're an experienced researcher with expertise in data analysis."
)

# Agent with Tools
from crewai_tools import SerperDevTool

search_tool = SerperDevTool()
agent_with_tools = Agent(
    role="Researcher",
    goal="Find accurate information",
    backstory="You're an experienced researcher.",
    tools=[search_tool]
)

# Agent with Custom LLM
from langchain_openai import ChatOpenAI

custom_llm = ChatOpenAI(model="gpt-4")
agent_with_llm = Agent(
    role="Researcher",
    goal="Find accurate information",
    backstory="You're an experienced researcher.",
    llm=custom_llm
)

# Agent with Delegation
delegating_agent = Agent(
    role="Team Manager",
    goal="Coordinate research activities",
    backstory="You're a team manager with excellent delegation skills.",
    allow_delegation=True
)</div>

                    <h3 class="text-xl font-semibold mt-6">Task Creation Patterns</h3>
                    <div class="code-block bg-black-800 text-white"># Basic Task
from crewai import Task

basic_task = Task(
    description="Research quantum computing advances",
    expected_output="Comprehensive research report",
    agent=researcher
)

# Task with Tools
task_with_tools = Task(
    description="Research quantum computing advances",
    expected_output="Comprehensive research report",
    agent=researcher,
    tools=[search_tool, web_scraper_tool]
)

# Task with Context (Dependency)
dependent_task = Task(
    description="Write an article based on research findings",
    expected_output="1500-word article",
    agent=writer,
    context=[research_task]  # This task depends on research_task
)

# Task with Structured Output
from pydantic import BaseModel
from typing import List

class ResearchReport(BaseModel):
    title: str
    key_findings: List[str]
    sources: List[str]

structured_task = Task(
    description="Research quantum computing advances",
    expected_output="Structured research report",
    agent=researcher,
    output_pydantic=ResearchReport
)

# Task with File Output
file_output_task = Task(
    description="Generate a research report",
    expected_output="Comprehensive markdown report",
    agent=researcher,
    output_file="output/research_report.md"
)

# Asynchronous Task
async_task = Task(
    description="Research quantum computing advances",
    expected_output="Research report",
    agent=researcher,
    async_execution=True
)

# Task with Human Input
human_review_task = Task(
    description="Create final research report",
    expected_output="Polished report",
    agent=editor,
    human_input=True
)</div>

                    <h3 class="text-xl font-semibold mt-6">Crew Creation Patterns</h3>
                    <div class="code-block bg-black-800 text-white"># Sequential Crew (Default)
from crewai import Crew

sequential_crew = Crew(
    agents=[researcher, writer, editor],
    tasks=[research_task, writing_task, editing_task],
    verbose=True
)

# Hierarchical Crew
hierarchical_crew = Crew(
    agents=[researcher, writer, editor],
    tasks=[research_task, writing_task, editing_task],
    process="hierarchical",
    manager_llm=openai_llm,  # Required for hierarchical process
    verbose=True
)

# Crew with Custom Manager
hierarchical_crew_custom_manager = Crew(
    agents=[researcher, writer, editor],
    tasks=[research_task, writing_task, editing_task],
    process="hierarchical",
    manager_agent=project_manager,  # Custom manager agent
    verbose=True
)

# Crew with Memory
crew_with_memory = Crew(
    agents=[researcher, writer],
    tasks=[research_task, writing_task],
    memory=True,
    verbose=True
)

# Crew with Full Output
crew_with_full_output = Crew(
    agents=[researcher, writer, editor],
    tasks=[research_task, writing_task, editing_task],
    full_output=True  # Return outputs from all tasks
)

# Crew with Callbacks
def task_complete_callback(task_output):
    print(f"Task completed: {task_output.description}")
    return task_output

crew_with_callbacks = Crew(
    agents=[researcher, writer],
    tasks=[research_task, writing_task],
    task_callback=task_complete_callback
)</div>

                    <h3 class="text-xl font-semibold mt-6">Execution Patterns</h3>
                    <div class="code-block bg-black-800 text-white"># Basic Kickoff
result = crew.kickoff()
print(result.raw)  # Raw text output

# Kickoff with Inputs
result = crew.kickoff(inputs={"topic": "Quantum Computing"})

# Kickoff for Multiple Inputs
inputs_array = [
    {"topic": "Quantum Computing"},
    {"topic": "Machine Learning"}
]
results = crew.kickoff_for_each(inputs=inputs_array)

# Asynchronous Kickoff
import asyncio

async def run_crew():
    result = await crew.kickoff_async(inputs={"topic": "Quantum Computing"})
    return result

result = asyncio.run(run_crew())

# Accessing Structured Output
if result.pydantic:
    print(f"Title: {result.pydantic.title}")
    print(f"Key findings: {result.pydantic.key_findings}")

# Accessing All Task Outputs (with full_output=True)
for task_output in result.tasks_output:
    print(f"Task: {task_output.description}")
    print(f"Output: {task_output.raw}")

# Checking Token Usage
print(f"Token usage: {result.token_usage}")</div>

                    <h3 class="text-xl font-semibold mt-6">Common Tool Patterns</h3>
                    <div class="code-block bg-black-800 text-white"># Search Tool
from crewai_tools import SerperDevTool

search_tool = SerperDevTool()

# Web Scraping
from crewai_tools import ScrapeWebsiteTool

scrape_tool = ScrapeWebsiteTool()

# Document Search Tools
from crewai_tools import PDFSearchTool, CSVSearchTool

pdf_tool = PDFSearchTool(pdf_path="data/research.pdf")
csv_tool = CSVSearchTool(csv_path="data/statistics.csv")

# Code Interpreter
from crewai_tools import CodeInterpreterTool

code_tool = CodeInterpreterTool()

# Custom Tool using Decorator
from crewai.tools import tool

@tool
def calculate_roi(investment: float, return_value: float) -> str:
    """
    Calculate Return on Investment (ROI)

    Args:
        investment: Initial investment amount
        return_value: Value returned from the investment

    Returns:
        ROI as a percentage
    """
    roi = (return_value - investment) / investment * 100
    return f"ROI: {roi:.2f}%"</div>

                    <h3 class="text-xl font-semibold mt-6">Troubleshooting Checklist</h3>
                    <div class="overflow-x-auto">
                        <table class="reference-table">
                            <thead>
                                <tr>
                                    <th>Issue</th>
                                    <th>Potential Cause</th>
                                    <th>Solution</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>Agent not using tools</td>
                                    <td>Tools not properly defined or not clearly needed in task</td>
                                    <td>Be more explicit in task description about using tools; check tool setup</td>
                                </tr>
                                <tr>
                                    <td>Tasks executed out of order</td>
                                    <td>Task dependencies not properly defined</td>
                                    <td>Ensure context is properly set for dependent tasks</td>
                                </tr>
                                <tr>
                                    <td>API key errors</td>
                                    <td>Missing or incorrect environment variables</td>
                                    <td>Check .env file and verify API keys are set correctly</td>
                                </tr>
                                <tr>
                                    <td>Poor agent performance</td>
                                    <td>Unclear role, goal, or backstory</td>
                                    <td>Make agent definitions more specific and detailed</td>
                                </tr>
                                <tr>
                                    <td>Timeout errors</td>
                                    <td>Tasks too complex or API rate limits</td>
                                    <td>Break into smaller tasks; implement max_rpm or retry logic</td>
                                </tr>
                                <tr>
                                    <td>Hierarchical process failing</td>
                                    <td>Missing manager_llm or poorly defined manager</td>
                                    <td>Ensure manager_llm is set or provide a well-defined manager_agent</td>
                                </tr>
                                <tr>
                                    <td>Tool execution errors</td>
                                    <td>Missing dependencies or incorrect usage</td>
                                    <td>Check tool documentation and required dependencies</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </section>

                <!-- Best Practices Section -->
                <section id="best-practices" class="section bg-white p-6 rounded-lg shadow">
                    <h2 class="text-2xl font-bold text-blue-800">8. Best Practices</h2>
                    <p class="mt-3">
                        These best practices will help you build more effective and efficient CrewAI applications.
                    </p>

                    <h3 class="text-xl font-semibold mt-6">Agent Design</h3>
                    <div class="card">
                        <h4 class="font-semibold text-blue-700"><i class="fas fa-user-tag mr-2"></i>Define Specialized Roles</h4>
                        <p>Create agents with distinct, non-overlapping roles for clearer responsibility distribution. Each agent should have a specific area of expertise.</p>
                        <div class="mt-2 text-sm bg-black-100 p-2 rounded">
                            <span class="font-semibold">Example:</span> Instead of having two general "researchers," create a "Data Analyst" focusing on statistics and a "Industry Expert" focusing on domain knowledge.
                        </div>
                    </div>

                    <div class="card mt-4">
                        <h4 class="font-semibold text-blue-700"><i class="fas fa-bullseye mr-2"></i>Craft Actionable Goals</h4>
                        <p>Create specific, measurable goals that guide agent behavior. Vague goals lead to unfocused actions.</p>
                        <div class="mt-2 text-sm bg-black-100 p-2 rounded">
                            <span class="font-semibold">Good:</span> "Identify the top 5 trends in renewable energy with supporting data points"<br>
                            <span class="font-semibold">Not as good:</span> "Research renewable energy trends"
                        </div>
                    </div>

                    <div class="card mt-4">
                        <h4 class="font-semibold text-blue-700"><i class="fas fa-book mr-2"></i>Develop Detailed Backstories</h4>
                        <p>Rich backstories provide context for decision-making and shape agent personality.</p>
                        <div class="mt-2 text-sm bg-black-100 p-2 rounded">
                            <span class="font-semibold">Good:</span> "You're a financial analyst with 15 years of experience in startup valuation. You've worked with VC firms and have helped assess over 200 startups. You're particularly skilled at identifying financial risks and market opportunities."<br>
                            <span class="font-semibold">Not as good:</span> "You're a financial expert who understands startups."
                        </div>
                    </div>

                    <h3 class="text-xl font-semibold mt-6">Task Design</h3>
                    <div class="card">
                        <h4 class="font-semibold text-blue-700"><i class="fas fa-tasks mr-2"></i>Create Granular Tasks</h4>
                        <p>Break complex processes into smaller, focused tasks for better management and performance.</p>
                        <div class="mt-2 text-sm bg-black-100 p-2 rounded">
                            <span class="font-semibold">Instead of:</span> One task for "Research and write a complete report on renewable energy"<br>
                            <span class="font-semibold">Consider:</span> Separate tasks for research, analysis, outline creation, drafting, and editing.
                        </div>
                    </div>

                    <div class="card mt-4">
                        <h4 class="font-semibold text-blue-700"><i class="fas fa-list-ul mr-2"></i>Provide Clear Instructions</h4>
                        <p>Include specific formats, requirements, and examples in task descriptions.</p>
                        <div class="mt-2 text-sm bg-black-100 p-2 rounded">
                            <span class="font-semibold">Good:</span> "Create a 5-section report with an executive summary, market overview, competitor analysis, opportunities, and recommendations. Each section should be 300-500 words and include specific examples."<br>
                            <span class="font-semibold">Not as good:</span> "Write a comprehensive report on the topic."
                        </div>
                    </div>

                    <div class="card mt-4">
                        <h4 class="font-semibold text-blue-700"><i class="fas fa-sitemap mr-2"></i>Design Logical Task Flows</h4>
                        <p>Create dependencies that mimic natural information flow and decision processes.</p>
                        <div class="mt-2 text-sm bg-black-100 p-2 rounded">
                            <span class="font-semibold">Example flow:</span> Market Research → Technical Feasibility → Financial Projections → Business Plan → Executive Summary
                        </div>
                    </div>

                    <h3 class="text-xl font-semibold mt-6">Crew Orchestration</h3>
                    <div class="card">
                        <h4 class="font-semibold text-blue-700"><i class="fas fa-project-diagram mr-2"></i>Start Simple, Then Expand</h4>
                        <p>Begin with 2-3 agents and a sequential process, then gradually add complexity.</p>
                        <div class="mt-2 text-sm bg-black-100 p-2 rounded">
                            <span class="font-semibold">Iterative approach:</span> Start with researcher + writer; once working well, add editor and refiner roles.
                        </div>
                    </div>

                    <div class="card mt-4">
                        <h4 class="font-semibold text-blue-700"><i class="fas fa-tools mr-2"></i>Equip Agents with Appropriate Tools</h4>
                        <p>Match tools to agent specializations and task requirements.</p>
                        <div class="mt-2 text-sm bg-black-100 p-2 rounded">
                            <span class="font-semibold">Example:</span> Equip research agents with search and web scraping tools; financial analysts with calculation tools; writers with content generation tools.
                        </div>
                    </div>

                    <div class="card mt-4">
                        <h4 class="font-semibold text-blue-700"><i class="fas fa-bug mr-2"></i>Implement Error Handling</h4>
                        <p>Use guardrails and validation to ensure quality outputs.</p>
                        <div class="mt-2 text-sm bg-black-100 p-2 rounded">
                            <span class="font-semibold">Example:</span> Add validation for research outputs to ensure they include proper citations; implement length checks for content; verify that reports include all required sections.
                        </div>
                    </div>

                    <h3 class="text-xl font-semibold mt-6">Performance Optimization</h3>
                    <div class="card">
                        <h4 class="font-semibold text-blue-700"><i class="fas fa-tachometer-alt mr-2"></i>Use Appropriate LLMs</h4>
                        <p>Match LLM capabilities to agent requirements and complexity.</p>
                        <div class="mt-2 text-sm bg-black-100 p-2 rounded">
                            <span class="font-semibold">Strategy:</span> Use more powerful models (like GPT-4) for complex reasoning tasks and manager roles; use faster models for simpler tasks.
                        </div>
                    </div>

                    <div class="card mt-4">
                        <h4 class="font-semibold text-blue-700"><i class="fas fa-database mr-2"></i>Implement Caching</h4>
                        <p>Enable caching to reduce redundant tool executions and improve performance.</p>
                        <div class="mt-2 text-sm bg-black-100 p-2 rounded">
                            <span class="font-semibold">Example:</span> Enable cache at both the crew and agent levels, especially for search operations and data retrieval that might be repeated.
                        </div>
                    </div>

                    <div class="card mt-4">
                        <h4 class="font-semibold text-blue-700"><i class="fas fa-code-branch mr-2"></i>Use Asynchronous Execution</h4>
                        <p>Leverage async capabilities for independent tasks to improve throughput.</p>
                        <div class="mt-2 text-sm bg-black-100 p-2 rounded">
                            <span class="font-semibold">Example:</span> Mark independent research tasks as async_execution=True and use kickoff_async() for parallel processing.
                        </div>
                    </div>

                    <div class="tip mt-6">
                        <p><strong>Key Takeaway:</strong> The most effective CrewAI applications are those that thoughtfully distribute specialized work across agents with clear goals, logical task dependencies, and appropriate tools. Start simple and iterate toward more complex systems as you gain experience.</p>
                    </div>
                </section>

                <!-- Resources Section -->
                <section id="resources" class="section bg-white p-6 rounded-lg shadow">
                    <h2 class="text-2xl font-bold text-blue-800">9. Additional Resources</h2>
                    <p class="mt-3">
                        Continue your learning journey with these valuable CrewAI resources.
                    </p>

                    <h3 class="text-xl font-semibold mt-6">Official Resources</h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-3">
                        <a href="https://docs.crewai.com" target="_blank" class="card hover:bg-blue-50 flex items-start transition-colors">
                            <div class="rounded-full bg-blue-100 p-3 mr-3">
                                <i class="fas fa-book text-blue-600"></i>
                            </div>
                            <div>
                                <h4 class="font-semibold text-blue-700">Official Documentation</h4>
                                <p class="text-sm">Comprehensive guides, API references, and examples</p>
                            </div>
                        </a>
                        <a href="https://github.com/crewAIInc/crewAI" target="_blank" class="card hover:bg-blue-50 flex items-start transition-colors">
                            <div class="rounded-full bg-blue-100 p-3 mr-3">
                                <i class="fab fa-github text-blue-600"></i>
                            </div>
                            <div>
                                <h4 class="font-semibold text-blue-700">GitHub Repository</h4>
                                <p class="text-sm">Source code, issues, and contributions</p>
                            </div>
                        </a>
                        <a href="https://github.com/crewAIInc/crewAI-examples" target="_blank" class="card hover:bg-blue-50 flex items-start transition-colors">
                            <div class="rounded-full bg-blue-100 p-3 mr-3">
                                <i class="fas fa-code text-blue-600"></i>
                            </div>
                            <div>
                                <h4 class="font-semibold text-blue-700">Example Applications</h4>
                                <p class="text-sm">Ready-to-use examples for various use cases</p>
                            </div>
                        </a>
                        <a href="https://github.com/crewAIInc/crewAI-tools" target="_blank" class="card hover:bg-blue-50 flex items-start transition-colors">
                            <div class="rounded-full bg-blue-100 p-3 mr-3">
                                <i class="fas fa-tools text-blue-600"></i>
                            </div>
                            <div>
                                <h4 class="font-semibold text-blue-700">CrewAI Tools</h4>
                                <p class="text-sm">Repository of tools to enhance agent capabilities</p>
                            </div>
                        </a>
                    </div>

                    <h3 class="text-xl font-semibold mt-6">Community Resources</h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-3">
                        <a href="https://www.youtube.com/watch?v=7GhWXODugWM" target="_blank" class="card hover:bg-blue-50 flex items-start transition-colors">
                            <div class="rounded-full bg-blue-100 p-3 mr-3">
                                <i class="fab fa-youtube text-blue-600"></i>
                            </div>
                            <div>
                                <h4 class="font-semibold text-blue-700">CrewAI RAG Deep Dive</h4>
                                <p class="text-sm">Detailed tutorial on implementing RAG with CrewAI</p>
                            </div>
                        </a>
                        <a href="https://medium.com/@sahin.samia/building-ai-agents-with-crewai-a-step-by-step-guide-172627e110c5" target="_blank" class="card hover:bg-blue-50 flex items-start transition-colors">
                            <div class="rounded-full bg-blue-100 p-3 mr-3">
                                <i class="fab fa-medium text-blue-600"></i>
                            </div>
                            <div>
                                <h4 class="font-semibold text-blue-700">Step-by-Step Guide</h4>
                                <p class="text-sm">Detailed Medium article on building AI agents with CrewAI</p>
                            </div>
                        </a>
                        <a href="https://www.reddit.com/r/crewai/" target="_blank" class="card hover:bg-blue-50 flex items-start transition-colors">
                            <div class="rounded-full bg-blue-100 p-3 mr-3">
                                <i class="fab fa-reddit text-blue-600"></i>
                            </div>
                            <div>
                                <h4 class="font-semibold text-blue-700">Reddit Community</h4>
                                <p class="text-sm">Discussion forum for CrewAI users and developers</p>
                            </div>
                        </a>
                        <a href="https://learn.deeplearning.ai/courses/practical-multi-ai-agents-and-advanced-use-cases-with-crewai/lesson/agfnp/introduction" target="_blank" class="card hover:bg-blue-50 flex items-start transition-colors">
                            <div class="rounded-full bg-blue-100 p-3 mr-3">
                                <i class="fas fa-graduation-cap text-blue-600"></i>
                            </div>
                            <div>
                                <h4 class="font-semibold text-blue-700">DeepLearning.AI Course</h4>
                                <p class="text-sm">Practical Multi AI Agents course with CrewAI</p>
                            </div>
                        </a>
                    </div>

                    <h3 class="text-xl font-semibold mt-6">Related Technologies</h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-3">
                        <a href="https://python.langchain.com/docs/integrations/tools" target="_blank" class="card hover:bg-blue-50 flex items-start transition-colors">
                            <div class="rounded-full bg-blue-100 p-3 mr-3">
                                <i class="fas fa-link text-blue-600"></i>
                            </div>
                            <div>
                                <h4 class="font-semibold text-blue-700">LangChain Tools</h4>
                                <p class="text-sm">Compatible tools that can be used with CrewAI</p>
                            </div>
                        </a>
                        <a href="https://github.com/microsoft/autogen" target="_blank" class="card hover:bg-blue-50 flex items-start transition-colors">
                            <div class="rounded-full bg-blue-100 p-3 mr-3">
                                <i class="fas fa-robot text-blue-600"></i>
                            </div>
                            <div>
                                <h4 class="font-semibold text-blue-700">AutoGen</h4>
                                <p class="text-sm">Another multi-agent framework for comparison</p>
                            </div>
                        </a>
                    </div>
                </section>
            </div>
        </div>
    </div>

    <footer class="bg-black-800 text-white p-6 mt-8">
        <div class="container mx-auto">
            <div class="text-center">
                <h3 class="text-xl font-bold mb-2">CrewAI Learning Platform & Cheatsheet</h3>
                <p class="mb-4">A comprehensive guide to building multi-agent systems with CrewAI</p>
                <p class="text-gray-400 text-sm">Created with ❤️ for the CrewAI community</p>
            </div>
        </div>
    </footer>

    <script>

        // Simple highlighting for TOC

        document.addEventListener('DOMContentLoaded', function() {

            const sections = document.querySelectorAll('section[id]');

            const tocLinks = document.querySelectorAll('.toc-link');



            function highlightTOC() {

                let scrollPosition = window.scrollY;



                sections.forEach(section => {

                    const sectionTop = section.offsetTop - 100;

                    const sectionHeight = section.offsetHeight;

                    const sectionId = section.getAttribute('id');



                    if (scrollPosition >= sectionTop && scrollPosition < sectionTop + sectionHeight) {

                        // Remove active class from all links

                        tocLinks.forEach(link => {

                            link.classList.remove('toc-active');

                        });



                        // Add active class to current section's link

                        const activeLink = document.querySelector(`.toc-link[href="#${sectionId}"]`);

                        if (activeLink) {

                            activeLink.classList.add('toc-active');

                        }

                    }

                });

            }



            window.addEventListener('scroll', highlightTOC);

            highlightTOC(); // Initialize on load



            // Smooth scrolling for TOC links

            tocLinks.forEach(link => {

                link.addEventListener('click', function(e) {

                    e.preventDefault();

                    const targetId = this.getAttribute('href');

                    const targetElement = document.querySelector(targetId);



                    window.scrollTo({

                        top: targetElement.offsetTop - 20,

                        behavior: 'smooth'

                    });

                });

            });

        });

    </script>
</body>
</html>