mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-07 22:52:58 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98a4ff8450 | ||
|
|
d6333aaf33 | ||
|
|
8005094267 | ||
|
|
08b21dabe3 | ||
|
|
8c70d840df | ||
|
|
d8e944c1d3 | ||
|
|
79b2b88f72 | ||
|
|
f5dfbd5670 | ||
|
|
aa6aa5933d | ||
|
|
ff3a4f2016 | ||
|
|
0d5444fc23 | ||
|
|
d7d5dab17b | ||
|
|
05678394e6 | ||
|
|
54cddc09b4 | ||
|
|
9cbab01785 | ||
|
|
de9d4bd3c6 | ||
|
|
aba2265e5e | ||
|
|
ebb9b24bff | ||
|
|
759ef2c655 | ||
|
|
cb4318f6e8 | ||
|
|
d9bb869d5e | ||
|
|
34b6aeb76b | ||
|
|
078b7801e1 | ||
|
|
a970e849b4 | ||
|
|
8e68f4e71c | ||
|
|
308758cdc2 | ||
|
|
f8fa61b082 | ||
|
|
955d236924 | ||
|
|
d9d63c3a13 | ||
|
|
5bee6eb470 | ||
|
|
7cb1676b7c | ||
|
|
e2e9c3f9ee | ||
|
|
cbe8beeca6 | ||
|
|
f7b66a52b7 | ||
|
|
6dbf194312 | ||
|
|
335e8d7e47 | ||
|
|
d65840e092 | ||
|
|
5a13571fdd | ||
|
|
e3b48c2526 | ||
|
|
8d32238b4c | ||
|
|
c17b1298bb | ||
|
|
ec6c150315 | ||
|
|
3d26cedd5d | ||
|
|
8c735a60b2 | ||
|
|
2f5f2f1c13 | ||
|
|
0253073c68 | ||
|
|
7f0e334e8c | ||
|
|
cacf1097ef | ||
|
|
09f01919d2 | ||
|
|
92397615f8 | ||
|
|
4b21943a53 | ||
|
|
af56a753bd | ||
|
|
15c2559a3c | ||
|
|
3215bdc0a6 | ||
|
|
0ff0d83744 | ||
|
|
8f956f91dd | ||
|
|
954f6ac33d | ||
|
|
264d11d8d9 | ||
|
|
88da2bdd7b | ||
|
|
b84e6c2460 | ||
|
|
0434b23ada | ||
|
|
a9951e0694 | ||
|
|
073062cd96 | ||
|
|
936b422876 | ||
|
|
99ab421ce2 | ||
|
|
c1f334905e | ||
|
|
6d3ba7cdf8 | ||
|
|
96616498d2 | ||
|
|
1cad345415 | ||
|
|
802e7e52f9 | ||
|
|
53704f234c | ||
|
|
b575994d91 | ||
|
|
7ed8596261 | ||
|
|
deef65c4bb | ||
|
|
d51327effd | ||
|
|
30ce8857e8 | ||
|
|
397874ccfc | ||
|
|
2016902e9a | ||
|
|
d2d19511da | ||
|
|
bc9579b497 | ||
|
|
3161389341 | ||
|
|
b01eb2b8fa | ||
|
|
e609fb7425 | ||
|
|
168ef98473 | ||
|
|
ce2c2926f9 | ||
|
|
0a569e2b46 | ||
|
|
054aea8f66 | ||
|
|
34f1293cfc | ||
|
|
7c1e32afc0 | ||
|
|
1125c835ec | ||
|
|
889d04a843 | ||
|
|
fba811c477 | ||
|
|
df687d86c3 | ||
|
|
afa37b0782 | ||
|
|
43a15e6049 | ||
|
|
8bf5a08246 | ||
|
|
aa81094ac3 | ||
|
|
c74fd7e925 | ||
|
|
249acf7965 | ||
|
|
ab68b2d296 | ||
|
|
abcc5b3b04 | ||
|
|
e584f56099 | ||
|
|
b6b01af066 | ||
|
|
9aae3eff86 | ||
|
|
f90582c66b | ||
|
|
67a8d65d8e | ||
|
|
d60c31a86d | ||
|
|
fcb7b2a0d0 | ||
|
|
81ad7db679 | ||
|
|
0482c3ebb0 | ||
|
|
3107458016 | ||
|
|
44c8ceebae | ||
|
|
20c0b02528 | ||
|
|
cfc886b591 | ||
|
|
77ac4b7a09 | ||
|
|
5897cedc45 | ||
|
|
a4d1079813 | ||
|
|
4eed985c4d | ||
|
|
0658491072 | ||
|
|
9f82368b4c | ||
|
|
c267cdda87 | ||
|
|
b88bb04090 | ||
|
|
709a35fbdc | ||
|
|
8b792424b6 | ||
|
|
ef2a8cd658 | ||
|
|
d41d2dcba2 | ||
|
|
3bc1786b49 | ||
|
|
2eec3e2359 | ||
|
|
6168401a69 | ||
|
|
473fda653d | ||
|
|
30f1a440b6 | ||
|
|
f991f37cfe | ||
|
|
a43b3ac72c | ||
|
|
06f82249e1 | ||
|
|
d3aa78241a | ||
|
|
dfb77c39f9 | ||
|
|
7e8f9b0574 | ||
|
|
19bcdcd000 | ||
|
|
8f5160f827 | ||
|
|
3574a4d2c0 | ||
|
|
b552843fa9 | ||
|
|
0461a133df | ||
|
|
b33857de33 | ||
|
|
433c643f6c | ||
|
|
214119a063 | ||
|
|
989a9f6fc5 | ||
|
|
cf276a5640 | ||
|
|
b5134ffb2f | ||
|
|
5664036712 | ||
|
|
6c2ca64cbe | ||
|
|
08c742287c | ||
|
|
4ee32b8eb2 | ||
|
|
35f07e5653 | ||
|
|
6481aec376 | ||
|
|
98c846ef78 | ||
|
|
6e4a9faaf8 | ||
|
|
05d62db355 | ||
|
|
375c8c9826 | ||
|
|
c6977c8221 | ||
|
|
d407c83cf3 | ||
|
|
214add68d9 | ||
|
|
6d2cb9676d | ||
|
|
c519cb1379 | ||
|
|
356dc4909a | ||
|
|
dc278ad07b | ||
|
|
5cc53eb4bb | ||
|
|
b72576d086 | ||
|
|
30314b1573 | ||
|
|
f721bd5e9a | ||
|
|
d00ea3e3c3 | ||
|
|
67dbd1007a | ||
|
|
cf2a5a135f | ||
|
|
bc23d3a104 | ||
|
|
bb4e1d8b9e | ||
|
|
69740baa7c | ||
|
|
5035978a29 | ||
|
|
4ddb043324 | ||
|
|
337014f4db | ||
|
|
35c371b25e | ||
|
|
bba75d9fdd | ||
|
|
bf8cd488da | ||
|
|
28905db46d | ||
|
|
3e7aa44dfa | ||
|
|
2f7a65ab92 | ||
|
|
e6e2379b02 | ||
|
|
f31f9a04aa | ||
|
|
5a8adf295e | ||
|
|
8dc243fd4f | ||
|
|
548b4afb88 | ||
|
|
ffa938b3df | ||
|
|
8a9beed264 | ||
|
|
daca5a1762 | ||
|
|
b183ac5cbd | ||
|
|
5f57e1d2f1 | ||
|
|
5114165944 | ||
|
|
389442ea04 | ||
|
|
6d7cc9c3ba | ||
|
|
690e4497cc | ||
|
|
041f5f0b08 | ||
|
|
bc0d9a6213 | ||
|
|
a4427fa135 | ||
|
|
51e8c65c8c | ||
|
|
285ed672c5 | ||
|
|
c03e51e337 | ||
|
|
f3ba05f6aa | ||
|
|
9cea3edcd6 | ||
|
|
02a3bd3597 | ||
|
|
128c77926d | ||
|
|
3aa1b825e4 | ||
|
|
b4ee30d837 | ||
|
|
825648aead | ||
|
|
1532c31e72 | ||
|
|
b313fefd86 | ||
|
|
435e1afb55 | ||
|
|
4cb3c0565a | ||
|
|
a7634b66dc | ||
|
|
3f0eaccbcb | ||
|
|
47713d933a | ||
|
|
c82bfccd1d | ||
|
|
ef7d1264e2 | ||
|
|
2799304270 | ||
|
|
4a85c135a6 | ||
|
|
cdb42a3f08 | ||
|
|
c8378118e7 | ||
|
|
0213764057 | ||
|
|
2220114809 | ||
|
|
9fe4dbc172 | ||
|
|
180503fcd5 | ||
|
|
0d8f936b19 | ||
|
|
8b53ebf5e3 | ||
|
|
504c5a9759 | ||
|
|
8fef42fc03 | ||
|
|
2f18cc1ea2 | ||
|
|
ff7969cdbf | ||
|
|
5fa84dc3eb | ||
|
|
4bf8b980ed | ||
|
|
53e0fd19ab | ||
|
|
0cb6307d3c | ||
|
|
adce94410b | ||
|
|
42aec561b1 | ||
|
|
acc805768d | ||
|
|
6d9fa167e3 | ||
|
|
9e178b70e6 | ||
|
|
ed406973cd | ||
|
|
f91918f4f6 | ||
|
|
ee21df9a6a | ||
|
|
c9159337fa | ||
|
|
2258685c32 | ||
|
|
7210788135 | ||
|
|
3f58e3b1ad | ||
|
|
561c32ddd5 | ||
|
|
79d934eec4 | ||
|
|
144c7edc4a | ||
|
|
4425e2b743 | ||
|
|
eb8dfc02cd | ||
|
|
27b6193b90 | ||
|
|
b0aa9dfe58 | ||
|
|
89d4f52327 | ||
|
|
da545f2e49 | ||
|
|
e794992d7b | ||
|
|
a958162704 | ||
|
|
3b47f7be7f | ||
|
|
0b8da8b4c4 | ||
|
|
092ea67732 | ||
|
|
5931ad00be | ||
|
|
b7676cf6c3 | ||
|
|
8ec4f5efa2 | ||
|
|
f459c192d6 | ||
|
|
18b85aada0 | ||
|
|
a3c77692fd | ||
|
|
4a06ee3626 | ||
|
|
776e83100e | ||
|
|
f718d89ba4 | ||
|
|
3469335d02 | ||
|
|
929a6e733d | ||
|
|
6caa825706 | ||
|
|
4baf6288ed | ||
|
|
65a23df7a2 | ||
|
|
ea0cb8b59a | ||
|
|
d0d2e60618 | ||
|
|
8eca3359cf | ||
|
|
41272ddd24 | ||
|
|
47d8e54fa5 | ||
|
|
0d42787a86 | ||
|
|
99a4b84e6a | ||
|
|
1b70e295b4 | ||
|
|
abc8d63b75 | ||
|
|
10e58e033a | ||
|
|
e36feed53e | ||
|
|
f01b3f4251 | ||
|
|
e2ca69327c | ||
|
|
cc8994f19c | ||
|
|
89277d14c4 | ||
|
|
9513173837 | ||
|
|
5b83af82db | ||
|
|
0539c337ab | ||
|
|
c6977cf541 | ||
|
|
b0e9eec33b | ||
|
|
2cb61ce529 | ||
|
|
4055c9c983 | ||
|
|
376b4d95f1 | ||
|
|
2ae47e4208 | ||
|
|
6b2814eb26 | ||
|
|
852765412a | ||
|
|
b4db6421f7 | ||
|
|
22ecf6963f | ||
|
|
5cea1f5702 | ||
|
|
36d7a2b489 | ||
|
|
2c9ae32e13 | ||
|
|
d2d7fab0e0 | ||
|
|
f4ef434610 | ||
|
|
d63b437eca | ||
|
|
04aac1c2d5 | ||
|
|
eca66f9213 | ||
|
|
f83f3eae0b | ||
|
|
68dd9fb5f1 | ||
|
|
e0531cedf7 | ||
|
|
197e98d3ff | ||
|
|
3b7fd3688c | ||
|
|
dd7bfa39f4 | ||
|
|
fca801c3f7 | ||
|
|
33c81861c0 | ||
|
|
b49b6d567f | ||
|
|
8c1677556c | ||
|
|
a656ea2bca | ||
|
|
02846b0efd | ||
|
|
8d463e6897 | ||
|
|
b47021d98f | ||
|
|
ab4561d7a4 | ||
|
|
81af51f3e7 | ||
|
|
550d9c30d4 | ||
|
|
39a8942054 | ||
|
|
6ecb6e4887 | ||
|
|
d64c1381ed | ||
|
|
8e6bc3845b | ||
|
|
d2b2ad525e | ||
|
|
60508ba410 | ||
|
|
a2951184d7 | ||
|
|
4e26bbecfb | ||
|
|
f77583c64f | ||
|
|
6071850401 | ||
|
|
6ce4363e92 | ||
|
|
3622838f9f | ||
|
|
60f0cb308a | ||
|
|
a3afd4f7fd | ||
|
|
7118b9a47b | ||
|
|
3fa0173bf8 | ||
|
|
b9ea6accf9 | ||
|
|
80d2491a59 | ||
|
|
52f23b87c9 | ||
|
|
70a3d2df34 | ||
|
|
d3c08660f5 | ||
|
|
4e09b7c878 | ||
|
|
6bc6ff79dd | ||
|
|
ab78189601 | ||
|
|
54c29a6ffe | ||
|
|
afb32705dc | ||
|
|
9f9a373c31 | ||
|
|
2c16131770 | ||
|
|
bc0d58104c | ||
|
|
a11990fa40 | ||
|
|
e1f6601137 | ||
|
|
05dc3b5223 | ||
|
|
c8fdab5885 | ||
|
|
8f1c18da70 | ||
|
|
739c25cbea | ||
|
|
bbbb77ba5c | ||
|
|
00b81080a3 | ||
|
|
2c7cbdf0c9 | ||
|
|
112a7248ca | ||
|
|
ce214edd99 | ||
|
|
ab8932be28 | ||
|
|
47c91ae624 | ||
|
|
626260f787 | ||
|
|
c0b8aba75b | ||
|
|
e3b0b3830e | ||
|
|
8c3e1f8569 | ||
|
|
ab01fe2965 | ||
|
|
e6472b5052 | ||
|
|
a178abe759 | ||
|
|
b139ea98ba | ||
|
|
589650029b | ||
|
|
97b25f5003 | ||
|
|
5d30ce9a1b | ||
|
|
5ad39b5f1b | ||
|
|
28c60d52f5 | ||
|
|
3a9e26670f | ||
|
|
209793bdb1 | ||
|
|
aa965cf719 | ||
|
|
4927f24d4a | ||
|
|
2a3240156d | ||
|
|
77e8ccb3c9 | ||
|
|
031c73c7d3 | ||
|
|
82b6f9c5ff | ||
|
|
22449a35b7 | ||
|
|
75bf3ac73b | ||
|
|
4d3e19462b | ||
|
|
efaff8845d | ||
|
|
a4e7a1bdbc | ||
|
|
fd346b410d | ||
|
|
9acff8f977 | ||
|
|
4bc3ad97a1 | ||
|
|
a91228b46e | ||
|
|
74403501ed | ||
|
|
c1703dd234 | ||
|
|
256ad050e4 | ||
|
|
4ca844e667 | ||
|
|
7e473dcb14 | ||
|
|
0188c6bf77 | ||
|
|
df304df3cf | ||
|
|
82cdda36d7 | ||
|
|
9d6c6d7ab2 | ||
|
|
e47c6b4278 | ||
|
|
aab077ce92 | ||
|
|
6d717d59b1 | ||
|
|
07cc581c04 | ||
|
|
283282d98b | ||
|
|
c231d625c3 | ||
|
|
d1b4ab0d95 | ||
|
|
c0d5eec2a7 | ||
|
|
94f7edaae4 | ||
|
|
6607b6279e | ||
|
|
d1cf53c543 | ||
|
|
4dcc72a02b | ||
|
|
d2a70c45ab | ||
|
|
a3cfaaabec | ||
|
|
4743ba20be | ||
|
|
81d4042578 | ||
|
|
9a6b156b6e | ||
|
|
fbbee806d1 | ||
|
|
2241ecbdde | ||
|
|
0501a85b9e | ||
|
|
c5c728e148 | ||
|
|
6d4c1d71fb | ||
|
|
31435c454f | ||
|
|
00e722aae1 | ||
|
|
76a65b3667 | ||
|
|
cd5459d4dc | ||
|
|
326390863f | ||
|
|
d1e6706427 | ||
|
|
7f0f8d5ed9 | ||
|
|
556d1298f1 | ||
|
|
48acfce433 | ||
|
|
1ddcafbaa4 | ||
|
|
eb2073fe77 | ||
|
|
732e4e6c75 | ||
|
|
7f01facb36 | ||
|
|
b2cc7ebfd9 | ||
|
|
3c51b6f644 | ||
|
|
44f02cdf43 | ||
|
|
55668c9510 | ||
|
|
28e95388f9 | ||
|
|
663150a0ee | ||
|
|
225ce7b9f2 | ||
|
|
b2cacb243f | ||
|
|
9e25572c84 | ||
|
|
801aedc00a | ||
|
|
f18103f66b | ||
|
|
a75745729b | ||
|
|
2bc61a1d55 | ||
|
|
a3877c34e5 | ||
|
|
ff1022bdb6 | ||
|
|
22e9904aef | ||
|
|
e5b7f7b740 | ||
|
|
3a137fb71e | ||
|
|
8e09f5e4b4 | ||
|
|
82e6673488 | ||
|
|
dd9b24597a | ||
|
|
dbd6062edf | ||
|
|
7fc615ff70 | ||
|
|
fabac466f9 | ||
|
|
8d98f27f9c | ||
|
|
cf0af4999d | ||
|
|
f6ecd3b4db | ||
|
|
a348d186c3 | ||
|
|
30c0f2458f | ||
|
|
668d61344f | ||
|
|
e8e9625f22 | ||
|
|
cc721ba0db | ||
|
|
07a30ab33d | ||
|
|
92978fdb1c | ||
|
|
15a307dd4e | ||
|
|
053ad043b8 | ||
|
|
6e664995e8 | ||
|
|
ccb1bccf0f | ||
|
|
94c8fc21e6 | ||
|
|
48575b4ee0 | ||
|
|
2ce7136d0c | ||
|
|
3bea2ffb10 | ||
|
|
fcbd915a0e | ||
|
|
ae7eb29684 | ||
|
|
c5ec1ffea0 | ||
|
|
aad5f286e2 | ||
|
|
1aa20de337 | ||
|
|
3bc185d15d | ||
|
|
6b8a7110f2 | ||
|
|
5ab0f245c5 | ||
|
|
5baa3f9b96 | ||
|
|
28c6d026f7 | ||
|
|
802716e5ec | ||
|
|
9eaa2731da | ||
|
|
0d3e1632a3 | ||
|
|
da14b1d8e9 | ||
|
|
c0679f4528 | ||
|
|
930555d921 | ||
|
|
859fb6a263 | ||
|
|
f154dba804 | ||
|
|
fb2a16126f | ||
|
|
77ab361d64 | ||
|
|
a276a610a0 | ||
|
|
ddb547f6a5 | ||
|
|
24437b40d9 | ||
|
|
582049f759 | ||
|
|
e8f4eff173 | ||
|
|
e1b93000be | ||
|
|
464cc128db | ||
|
|
f44bb7fa39 | ||
|
|
5b70f4b34d | ||
|
|
5514f17346 | ||
|
|
318ececfb4 | ||
|
|
83afc0891f | ||
|
|
8e7323c484 | ||
|
|
8dd6494a59 | ||
|
|
857238a82a | ||
|
|
658a2397fc | ||
|
|
1ab09fa259 | ||
|
|
f7f4a6c0bf | ||
|
|
a743f4b68c | ||
|
|
77b7c3b1ce | ||
|
|
48c65a742c | ||
|
|
35295ad167 | ||
|
|
1a6078d7eb | ||
|
|
fbd4c53796 | ||
|
|
55e70d521e | ||
|
|
d4023c0484 | ||
|
|
d88200e258 | ||
|
|
beac0b47a2 | ||
|
|
6d6c44e7ca | ||
|
|
1cd838f691 | ||
|
|
319944e012 | ||
|
|
b53162aa9e | ||
|
|
7d42e31e0a | ||
|
|
9c96a838a8 | ||
|
|
52c249fde0 | ||
|
|
7607df753f | ||
|
|
8fa181bc55 | ||
|
|
ccbf0ebebb | ||
|
|
d3f0c217ca | ||
|
|
6995a446e1 | ||
|
|
72c70ce050 | ||
|
|
6a13d2b971 | ||
|
|
fdc747a9c9 | ||
|
|
f381b93ae9 | ||
|
|
9c44945123 | ||
|
|
a19748902d | ||
|
|
fa1061a7aa | ||
|
|
775d97671f | ||
|
|
6c4f4d981d | ||
|
|
72395efd32 | ||
|
|
efa29de346 | ||
|
|
75462584b3 | ||
|
|
d352adbdac | ||
|
|
68664fdd55 | ||
|
|
bcda52cc44 | ||
|
|
4888dfb993 | ||
|
|
c5a3fc89cc | ||
|
|
ca33559d4c | ||
|
|
b02449dfdb | ||
|
|
c4c0c1c146 | ||
|
|
aa2d7e4c31 | ||
|
|
b339c5b3aa | ||
|
|
e535f98f4e | ||
|
|
bc349ad09f | ||
|
|
5b8da1180e | ||
|
|
8f6d8f0a48 | ||
|
|
3730b4d094 | ||
|
|
7f3810ed98 | ||
|
|
c84a59ab4d | ||
|
|
c6a6bfa827 | ||
|
|
a604cd9584 | ||
|
|
cb043da19c | ||
|
|
7b41444aad | ||
|
|
7c8b77063f | ||
|
|
59eb8d6356 | ||
|
|
89bddc31c6 | ||
|
|
e6e908298b | ||
|
|
2b3509c1d1 | ||
|
|
6e8029055a | ||
|
|
d2c9e8825a | ||
|
|
cd9816e218 | ||
|
|
d400149075 | ||
|
|
73b08e6b76 | ||
|
|
19c3a1f6a7 | ||
|
|
71a7968318 | ||
|
|
1b258229c1 | ||
|
|
d0e09f51f3 | ||
|
|
5adc862ead | ||
|
|
856db54334 | ||
|
|
f94e5bb3d6 | ||
|
|
1cece603ec | ||
|
|
9e2bbb9bbb | ||
|
|
35b4cff7f7 | ||
|
|
a094d1ff30 | ||
|
|
000bdf3418 | ||
|
|
826ff56fc5 | ||
|
|
4bd0195d5d | ||
|
|
812abec2eb | ||
|
|
e58f6deb4b | ||
|
|
f23680c121 | ||
|
|
e569400260 | ||
|
|
75c4d8432c | ||
|
|
6249d14d3f | ||
|
|
32537a227e | ||
|
|
f83ffcdafe | ||
|
|
519aebd271 | ||
|
|
fb4ecf1893 | ||
|
|
5a4cbf8aeb | ||
|
|
885a73f697 | ||
|
|
9336f15e67 | ||
|
|
6d55cfa87e | ||
|
|
0b431b1fe1 | ||
|
|
e252f86ac9 | ||
|
|
ed395de6f3 | ||
|
|
633469d12e | ||
|
|
c5c57dff26 | ||
|
|
573b9efcc1 | ||
|
|
dc4e51ac81 | ||
|
|
08e211c693 | ||
|
|
abd8021925 | ||
|
|
8a6c4eec7f | ||
|
|
4e77a6a019 | ||
|
|
41e33c09e0 | ||
|
|
96f00e2172 | ||
|
|
e858cebed9 | ||
|
|
cca79bd9fc | ||
|
|
4ffbc1b52a | ||
|
|
b948151a14 | ||
|
|
11eee70d9a | ||
|
|
da6a2c1c04 | ||
|
|
731268df5c | ||
|
|
d60021cb40 | ||
|
|
75894f26c1 | ||
|
|
c53e09480a | ||
|
|
2ef506fa8a | ||
|
|
7ce783e59b | ||
|
|
95ffd0c53f | ||
|
|
e1c90bf569 | ||
|
|
5fbd8aa783 | ||
|
|
381c86de79 | ||
|
|
35250e429e | ||
|
|
3027937057 | ||
|
|
d79443868f | ||
|
|
6705e753e8 | ||
|
|
b4d1532512 | ||
|
|
4b5d3b2eda | ||
|
|
a1d4f3ee43 | ||
|
|
b5e930ff2e | ||
|
|
1a6a14f8f2 | ||
|
|
ca69de4c6a | ||
|
|
9b3d36e6d7 | ||
|
|
a9359a0785 | ||
|
|
4cb016c3ca | ||
|
|
d2e4776884 | ||
|
|
193b82aeba | ||
|
|
029de283c4 | ||
|
|
26376a77af | ||
|
|
7cb580bb12 | ||
|
|
06b458cc54 | ||
|
|
e29c2fbe90 | ||
|
|
76032be618 | ||
|
|
80f5ba940b | ||
|
|
65791781e2 | ||
|
|
ee66154b73 | ||
|
|
0dc51060d8 | ||
|
|
2daae1f464 | ||
|
|
81bcda0440 | ||
|
|
e269cc7bf2 | ||
|
|
66e5dfcb41 | ||
|
|
ae3e69a286 | ||
|
|
40ea6fe1aa | ||
|
|
e30a7564be | ||
|
|
fbd0a736f0 | ||
|
|
eea9f757af | ||
|
|
02a8f075a6 | ||
|
|
57c39653d6 | ||
|
|
2f21d0f907 | ||
|
|
e0caaf8421 | ||
|
|
4bc35c3b6e | ||
|
|
4fd9b863a6 | ||
|
|
fc02392ddb | ||
|
|
4564639f18 | ||
|
|
16598104ab | ||
|
|
b5d13a2b7f | ||
|
|
4622bcda43 | ||
|
|
31bae3a231 | ||
|
|
466bcfedd7 | ||
|
|
c24bf80314 | ||
|
|
c36b3aee6e | ||
|
|
08512ba6d3 | ||
|
|
63ebfc0b54 | ||
|
|
b29269071d | ||
|
|
b6a86bf348 | ||
|
|
02ba71be3d | ||
|
|
e60f1c1aa1 | ||
|
|
450f237805 | ||
|
|
66e53fc82e | ||
|
|
7e6ee5f9f2 | ||
|
|
b669b9815d | ||
|
|
6d89cd603e | ||
|
|
6e955b5941 | ||
|
|
87a67b5f5d | ||
|
|
baec9cd0a4 | ||
|
|
e144dc497d | ||
|
|
8a77ab0ab5 | ||
|
|
0034b5c964 | ||
|
|
543c627374 | ||
|
|
93154adf9e | ||
|
|
3ab2462d96 | ||
|
|
aecf65a130 | ||
|
|
0a453d30a2 | ||
|
|
354a2c717b | ||
|
|
62514fbef4 | ||
|
|
f3c77a2e8b | ||
|
|
50dde4fa02 | ||
|
|
bbc4530329 | ||
|
|
aab975bec7 | ||
|
|
50c50fa567 | ||
|
|
68f280634a | ||
|
|
346488fbec | ||
|
|
57b5a1fd8d | ||
|
|
d75a5bb728 | ||
|
|
519ecc025a | ||
|
|
8290b95132 | ||
|
|
3d95e1ff0e | ||
|
|
74405d1bbe | ||
|
|
d307c3857c | ||
|
|
fbe5dddaae | ||
|
|
7e4108918d | ||
|
|
da7e38100e | ||
|
|
848459b816 | ||
|
|
cd63845398 | ||
|
|
7827427dc0 | ||
|
|
0e378d0754 | ||
|
|
206022eb9c | ||
|
|
901ba8074d | ||
|
|
953ee6e7bd | ||
|
|
181d7e1ede | ||
|
|
4039878422 | ||
|
|
461eba18d5 | ||
|
|
331a1de610 | ||
|
|
91632eb5e4 | ||
|
|
ad46225483 | ||
|
|
9af6758eb6 | ||
|
|
aac67a6572 | ||
|
|
2ceff9bfae | ||
|
|
3b7af02bea | ||
|
|
1ee7cfa2ef | ||
|
|
b01bd41574 | ||
|
|
6570e445b8 | ||
|
|
b421bcf925 | ||
|
|
41d0998b76 | ||
|
|
393e0ee33d | ||
|
|
0dce4de4a4 | ||
|
|
7fe4b48c6e | ||
|
|
5286912f34 | ||
|
|
d6cb1c0165 | ||
|
|
08ed3f94dc | ||
|
|
d3bfbc4b92 | ||
|
|
af7081d294 | ||
|
|
3b2f26699e | ||
|
|
7aa61b9155 | ||
|
|
7e37c940d4 | ||
|
|
2199a57dfe | ||
|
|
d49f046322 | ||
|
|
c16c2e38af | ||
|
|
b5df9f323c | ||
|
|
6e4abeef52 | ||
|
|
5656570172 | ||
|
|
c08c7cfedf | ||
|
|
fbbe80fd4d | ||
|
|
cabddd9a22 | ||
|
|
20b838f36a | ||
|
|
cf149a3c2d | ||
|
|
30f6f5706c | ||
|
|
0423c9c4af | ||
|
|
be82abfac3 | ||
|
|
4af6228f89 | ||
|
|
33eaf34ffb | ||
|
|
e2512b38c0 | ||
|
|
b02cda252d | ||
|
|
2a4b369e15 | ||
|
|
c0a9e55f6a | ||
|
|
7c4b28885d | ||
|
|
b0ec8b9a22 | ||
|
|
1b5cf2baea | ||
|
|
b1cc2c31ce | ||
|
|
2a40c57033 | ||
|
|
350d6e6488 | ||
|
|
20a49ffd70 | ||
|
|
4bf9916c5f | ||
|
|
9764483f36 | ||
|
|
ff405be834 | ||
|
|
6d384a96ca | ||
|
|
6770996c8b | ||
|
|
93c7731ccb | ||
|
|
2057c68a20 | ||
|
|
1ca928a2e4 | ||
|
|
66ea9d7148 | ||
|
|
74a71807a6 | ||
|
|
9e92e85a72 | ||
|
|
6d827a45c8 | ||
|
|
aabaaa6318 | ||
|
|
f518bd301a | ||
|
|
834f710cf6 | ||
|
|
ede71a7fbe | ||
|
|
7c751c88a3 | ||
|
|
17f3aab1e1 | ||
|
|
028fa8158d | ||
|
|
c62685adc5 | ||
|
|
60d6178310 | ||
|
|
b198154b71 | ||
|
|
205de2ba0b | ||
|
|
ee668b2711 | ||
|
|
a5bbb65017 | ||
|
|
6296755ebb | ||
|
|
4b6c847260 | ||
|
|
2fc459fe05 | ||
|
|
1c3c2941cc | ||
|
|
6e38a88cd3 | ||
|
|
f0f22bb13d | ||
|
|
a8fa70c455 | ||
|
|
1b4b4a10b5 | ||
|
|
1efdaac18f | ||
|
|
1b2182968f | ||
|
|
5e5a10589e | ||
|
|
6c5e42762f | ||
|
|
afb7e47080 | ||
|
|
e674a2ae84 | ||
|
|
d471d9754a | ||
|
|
9d25b1ed3d | ||
|
|
d0d04bc17e | ||
|
|
1f4e2b1c5a | ||
|
|
88d4241121 | ||
|
|
9e081e9413 | ||
|
|
bc0449b8de | ||
|
|
c262942ba7 | ||
|
|
40e5c13f47 | ||
|
|
5eea991a60 | ||
|
|
209c2a42ae | ||
|
|
efb927137f | ||
|
|
162223162f | ||
|
|
75c856b948 | ||
|
|
85fefac429 | ||
|
|
35b9d46bdf | ||
|
|
5bd3e45be4 | ||
|
|
4c62731e81 | ||
|
|
544672edea | ||
|
|
72dcc91b3a | ||
|
|
75e728f7d7 | ||
|
|
7ddbf98794 | ||
|
|
0213dea12b | ||
|
|
841a7b52c4 | ||
|
|
99506e80cf | ||
|
|
c0d495fd48 | ||
|
|
0e51ed0d6c | ||
|
|
32dce14f96 | ||
|
|
27aaac80c6 | ||
|
|
5a0a3983e4 | ||
|
|
400a4c934e | ||
|
|
e88b0fd47b | ||
|
|
e6c1c0679f | ||
|
|
108aee0a54 | ||
|
|
cb017aad70 | ||
|
|
ea29d3181b | ||
|
|
7f0f265671 | ||
|
|
bc1c508419 | ||
|
|
bd108ba3e7 | ||
|
|
ac5f2649df | ||
|
|
1b64762d54 | ||
|
|
df402bcfdb | ||
|
|
061c8d58b4 | ||
|
|
117c02cf30 | ||
|
|
82c9ff80a7 | ||
|
|
f44b15d73b | ||
|
|
f2c89c2012 | ||
|
|
fd2569e642 | ||
|
|
58efb4b4cd | ||
|
|
35df78874d | ||
|
|
4abe80a563 | ||
|
|
95c15f52fc | ||
|
|
0e2a753cc3 | ||
|
|
660260c6e6 | ||
|
|
f49b5c368c | ||
|
|
39f0c40dcc | ||
|
|
27b10ff3ea | ||
|
|
f63f247bfe | ||
|
|
f3f5f63b22 | ||
|
|
ccf9470f41 | ||
|
|
75cf937581 | ||
|
|
d228a742b7 | ||
|
|
1d7e03b03e | ||
|
|
290570de88 | ||
|
|
542ea8c10d | ||
|
|
843f70b599 | ||
|
|
dee707299d | ||
|
|
7f6e300a9e | ||
|
|
88e9de2914 | ||
|
|
f17daec68b | ||
|
|
f4d54d76e8 | ||
|
|
23e2951724 | ||
|
|
1916b1a108 | ||
|
|
5b99ca8357 | ||
|
|
09ef400c15 | ||
|
|
d5c381890f | ||
|
|
639e53ea9b | ||
|
|
0954fb4d3d | ||
|
|
f5c35f31e9 | ||
|
|
4f31ec9b63 | ||
|
|
abee86337d | ||
|
|
e6cf4ebfcd | ||
|
|
68fb0aaaca | ||
|
|
4c9009c3f5 | ||
|
|
ac21e5d595 | ||
|
|
58b12b9f24 | ||
|
|
09dcf9c114 | ||
|
|
e25e0a895f | ||
|
|
855ec4c10a | ||
|
|
2b672f4d40 | ||
|
|
fe24d6bbea | ||
|
|
f402ef642b | ||
|
|
7ca9db4d1c | ||
|
|
322f972b5d | ||
|
|
8c50464db0 | ||
|
|
7828697eea | ||
|
|
4e89a5f6db | ||
|
|
8692a04551 | ||
|
|
da51c0ae63 | ||
|
|
77b2db24cc | ||
|
|
9569d1fefa | ||
|
|
84201195f7 | ||
|
|
850b7bfd7b | ||
|
|
77532114ec | ||
|
|
2882af376e | ||
|
|
19482e9163 | ||
|
|
0741b523b8 | ||
|
|
d63d564649 | ||
|
|
88ae3a26fb | ||
|
|
74ef96b9f6 | ||
|
|
12270a56d7 | ||
|
|
c79eedc8ec | ||
|
|
98874da689 | ||
|
|
6f019de05c | ||
|
|
a03d288e01 | ||
|
|
03c23021ab | ||
|
|
0178ec807e | ||
|
|
922362bd4c | ||
|
|
2e8b9cbf29 | ||
|
|
b79197b3a6 | ||
|
|
c056c3b65d | ||
|
|
965df5296f | ||
|
|
a8810cf4de | ||
|
|
4e50fab7f8 | ||
|
|
041feb6ec9 | ||
|
|
1fafaf8758 | ||
|
|
a056015b4b | ||
|
|
80e27a7cb7 | ||
|
|
ac59fcf65e | ||
|
|
a55db3f2c1 | ||
|
|
feafe6185d | ||
|
|
e052f4ab97 | ||
|
|
a8b94c8c8e | ||
|
|
d5270d5f13 | ||
|
|
9462b2409e | ||
|
|
5da1ba7387 | ||
|
|
7567145042 | ||
|
|
ca83ea5548 | ||
|
|
84e880ccdb | ||
|
|
d20247f628 | ||
|
|
9794047182 | ||
|
|
7292182a16 | ||
|
|
94f2f92577 | ||
|
|
f6ae1d2c5f | ||
|
|
cfe948e7ef | ||
|
|
3e18a5c591 | ||
|
|
498e6a4dbf | ||
|
|
5ff64d2c10 | ||
|
|
af5556a235 | ||
|
|
2d27264bab | ||
|
|
ed443583b2 | ||
|
|
c0c6eed552 | ||
|
|
54da62213a | ||
|
|
9efed5b4c7 | ||
|
|
bd2774d44c | ||
|
|
89bbc960dd | ||
|
|
8214b8ac04 | ||
|
|
9d01b277a5 | ||
|
|
f1cb5df3aa | ||
|
|
ab7d5cc5cc | ||
|
|
8b03c399f6 | ||
|
|
8ca1104850 | ||
|
|
0c8efc283e | ||
|
|
c560957a38 | ||
|
|
5c73595f22 | ||
|
|
a88ea82bf0 | ||
|
|
9e35d6e46b | ||
|
|
4cc7ee7cfb | ||
|
|
1f260f419f | ||
|
|
ef0e3529e4 | ||
|
|
eafc33976c | ||
|
|
dd6e1e1309 | ||
|
|
952e59e07a | ||
|
|
730ee778dc | ||
|
|
3cd664bf7b | ||
|
|
25de69d3fa | ||
|
|
894a95cfc2 | ||
|
|
6f6979e616 | ||
|
|
e3b9ca6091 | ||
|
|
370a51dc86 | ||
|
|
72e25f1ca2 | ||
|
|
9757e3dea7 | ||
|
|
3f1437e216 | ||
|
|
9f682a5a36 | ||
|
|
53acd2ae4b | ||
|
|
afadcbe687 | ||
|
|
a95fdede7c | ||
|
|
33ef1cdf48 | ||
|
|
5f38d7f9f4 | ||
|
|
be57dd2e73 | ||
|
|
bc6373036b | ||
|
|
ed41906af7 | ||
|
|
e456990a91 | ||
|
|
c5647bec54 | ||
|
|
1e45cc0ce1 | ||
|
|
6a1009462a | ||
|
|
6425758a25 | ||
|
|
1960cf9401 | ||
|
|
7f399f4870 | ||
|
|
81c35a35ca | ||
|
|
d0cf8e8b20 | ||
|
|
9eee37ad61 | ||
|
|
90cb5c57db | ||
|
|
4137d7dd45 | ||
|
|
5804bb7115 | ||
|
|
f641110bd1 | ||
|
|
de02eb7054 | ||
|
|
d579412eed | ||
|
|
22904cf41d | ||
|
|
c542d77b45 | ||
|
|
dce8becb5d | ||
|
|
9f7993ac40 | ||
|
|
2ce177890f | ||
|
|
11909566e9 | ||
|
|
57b4b10ddf | ||
|
|
7bafdd7a4a | ||
|
|
911e991f84 | ||
|
|
8164dfd1cf | ||
|
|
461bac900d | ||
|
|
a6b964d185 | ||
|
|
67e02cd88a | ||
|
|
4f7b6ed9f8 | ||
|
|
f157196759 | ||
|
|
c9d31385ec | ||
|
|
92fae803e8 | ||
|
|
4d867a9ff1 | ||
|
|
1fe43d9c9e | ||
|
|
acdcabcba7 | ||
|
|
5f8c87f2cb | ||
|
|
7907cd0913 | ||
|
|
298a5b2b65 | ||
|
|
7d6bd0ffeb | ||
|
|
19d4999021 | ||
|
|
8a309dd4b2 | ||
|
|
54805722cd | ||
|
|
41b1d9f885 | ||
|
|
9de8d57a1c | ||
|
|
58da95e139 | ||
|
|
1b52f4ce5f | ||
|
|
ec3a8d1863 | ||
|
|
41157e1f31 | ||
|
|
31078c38a0 | ||
|
|
a48a0aca22 | ||
|
|
bf39bf7e8b | ||
|
|
e9e1086afe | ||
|
|
0554796b45 | ||
|
|
7e2f17e047 | ||
|
|
04457f5bc6 | ||
|
|
250c56bbaa | ||
|
|
a01f55cdd2 | ||
|
|
f4df72dfc4 | ||
|
|
291c0b6b35 | ||
|
|
d7ad0dfaf4 | ||
|
|
3435b14a60 | ||
|
|
26c89de3b7 | ||
|
|
467e07fb8b | ||
|
|
1f64210663 | ||
|
|
8e87f2767f | ||
|
|
b74dbcd772 | ||
|
|
2ca306d6c9 | ||
|
|
0ae294f528 | ||
|
|
d7b371fb3f | ||
|
|
557f680b04 | ||
|
|
80ceb59767 | ||
|
|
e2fc2752e0 | ||
|
|
f6ca39469f | ||
|
|
bd061bf555 | ||
|
|
c3f668ebef | ||
|
|
1491ebf00a | ||
|
|
59eec99ae4 | ||
|
|
13d90399e5 | ||
|
|
e2a707509e | ||
|
|
a432135e75 | ||
|
|
17e620d9e0 | ||
|
|
17ceaad435 | ||
|
|
fe3ba3a916 | ||
|
|
1b9c9b78c9 | ||
|
|
1051f3a705 | ||
|
|
982473ce08 | ||
|
|
09de1f1405 | ||
|
|
ee21add0ef | ||
|
|
dcc2f899e7 | ||
|
|
362d6e62be | ||
|
|
d2a12c5fc6 | ||
|
|
993c342209 | ||
|
|
218370fef8 | ||
|
|
117969e8f6 | ||
|
|
aa3282cabd | ||
|
|
914532028d | ||
|
|
83d808ddc1 | ||
|
|
3cf922f36c | ||
|
|
b5956e0d39 | ||
|
|
07952d1b61 | ||
|
|
9eedd55b19 | ||
|
|
3b31afb270 | ||
|
|
c77f3c7363 | ||
|
|
c808ce29e4 | ||
|
|
ca70d34ffe | ||
|
|
96563ffb04 | ||
|
|
d7a89a5b5d | ||
|
|
7d0afb062e | ||
|
|
3ede63d3d9 | ||
|
|
db58770b46 | ||
|
|
9066668121 | ||
|
|
8e5b6a9d38 | ||
|
|
b16086c17d | ||
|
|
f50a2448df | ||
|
|
b1ff7a9500 | ||
|
|
c4829d45a4 | ||
|
|
f4479fa1f4 | ||
|
|
f008aa1c3b | ||
|
|
3abb084209 | ||
|
|
617efcc96d | ||
|
|
41bec67b51 | ||
|
|
91361eee17 | ||
|
|
aa1356629b | ||
|
|
ac86a8dd76 | ||
|
|
ab679e040e | ||
|
|
c2fded7a89 | ||
|
|
1a306988cf | ||
|
|
f4cb62a288 | ||
|
|
dde6ec4a6a | ||
|
|
c8b2414f5b |
No files matched your search
@@ -0,0 +1,34 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: '[BUG] '
|
||||
labels: bug
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## Environment
|
||||
- Provider (select one):
|
||||
- [ ] Anthropic
|
||||
- [ ] OpenAI
|
||||
- [ ] Google Vertex AI
|
||||
- [ ] AWS Bedrock
|
||||
- [ ] Other: <!-- specify -->
|
||||
- PraisonAI version: <!-- if known -->
|
||||
- Operating System: <!-- e.g. macOS 14.3, Windows 11, Ubuntu 22.04 -->
|
||||
|
||||
## Full Code
|
||||
<!-- Full code that reproduces the bug -->
|
||||
|
||||
## Steps to Reproduce
|
||||
1. <!-- First step -->
|
||||
2. <!-- Second step -->
|
||||
3. <!-- And so on... -->
|
||||
|
||||
## Expected Behavior
|
||||
<!-- What you expected to happen -->
|
||||
|
||||
## Actual Behavior
|
||||
<!-- What actually happened -->
|
||||
|
||||
## Additional Context
|
||||
<!-- Add any other context about the problem here, such as screenshots, logs, etc. -->
|
||||
@@ -1,9 +0,0 @@
|
||||
FROM node:20-alpine
|
||||
|
||||
RUN npm install -g @anthropic-ai/claude-code
|
||||
|
||||
WORKDIR /app
|
||||
COPY entrypoint.sh .
|
||||
RUN chmod +x entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
@@ -1,20 +1,256 @@
|
||||
name: "Claude Code Action"
|
||||
description: "Custom Claude Code runner for PraisonAI"
|
||||
description: "Run Claude Code in GitHub Actions workflows"
|
||||
|
||||
inputs:
|
||||
anthropic_api_key:
|
||||
required: true
|
||||
description: "Anthropic API key"
|
||||
required: false
|
||||
github_token:
|
||||
required: true
|
||||
description: "GitHub token for repo access"
|
||||
description: "GitHub token for Claude to operate with"
|
||||
required: false
|
||||
default: ${{ github.token }}
|
||||
trigger_phrase:
|
||||
description: "The trigger phrase to look for in comments, issue/PR bodies, and issue titles"
|
||||
required: false
|
||||
default: "@claude"
|
||||
assignee_trigger:
|
||||
description: "The assignee username that triggers the action (e.g. @claude). Only used for issue assignment"
|
||||
required: false
|
||||
max_turns:
|
||||
description: "Maximum number of conversation turns Claude can take"
|
||||
required: false
|
||||
timeout_minutes:
|
||||
description: "Timeout in minutes for execution"
|
||||
required: false
|
||||
default: "30"
|
||||
model:
|
||||
description: "Model to use (provider-specific format required for Bedrock/Vertex)"
|
||||
required: false
|
||||
use_bedrock:
|
||||
description: "Use Amazon Bedrock with OIDC authentication instead of direct Anthropic API"
|
||||
required: false
|
||||
default: "false"
|
||||
use_vertex:
|
||||
description: "Use Google Vertex AI with OIDC authentication instead of direct Anthropic API"
|
||||
required: false
|
||||
default: "false"
|
||||
allowed_tools:
|
||||
description: "Additional tools for Claude to use (the base GitHub tools will always be included)"
|
||||
required: false
|
||||
default: ""
|
||||
disallowed_tools:
|
||||
description: "Tools that Claude should never use"
|
||||
required: false
|
||||
default: ""
|
||||
custom_instructions:
|
||||
description: "Additional custom instructions to include in the prompt for Claude"
|
||||
required: false
|
||||
default: ""
|
||||
mcp_config:
|
||||
description: "Additional MCP configuration (JSON string) that merges with the built-in GitHub MCP servers"
|
||||
required: false
|
||||
default: ""
|
||||
claude_env:
|
||||
description: "Custom environment variables to pass to Claude Code execution (YAML format)"
|
||||
required: false
|
||||
default: ""
|
||||
direct_prompt:
|
||||
description: "Direct prompt for Claude to execute automatically without needing a trigger (for automated workflows)"
|
||||
required: false
|
||||
|
||||
runs:
|
||||
using: "docker"
|
||||
image: "ghcr.io/mervinpraison/praisonai-claudecode:latest"
|
||||
env:
|
||||
ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }}
|
||||
GITHUB_TOKEN: ${{ inputs.github_token }}
|
||||
args:
|
||||
- "--anthropic-api-key=${{ inputs.anthropic_api_key }}"
|
||||
- "--github-token=${{ inputs.github_token }}"
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Install Claude Code
|
||||
shell: bash
|
||||
run: npm install -g @anthropic-ai/claude-code
|
||||
|
||||
- name: Install GitHub MCP Server
|
||||
shell: bash
|
||||
run: |
|
||||
claude mcp add-json github '{
|
||||
"command": "docker",
|
||||
"args": [
|
||||
"run",
|
||||
"-i",
|
||||
"--rm",
|
||||
"-e",
|
||||
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
||||
"ghcr.io/github/github-mcp-server:sha-ff3036d"
|
||||
],
|
||||
"env": {
|
||||
"GITHUB_PERSONAL_ACCESS_TOKEN": "${{ inputs.github_token }}"
|
||||
}
|
||||
}'
|
||||
|
||||
- name: Extract GitHub Context and Create Prompt
|
||||
shell: bash
|
||||
id: prepare_context
|
||||
env:
|
||||
# Pass user-controlled inputs via environment variables to prevent script injection (GHSL-2025-093)
|
||||
EVENT_COMMENT_BODY: ${{ github.event.comment.body }}
|
||||
EVENT_ISSUE_TITLE: ${{ github.event.issue.title }}
|
||||
EVENT_ISSUE_BODY: ${{ github.event.issue.body }}
|
||||
EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||
EVENT_PR_TITLE: ${{ github.event.pull_request.title }}
|
||||
EVENT_PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
EVENT_REVIEW_BODY: ${{ github.event.review.body }}
|
||||
EVENT_ASSIGNEE_LOGIN: ${{ github.event.assignee.login }}
|
||||
INPUT_TRIGGER_PHRASE: ${{ inputs.trigger_phrase }}
|
||||
INPUT_ASSIGNEE_TRIGGER: ${{ inputs.assignee_trigger }}
|
||||
INPUT_DIRECT_PROMPT: ${{ inputs.direct_prompt }}
|
||||
EVENT_ACTION: ${{ github.event.action }}
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
REPO_NAME: ${{ github.repository }}
|
||||
run: |
|
||||
echo "🔍 Extracting GitHub context from event: $EVENT_NAME"
|
||||
|
||||
# Function to check for trigger phrase
|
||||
check_trigger() {
|
||||
local text="$1"
|
||||
local trigger="$INPUT_TRIGGER_PHRASE"
|
||||
if [[ "$text" == *"$trigger"* ]]; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Extract context based on event type
|
||||
TRIGGER_FOUND="false"
|
||||
USER_REQUEST=""
|
||||
CONTEXT_INFO=""
|
||||
|
||||
case "$EVENT_NAME" in
|
||||
"issue_comment")
|
||||
COMMENT_BODY="$EVENT_COMMENT_BODY"
|
||||
ISSUE_TITLE="$EVENT_ISSUE_TITLE"
|
||||
ISSUE_NUMBER="$EVENT_ISSUE_NUMBER"
|
||||
|
||||
if check_trigger "$COMMENT_BODY"; then
|
||||
TRIGGER_FOUND="true"
|
||||
USER_REQUEST="$COMMENT_BODY"
|
||||
CONTEXT_INFO="Issue Comment on #$ISSUE_NUMBER: $ISSUE_TITLE"
|
||||
fi
|
||||
;;
|
||||
|
||||
"pull_request_review_comment")
|
||||
COMMENT_BODY="$EVENT_COMMENT_BODY"
|
||||
PR_TITLE="$EVENT_PR_TITLE"
|
||||
PR_NUMBER="$EVENT_PR_NUMBER"
|
||||
|
||||
if check_trigger "$COMMENT_BODY"; then
|
||||
TRIGGER_FOUND="true"
|
||||
USER_REQUEST="$COMMENT_BODY"
|
||||
CONTEXT_INFO="PR Comment on #$PR_NUMBER: $PR_TITLE"
|
||||
fi
|
||||
;;
|
||||
|
||||
"pull_request_review")
|
||||
REVIEW_BODY="$EVENT_REVIEW_BODY"
|
||||
PR_TITLE="$EVENT_PR_TITLE"
|
||||
PR_NUMBER="$EVENT_PR_NUMBER"
|
||||
|
||||
if check_trigger "$REVIEW_BODY"; then
|
||||
TRIGGER_FOUND="true"
|
||||
USER_REQUEST="$REVIEW_BODY"
|
||||
CONTEXT_INFO="PR Review on #$PR_NUMBER: $PR_TITLE"
|
||||
fi
|
||||
;;
|
||||
|
||||
"issues")
|
||||
ISSUE_BODY="$EVENT_ISSUE_BODY"
|
||||
ISSUE_TITLE="$EVENT_ISSUE_TITLE"
|
||||
ISSUE_NUMBER="$EVENT_ISSUE_NUMBER"
|
||||
|
||||
if check_trigger "$ISSUE_TITLE" || check_trigger "$ISSUE_BODY"; then
|
||||
TRIGGER_FOUND="true"
|
||||
USER_REQUEST="$ISSUE_BODY"
|
||||
CONTEXT_INFO="Issue #$ISSUE_NUMBER: $ISSUE_TITLE"
|
||||
elif [[ "$EVENT_ACTION" == "assigned" && -n "$INPUT_ASSIGNEE_TRIGGER" ]]; then
|
||||
ASSIGNEE="$EVENT_ASSIGNEE_LOGIN"
|
||||
if [[ "$ASSIGNEE" == "$INPUT_ASSIGNEE_TRIGGER" ]]; then
|
||||
TRIGGER_FOUND="true"
|
||||
USER_REQUEST="$ISSUE_BODY"
|
||||
CONTEXT_INFO="Issue #$ISSUE_NUMBER assigned to $ASSIGNEE: $ISSUE_TITLE"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# Check for direct prompt override
|
||||
if [[ -n "$INPUT_DIRECT_PROMPT" ]]; then
|
||||
TRIGGER_FOUND="true"
|
||||
USER_REQUEST="$INPUT_DIRECT_PROMPT"
|
||||
CONTEXT_INFO="Automated GitHub workflow"
|
||||
fi
|
||||
|
||||
if [[ "$TRIGGER_FOUND" != "true" ]]; then
|
||||
echo "❌ No trigger phrase found or direct prompt provided. Exiting gracefully."
|
||||
echo "SKIP_EXECUTION=true" >> $GITHUB_ENV
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "✅ Trigger found! Context: $CONTEXT_INFO"
|
||||
|
||||
# Create comprehensive prompt
|
||||
mkdir -p /tmp/claude-action
|
||||
cat > /tmp/claude-action/github-context-prompt.txt << EOF
|
||||
You are Claude Code, an AI assistant helping with GitHub workflows and code.
|
||||
|
||||
Repository: $REPO_NAME
|
||||
Context: $CONTEXT_INFO
|
||||
Event: $EVENT_NAME
|
||||
|
||||
User Request:
|
||||
$USER_REQUEST
|
||||
|
||||
Please analyze the request and provide helpful assistance. You have access to repository tools and can help with:
|
||||
- Code analysis and implementation
|
||||
- GitHub workflows and automation
|
||||
- Pull request reviews and feedback
|
||||
- Issue resolution and bug fixes
|
||||
- Documentation updates
|
||||
- Testing and deployment
|
||||
|
||||
Respond naturally and helpfully to the user's request using the available tools.
|
||||
EOF
|
||||
|
||||
echo "PROMPT_FILE=/tmp/claude-action/github-context-prompt.txt" >> $GITHUB_ENV
|
||||
echo "SKIP_EXECUTION=false" >> $GITHUB_ENV
|
||||
|
||||
- name: Run Claude Code
|
||||
if: env.SKIP_EXECUTION != 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
echo "🚀 Running Claude Code with GitHub context..."
|
||||
|
||||
# Build command arguments
|
||||
CMD_ARGS=("-p" "--verbose" "--output-format" "stream-json")
|
||||
|
||||
# Add max turns if specified
|
||||
if [[ -n "${{ inputs.max_turns }}" ]]; then
|
||||
CMD_ARGS+=("--max-turns" "${{ inputs.max_turns }}")
|
||||
fi
|
||||
|
||||
# Add allowed tools (include GitHub tools by default)
|
||||
TOOLS="mcp__github__get_issue,mcp__github__get_issue_comments,mcp__github__update_issue,mcp__github__search_issues,mcp__github__list_issues,mcp__github__create_comment,Read,Write,Edit,Bash"
|
||||
if [[ -n "${{ inputs.allowed_tools }}" ]]; then
|
||||
TOOLS="$TOOLS,${{ inputs.allowed_tools }}"
|
||||
fi
|
||||
CMD_ARGS+=("--allowedTools" "$TOOLS")
|
||||
|
||||
# Add disallowed tools
|
||||
if [[ -n "${{ inputs.disallowed_tools }}" ]]; then
|
||||
CMD_ARGS+=("--disallowedTools" "${{ inputs.disallowed_tools }}")
|
||||
fi
|
||||
|
||||
echo "📝 Executing Claude Code with prompt from file..."
|
||||
|
||||
# Execute Claude Code with timeout, using stdin for the prompt
|
||||
TIMEOUT_SECONDS=$((${{ inputs.timeout_minutes }} * 60))
|
||||
timeout $TIMEOUT_SECONDS claude "${CMD_ARGS[@]}" < "${{ env.PROMPT_FILE }}"
|
||||
|
||||
echo "✅ Claude Code execution completed"
|
||||
env:
|
||||
ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }}
|
||||
GITHUB_TOKEN: ${{ inputs.github_token }}
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
echo "Running Claude Code in CI mode..."
|
||||
|
||||
# Extract GitHub context and create a smart prompt
|
||||
PROMPT="Analyse the GitHub issue or PR context and generate a smart response based on the repository context."
|
||||
|
||||
# Set environment variables from arguments
|
||||
export ANTHROPIC_API_KEY="${1#--anthropic-api-key=}"
|
||||
export GITHUB_TOKEN="${2#--github-token=}"
|
||||
|
||||
# Verify environment variables
|
||||
if [ -z "$ANTHROPIC_API_KEY" ] || [ -z "$GITHUB_TOKEN" ]; then
|
||||
echo "Error: Required environment variables are not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run Claude with the prompt
|
||||
claude -p "$PROMPT"
|
||||
@@ -1,117 +0,0 @@
|
||||
name: "Claude Code Action"
|
||||
description: "Run Claude Code in GitHub Actions workflows"
|
||||
|
||||
inputs:
|
||||
github_token:
|
||||
description: "GitHub token with repo and issues permissions"
|
||||
required: true
|
||||
anthropic_api_key:
|
||||
description: "Anthropic API key"
|
||||
required: true
|
||||
prompt:
|
||||
description: "The prompt to send to Claude Code"
|
||||
required: false
|
||||
default: ""
|
||||
prompt_file:
|
||||
description: "Path to a file containing the prompt to send to Claude Code"
|
||||
required: false
|
||||
default: ""
|
||||
allowed_tools:
|
||||
description: "Comma-separated list of allowed tools for Claude Code to use"
|
||||
required: false
|
||||
default: ""
|
||||
output_file:
|
||||
description: "File to save Claude Code output to (optional)"
|
||||
required: false
|
||||
default: ""
|
||||
timeout_minutes:
|
||||
description: "Timeout in minutes for Claude Code execution"
|
||||
required: false
|
||||
default: "10"
|
||||
install_github_mcp:
|
||||
description: "Whether to install the GitHub MCP server"
|
||||
required: false
|
||||
default: "false"
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Install Claude Code
|
||||
shell: bash
|
||||
run: npm install -g @anthropic-ai/claude-code
|
||||
|
||||
- name: Install GitHub MCP Server
|
||||
if: inputs.install_github_mcp == 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
claude mcp add-json github '{
|
||||
"command": "docker",
|
||||
"args": [
|
||||
"run",
|
||||
"-i",
|
||||
"--rm",
|
||||
"-e",
|
||||
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
||||
"ghcr.io/github/github-mcp-server:sha-ff3036d"
|
||||
],
|
||||
"env": {
|
||||
"GITHUB_PERSONAL_ACCESS_TOKEN": "${{ inputs.GITHUB_TOKEN }}"
|
||||
}
|
||||
}'
|
||||
|
||||
- name: Prepare Prompt File
|
||||
shell: bash
|
||||
id: prepare_prompt
|
||||
run: |
|
||||
if [ -z "${{ inputs.prompt }}" ] && [ -z "${{ inputs.prompt_file }}" ]; then
|
||||
echo "::error::Neither 'prompt' nor 'prompt_file' was provided. At least one is required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -z "${{ inputs.prompt_file }}" ]; then
|
||||
if [ ! -f "${{ inputs.prompt_file }}" ]; then
|
||||
echo "::error::Prompt file '${{ inputs.prompt_file }}' does not exist."
|
||||
exit 1
|
||||
fi
|
||||
PROMPT_PATH="${{ inputs.prompt_file }}"
|
||||
else
|
||||
mkdir -p /tmp/claude-action
|
||||
PROMPT_PATH="/tmp/claude-action/prompt.txt"
|
||||
echo "${{ inputs.prompt }}" > "$PROMPT_PATH"
|
||||
fi
|
||||
|
||||
if [ ! -s "$PROMPT_PATH" ]; then
|
||||
echo "::error::Prompt is empty. Please provide a non-empty prompt."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "PROMPT_PATH=$PROMPT_PATH" >> $GITHUB_ENV
|
||||
|
||||
- name: Run Claude Code
|
||||
shell: bash
|
||||
id: run_claude
|
||||
run: |
|
||||
timeout_seconds=$((${{ inputs.timeout_minutes }} * 60))
|
||||
|
||||
if [ -z "${{ inputs.output_file }}" ]; then
|
||||
timeout $timeout_seconds claude \
|
||||
-p \
|
||||
--verbose \
|
||||
--output-format stream-json \
|
||||
"$(cat ${{ env.PROMPT_PATH }})" \
|
||||
${{ inputs.allowed_tools != '' && format('--allowedTools "{0}"', inputs.allowed_tools) || '' }}
|
||||
else
|
||||
timeout $timeout_seconds claude \
|
||||
-p \
|
||||
--verbose \
|
||||
--output-format stream-json \
|
||||
"$(cat ${{ env.PROMPT_PATH }})" \
|
||||
${{ inputs.allowed_tools != '' && format('--allowedTools "{0}"', inputs.allowed_tools) || '' }} | tee output.txt
|
||||
|
||||
jq -s '.' output.txt > output.json
|
||||
jq -r '.[-1].result' output.json > "${{ inputs.output_file }}"
|
||||
echo "Complete output saved to output.json, final response saved to ${{ inputs.output_file }}"
|
||||
fi
|
||||
env:
|
||||
ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }}
|
||||
GITHUB_TOKEN: ${{ inputs.github_token }}
|
||||
@@ -0,0 +1,87 @@
|
||||
name: "Claude Issue Triage Action"
|
||||
description: "Automatically triage GitHub issues using Claude Code"
|
||||
|
||||
inputs:
|
||||
timeout_minutes:
|
||||
description: "Timeout in minutes for execution"
|
||||
required: false
|
||||
default: "5"
|
||||
anthropic_api_key:
|
||||
description: "Anthropic API key"
|
||||
required: true
|
||||
github_token:
|
||||
description: "GitHub token with repo and issues permissions"
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Checkout repository code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Create prompt file
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p /tmp/claude-prompts
|
||||
cat > /tmp/claude-prompts/claude-issue-triage-prompt.txt << 'EOF'
|
||||
You're an issue triage assistant for GitHub issues. Your task is to analyze the issue and select appropriate labels from the provided list.
|
||||
|
||||
IMPORTANT: Don't post any comments or messages to the issue. Your only action should be to apply labels.
|
||||
|
||||
Issue Information:
|
||||
- REPO: ${{ github.repository }}
|
||||
- ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||
|
||||
TASK OVERVIEW:
|
||||
|
||||
1. First, fetch the list of labels available in this repository by running: `gh label list`. Run exactly this command with nothing else.
|
||||
|
||||
2. Next, use the GitHub tools to get context about the issue:
|
||||
- You have access to these tools:
|
||||
- mcp__github__get_issue: Use this to retrieve the current issue's details including title, description, and existing labels
|
||||
- mcp__github__get_issue_comments: Use this to read any discussion or additional context provided in the comments
|
||||
- mcp__github__update_issue: Use this to apply labels to the issue (do not use this for commenting)
|
||||
- mcp__github__search_issues: Use this to find similar issues that might provide context for proper categorization and to identify potential duplicate issues
|
||||
- mcp__github__list_issues: Use this to understand patterns in how other issues are labeled
|
||||
- Start by using mcp__github__get_issue to get the issue details
|
||||
|
||||
3. Analyze the issue content, considering:
|
||||
- The issue title and description
|
||||
- The type of issue (bug report, feature request, question, etc.)
|
||||
- Technical areas mentioned
|
||||
- Severity or priority indicators
|
||||
- User impact
|
||||
- Components affected
|
||||
|
||||
4. Select appropriate labels from the available labels list provided above:
|
||||
- Choose labels that accurately reflect the issue's nature
|
||||
- Be specific but comprehensive
|
||||
- Select priority labels if you can determine urgency (high-priority, med-priority, or low-priority)
|
||||
- Consider platform labels (android, ios) if applicable
|
||||
- If you find similar issues using mcp__github__search_issues, consider using a "duplicate" label if appropriate. Only do so if the issue is a duplicate of another OPEN issue.
|
||||
|
||||
5. Apply the selected labels:
|
||||
- Use mcp__github__update_issue to apply your selected labels
|
||||
- DO NOT post any comments explaining your decision
|
||||
- DO NOT communicate directly with users
|
||||
- If no labels are clearly applicable, do not apply any labels
|
||||
|
||||
IMPORTANT GUIDELINES:
|
||||
- Be thorough in your analysis
|
||||
- Only select labels from the provided list above
|
||||
- DO NOT post any comments to the issue
|
||||
- Your ONLY action should be to apply labels using mcp__github__update_issue
|
||||
- It's okay to not add any labels if none are clearly applicable
|
||||
EOF
|
||||
|
||||
- name: Run Claude Code
|
||||
uses: ./.github/actions/claude-code-action
|
||||
with:
|
||||
prompt_file: /tmp/claude-prompts/claude-issue-triage-prompt.txt
|
||||
allowed_tools: "Bash(gh label list),mcp__github__get_issue,mcp__github__get_issue_comments,mcp__github__update_issue,mcp__github__search_issues,mcp__github__list_issues"
|
||||
install_github_mcp: "true"
|
||||
timeout_minutes: ${{ inputs.timeout_minutes }}
|
||||
anthropic_api_key: ${{ inputs.anthropic_api_key }}
|
||||
github_token: ${{ inputs.github_token }}
|
||||
@@ -0,0 +1,81 @@
|
||||
name: 'Gemini CLI Action'
|
||||
description: 'Uses the Gemini CLI to automate software development tasks.'
|
||||
author: 'Gemini'
|
||||
|
||||
inputs:
|
||||
prompt:
|
||||
description: 'A specific prompt to guide Gemini.'
|
||||
required: false
|
||||
default: 'You are a helpful assistant.'
|
||||
GEMINI_API_KEY:
|
||||
description: 'Your Gemini API key.'
|
||||
required: true
|
||||
OTLP_GCP_WIF_PROVIDER:
|
||||
description: 'The workload identity provider for GCP authentication.'
|
||||
required: false
|
||||
OTLP_GOOGLE_CLOUD_PROJECT:
|
||||
description: 'The Google Cloud project for telemetry.'
|
||||
required: false
|
||||
settings_json:
|
||||
description: |
|
||||
A JSON string to configure the Gemini CLI. This will be written to .gemini/settings.json.
|
||||
To enable observability with Google Cloud, include:
|
||||
{"telemetry": {"enabled": true, "target": "gcp"}, "sandbox": false}
|
||||
required: false
|
||||
version:
|
||||
description: |
|
||||
The version of @google/gemini-cli to execute.
|
||||
Can be a specific version from npm (e.g., '0.1.0', 'latest'), a branch name (e.g., 'main'), or a commit hash.
|
||||
required: false
|
||||
default: 'latest'
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Configure Gemini CLI
|
||||
if: inputs.settings_json != ''
|
||||
run: |
|
||||
mkdir -p .gemini
|
||||
echo "$SETTINGS_JSON" > .gemini/settings.json
|
||||
shell: bash
|
||||
env:
|
||||
SETTINGS_JSON: ${{ inputs.settings_json }}
|
||||
|
||||
- name: Authenticate to Google Cloud for Telemetry
|
||||
if: inputs.OTLP_GCP_WIF_PROVIDER != ''
|
||||
id: auth
|
||||
uses: 'google-github-actions/auth@v2'
|
||||
with:
|
||||
project_id: ${{ inputs.OTLP_GOOGLE_CLOUD_PROJECT }}
|
||||
workload_identity_provider: ${{ inputs.OTLP_GCP_WIF_PROVIDER }}
|
||||
|
||||
- name: Install Gemini CLI
|
||||
id: install
|
||||
run: |
|
||||
if [[ "${{ inputs.version }}" == "latest" || "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.-]+)?(\+[a-zA-Z0-9\.-]+)?$ ]]; then
|
||||
echo "Installing Gemini CLI from npm: @google/gemini-cli@${{ inputs.version }}"
|
||||
npm install -g @google/gemini-cli@${{ inputs.version }}
|
||||
else
|
||||
echo "Installing Gemini CLI from GitHub: github:google-gemini/gemini-cli#${{ inputs.version }}"
|
||||
npm install -g github:google-gemini/gemini-cli#${{ inputs.version }}
|
||||
fi
|
||||
echo "Verifying installation:"
|
||||
if command -v gemini >/dev/null 2>&1; then
|
||||
gemini --version || echo "Gemini CLI installed successfully (version command not available)"
|
||||
else
|
||||
echo "Error: Gemini CLI not found in PATH"
|
||||
exit 1
|
||||
fi
|
||||
shell: bash
|
||||
|
||||
- name: Run Gemini CLI
|
||||
run: |
|
||||
gemini --yolo --prompt "$PROMPT"
|
||||
shell: bash
|
||||
env:
|
||||
GEMINI_API_KEY: ${{ inputs.GEMINI_API_KEY }}
|
||||
PROMPT: ${{ inputs.prompt }}
|
||||
|
||||
branding:
|
||||
icon: 'terminal'
|
||||
color: 'blue'
|
||||
@@ -0,0 +1,26 @@
|
||||
name: Auto Issue Comment with PR Creation
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
add-comment:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
contents: write
|
||||
pull-requests: write
|
||||
actions: read
|
||||
steps:
|
||||
- name: Add automated comment
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GH_TOKEN }}
|
||||
script: |
|
||||
github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: '@claude review this issue and do a detailed analysis and fix this if the existing code doesn\'t have the solution implemented. Making sure it has backward compatibility, no existing features removed. After making those changes, again review the applied changes. Use @web to search if you dont know any information or to find the latest documentation or to find the latest version. Run the code if you think you need to run it to test it. Minimal code change to start with if required any changes. MAINLY IT SHOULD NOT IMPACT ON THE CURRENT SPEED OF EXECUTION of existing features, not increasing the overhead. **Please create a PR using gh tool with your changes**.'
|
||||
})
|
||||
@@ -0,0 +1,23 @@
|
||||
name: Auto PR Comment
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
add-comment:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Add automated comment
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GH_TOKEN }}
|
||||
script: |
|
||||
github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: '@claude review this pull request and do a detailed analysis and fix this if the existing code doesn\'t have the solution implemented. Making sure it has backward compatibility, no existing features removed. After making those changes, again review the applied changes. Use @web to search if you dont know any information or to find the latest documentation or to find the latest version. Run the code if you think you need to run it to test it. Minimal code change to start with if required any changes. MAINLY IT SHOULD NOT IMPACT ON THE CURRENT SPEED OF EXECUTION of existing features, not increasing the overhead.'
|
||||
})
|
||||
@@ -11,6 +11,7 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
@@ -26,13 +27,14 @@ jobs:
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
password: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./.github/actions/claude-code-action
|
||||
push: true
|
||||
platforms: linux/amd64
|
||||
tags: ghcr.io/mervinpraison/praisonai-claudecode:${{ inputs.version }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
name: Claude Issue Triage
|
||||
description: "Automatically triage GitHub issues using Claude Code"
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
triage-issue:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||
|
||||
- name: Run Claude Issue Triage
|
||||
uses: ./.github/actions/claude-issue-triage-action
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -0,0 +1,21 @@
|
||||
name: Claude OAuth
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
code:
|
||||
description: 'Authorization code (leave empty for step 1)'
|
||||
required: false
|
||||
|
||||
permissions:
|
||||
actions: write # Required for cache management
|
||||
contents: read # Required for basic repository access
|
||||
|
||||
jobs:
|
||||
auth:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: grll/claude-code-login@v1
|
||||
with:
|
||||
code: ${{ inputs.code }}
|
||||
secrets_admin_pat: ${{ secrets.SECRETS_ADMIN_PAT }}
|
||||
+139
-61
@@ -1,4 +1,4 @@
|
||||
name: Claude Code
|
||||
name: Claude Assistant
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
@@ -6,77 +6,155 @@ on:
|
||||
pull_request_review_comment:
|
||||
types: [created]
|
||||
issues:
|
||||
types: [opened, assigned]
|
||||
types: [opened, assigned, labeled]
|
||||
pull_request_review:
|
||||
types: [submitted]
|
||||
|
||||
jobs:
|
||||
claude:
|
||||
claude-response:
|
||||
# Prevent certain bots from triggering this action (but allow github-actions[bot] for auto-comments)
|
||||
if: |
|
||||
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
|
||||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
||||
github.actor != 'dependabot[bot]' &&
|
||||
github.actor != 'cursor[bot]' &&
|
||||
github.actor != 'renovate[bot]' &&
|
||||
!(contains(github.actor, '[bot]') && github.actor != 'github-actions[bot]')
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
issues: read
|
||||
id-token: write
|
||||
packages: read
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
contents: write
|
||||
pull-requests: write
|
||||
issues: write
|
||||
actions: read
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Debug Environment
|
||||
run: |
|
||||
echo "=== Environment Debug ==="
|
||||
echo "GITHUB_ACTOR: $GITHUB_ACTOR"
|
||||
echo "GITHUB_REPOSITORY: $GITHUB_REPOSITORY"
|
||||
echo "GITHUB_REPOSITORY_OWNER: $GITHUB_REPOSITORY_OWNER"
|
||||
echo "GITHUB_TOKEN exists: $([ -n "$GITHUB_TOKEN" ] && echo "yes" || echo "no")"
|
||||
echo "GITHUB_TOKEN length: ${#GITHUB_TOKEN}"
|
||||
|
||||
- name: Check Package Visibility
|
||||
run: |
|
||||
echo "=== Checking Package Visibility ==="
|
||||
curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
"https://api.github.com/users/MervinPraison/packages/container/praisonai-claudecode" \
|
||||
|| echo "Package API call failed"
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: anthropics/claude-code-action@beta
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Test Docker Authentication
|
||||
run: |
|
||||
echo "=== Testing Docker Authentication ==="
|
||||
echo "Checking ~/.docker/config.json"
|
||||
cat ~/.docker/config.json | jq '.' || echo "No docker config found"
|
||||
echo "=== Testing Registry Access ==="
|
||||
curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
|
||||
"https://ghcr.io/v2/" || echo "Registry access failed"
|
||||
|
||||
- name: Test Docker Pull
|
||||
run: |
|
||||
echo "=== Testing Docker Pull ==="
|
||||
echo "Attempting to pull image: ghcr.io/mervinpraison/praisonai-claudecode:latest"
|
||||
docker pull ghcr.io/mervinpraison/praisonai-claudecode:latest || echo "Pull failed with exit code: $?"
|
||||
echo "=== Checking Docker Images ==="
|
||||
docker images | grep praisonai-claudecode || echo "No images found"
|
||||
|
||||
- name: Run Claude Code
|
||||
id: claude
|
||||
uses: ./.github/actions/claude-code-action
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
claude_code_oauth_token: ${{ secrets.CLAUDE_ACCESS_TOKEN }}
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
trigger_phrase: "@claude"
|
||||
allowed_tools: |
|
||||
Bash(git:*)
|
||||
Bash(python:*)
|
||||
Bash(pip:*)
|
||||
Bash(conda:*)
|
||||
Bash(pytest:*)
|
||||
Bash(gh:*)
|
||||
Bash(python -m pytest:*)
|
||||
Bash(python -m pip:*)
|
||||
Bash(poetry:*)
|
||||
View
|
||||
GlobTool
|
||||
GrepTool
|
||||
BatchTool
|
||||
Edit
|
||||
Replace
|
||||
mcp__github__get_issue
|
||||
mcp__github__get_issue_comments
|
||||
mcp__github__update_issue
|
||||
timeout_minutes: 30
|
||||
|
||||
post-review-comment:
|
||||
needs: claude-response
|
||||
if: success() && needs.claude-response.result == 'success'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
issues: write
|
||||
steps:
|
||||
- name: Check for existing review comment
|
||||
id: check-comment
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GH_TOKEN }}
|
||||
script: |
|
||||
const reviewText = '@claude review if the changes made in the above branch are as per the requirements and make changes to the above branch if issues still exist.';
|
||||
let comments = [];
|
||||
let issueNumber;
|
||||
|
||||
try {
|
||||
// Determine issue/PR number based on event type
|
||||
if (context.eventName === 'pull_request_review_comment' || context.eventName === 'pull_request_review') {
|
||||
issueNumber = context.payload.pull_request?.number || context.issue.number;
|
||||
} else if (context.eventName === 'issue_comment' && context.payload.issue.pull_request) {
|
||||
// This is a comment on a PR (not an issue)
|
||||
issueNumber = context.payload.issue.number;
|
||||
} else {
|
||||
// This is a regular issue
|
||||
issueNumber = context.issue.number;
|
||||
}
|
||||
|
||||
comments = await github.rest.issues.listComments({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber
|
||||
});
|
||||
|
||||
// Look for Claude's completed review comments
|
||||
const claudeReviewComments = comments.data.filter(comment =>
|
||||
(comment.user.login === 'claude[bot]' || comment.body.includes('✅') || comment.body.includes('## Summary')) &&
|
||||
!comment.body.includes('⏳') &&
|
||||
!comment.body.includes('🔄') &&
|
||||
!comment.body.includes('Loading...')
|
||||
);
|
||||
|
||||
// Check if our review request comment already exists
|
||||
const existingReviewRequest = comments.data.find(comment =>
|
||||
comment.body.includes(reviewText)
|
||||
);
|
||||
|
||||
// Post if Claude has completed a review AND we haven't posted the review request yet
|
||||
const shouldPost = claudeReviewComments.length > 0 && !existingReviewRequest;
|
||||
core.setOutput('should-post', shouldPost);
|
||||
console.log(`Claude review completed: ${claudeReviewComments.length > 0}`);
|
||||
console.log(`Review request exists: ${!!existingReviewRequest}`);
|
||||
console.log(`Should post comment: ${shouldPost}`);
|
||||
|
||||
} catch (error) {
|
||||
console.log('Error checking comments:', error);
|
||||
core.setOutput('should-post', false); // If we can't check, don't post
|
||||
}
|
||||
|
||||
- name: Wait 30 seconds before posting comment
|
||||
if: steps.check-comment.outputs.should-post == 'true'
|
||||
run: sleep 30
|
||||
|
||||
- name: Post review comment
|
||||
if: steps.check-comment.outputs.should-post == 'true'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GH_TOKEN }}
|
||||
script: |
|
||||
let issueNumber;
|
||||
let isPR = false;
|
||||
|
||||
// Determine issue/PR number and type based on event type
|
||||
if (context.eventName === 'pull_request_review_comment' || context.eventName === 'pull_request_review') {
|
||||
issueNumber = context.payload.pull_request?.number || context.issue.number;
|
||||
isPR = true;
|
||||
} else if (context.eventName === 'issue_comment' && context.payload.issue.pull_request) {
|
||||
// This is a comment on a PR (not an issue)
|
||||
issueNumber = context.payload.issue.number;
|
||||
isPR = true;
|
||||
} else {
|
||||
// This is a regular issue - don't post review comment
|
||||
issueNumber = context.issue.number;
|
||||
isPR = false;
|
||||
}
|
||||
|
||||
// Only post review comment on PRs, not regular issues
|
||||
if (isPR) {
|
||||
console.log(`Posting review comment on PR #${issueNumber}`);
|
||||
|
||||
await github.rest.issues.createComment({
|
||||
issue_number: issueNumber,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: '@claude review if the changes made in the above branch are as per the requirements and make changes to the above branch if issues still exist. MAINLY IT SHOULD NOT IMPACT ON THE CURRENT SPEED OF EXECUTION of existing features, not increasing the overhead.'
|
||||
});
|
||||
} else {
|
||||
console.log(`Skipping review comment for regular issue #${issueNumber}`);
|
||||
}
|
||||
@@ -10,6 +10,7 @@ jobs:
|
||||
test:
|
||||
name: Run tests and collect coverage
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -40,7 +41,7 @@ jobs:
|
||||
run: |
|
||||
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-5-nano' }}" >> $GITHUB_ENV
|
||||
echo "LOGLEVEL=DEBUG" >> $GITHUB_ENV
|
||||
echo "PYTHONPATH=${{ github.workspace }}/src/praisonai-agents:$PYTHONPATH" >> $GITHUB_ENV
|
||||
|
||||
|
||||
@@ -1,44 +1,54 @@
|
||||
name: Daily Publish Docker
|
||||
name: Publish Docker
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Docker image tag (default: latest)'
|
||||
required: false
|
||||
default: 'latest'
|
||||
|
||||
jobs:
|
||||
check-and-build:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Check last commit time
|
||||
id: check_commit
|
||||
run: |
|
||||
last_commit_time=$(git log -1 --format=%ct)
|
||||
current_time=$(date +%s)
|
||||
time_diff=$((current_time - last_commit_time))
|
||||
if [ $time_diff -ge 120 ] && [ $time_diff -lt 240 ]; then
|
||||
echo "should_run=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "should_run=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
if: steps.check_commit.outputs.should_run == 'true'
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to the GitHub Container Registry
|
||||
if: steps.check_commit.outputs.should_run == 'true'
|
||||
run: echo ${{ secrets.GH_TOKEN }} | docker login ghcr.io -u USERNAME --password-stdin
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ghcr.io/mervinpraison/praisonai
|
||||
tags: |
|
||||
type=raw,value=latest,enable=${{ github.event_name == 'release' }}
|
||||
type=semver,pattern={{version}},enable=${{ github.event_name == 'release' }}
|
||||
type=semver,pattern={{major}}.{{minor}},enable=${{ github.event_name == 'release' }}
|
||||
type=raw,value=${{ github.event.inputs.tag || 'latest' }},enable=${{ github.event_name == 'workflow_dispatch' }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
if: steps.check_commit.outputs.should_run == 'true'
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./docker/Dockerfile
|
||||
push: true
|
||||
tags: ghcr.io/mervinpraison/praisonai:latest
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
@@ -0,0 +1,76 @@
|
||||
name: Gemini Automated Issue Triage
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
triage-issue:
|
||||
if: >
|
||||
github.event_name == 'issue_comment' &&
|
||||
!github.event.issue.pull_request &&
|
||||
contains(github.event.comment.body, '@gemini triage') &&
|
||||
(github.event.comment.author_association == 'OWNER' ||
|
||||
github.event.comment.author_association == 'MEMBER' ||
|
||||
github.event.comment.author_association == 'COLLABORATOR')
|
||||
timeout-minutes: 5
|
||||
permissions:
|
||||
issues: write
|
||||
contents: read
|
||||
id-token: write
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.issue.number }}
|
||||
cancel-in-progress: true
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Generate GitHub App Token
|
||||
id: generate_token
|
||||
uses: actions/create-github-app-token@v1
|
||||
with:
|
||||
app-id: ${{ secrets.APP_ID }}
|
||||
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ steps.generate_token.outputs.token }}
|
||||
|
||||
- name: Run Gemini Issue Triage
|
||||
uses: google-gemini/gemini-cli-action@main
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||
ISSUE_TITLE: ${{ github.event.issue.title }}
|
||||
ISSUE_BODY: ${{ github.event.issue.body }}
|
||||
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||
REPOSITORY: ${{ github.repository }}
|
||||
with:
|
||||
version: 0.1.8-rc.0
|
||||
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
||||
OTLP_GCP_WIF_PROVIDER: ${{ secrets.OTLP_GCP_WIF_PROVIDER }}
|
||||
OTLP_GOOGLE_CLOUD_PROJECT: ${{ secrets.OTLP_GOOGLE_CLOUD_PROJECT }}
|
||||
settings_json: |
|
||||
{
|
||||
"coreTools": [
|
||||
"run_shell_command(gh label list)",
|
||||
"run_shell_command(gh issue edit)"
|
||||
],
|
||||
"telemetry": {
|
||||
"enabled": true,
|
||||
"target": "gcp"
|
||||
},
|
||||
"sandbox": false
|
||||
}
|
||||
prompt: |
|
||||
You are an issue triage assistant. Analyze the current GitHub issue and apply the most appropriate existing labels.
|
||||
|
||||
Steps:
|
||||
1. Run: `gh label list --limit 100` to get all available labels.
|
||||
2. Review the issue title and body provided in the environment variables.
|
||||
3. Select the most relevant labels from the existing labels, focusing on kind/*, area/*, and priority/*.
|
||||
4. Apply the selected labels to this issue using: `gh issue edit ISSUE_NUMBER --add-label "label1,label2"`
|
||||
|
||||
Guidelines:
|
||||
- Only use labels that already exist in the repository.
|
||||
- Do not add comments or modify the issue content.
|
||||
- Triage only the current issue.
|
||||
- Assign all applicable kind/*, area/*, and priority/* labels based on the issue content.
|
||||
@@ -0,0 +1,202 @@
|
||||
name: Gemini Issue Review
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
pull-requests: read
|
||||
|
||||
jobs:
|
||||
review-issue:
|
||||
if: >
|
||||
github.event_name == 'workflow_dispatch' ||
|
||||
(github.event_name == 'issue_comment' &&
|
||||
!github.event.issue.pull_request &&
|
||||
contains(github.event.comment.body, '@gemini') &&
|
||||
!contains(github.event.comment.body, '@gemini triage') &&
|
||||
(github.event.comment.author_association == 'OWNER' ||
|
||||
github.event.comment.author_association == 'MEMBER' ||
|
||||
github.event.comment.author_association == 'COLLABORATOR'))
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
||||
steps:
|
||||
- name: Generate token
|
||||
id: generate_token
|
||||
uses: actions/create-github-app-token@v1
|
||||
with:
|
||||
app-id: ${{ secrets.APP_ID }}
|
||||
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ steps.generate_token.outputs.token }}
|
||||
|
||||
- name: Set up Git
|
||||
run: |
|
||||
git config --local user.email "[email protected]"
|
||||
git config --local user.name "Gemini Bot"
|
||||
|
||||
- name: Get issue data
|
||||
id: issue_data
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||
# Pass user-controlled inputs via environment variables to prevent script injection (GHSL-2025-093)
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||
EVENT_COMMENT_BODY: ${{ github.event.comment.body }}
|
||||
run: |
|
||||
# Get issue number from event or context
|
||||
if [ "$EVENT_NAME" = "issue_comment" ]; then
|
||||
ISSUE_NUMBER="$EVENT_ISSUE_NUMBER"
|
||||
elif [ "$EVENT_NAME" = "issues" ]; then
|
||||
ISSUE_NUMBER="$EVENT_ISSUE_NUMBER"
|
||||
else
|
||||
echo "Unable to determine issue number"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get issue details
|
||||
gh issue view $ISSUE_NUMBER --json title,body,labels,assignees > issue_details.json
|
||||
|
||||
# Extract additional instructions from comment if triggered by comment
|
||||
ADDITIONAL_INSTRUCTIONS=""
|
||||
if [ "$EVENT_NAME" = "issue_comment" ]; then
|
||||
COMMENT_BODY="$EVENT_COMMENT_BODY"
|
||||
ADDITIONAL_INSTRUCTIONS=$(echo "$COMMENT_BODY" | sed -n 's/.*@gemini[[:space:]]*\(.*\)/\1/p' | head -1)
|
||||
fi
|
||||
|
||||
echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $GITHUB_OUTPUT
|
||||
echo "ADDITIONAL_INSTRUCTIONS=$ADDITIONAL_INSTRUCTIONS" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Run Gemini CLI
|
||||
uses: ./.github/actions/gemini
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||
ISSUE_NUMBER: ${{ steps.issue_data.outputs.ISSUE_NUMBER }}
|
||||
ADDITIONAL_INSTRUCTIONS: ${{ steps.issue_data.outputs.ADDITIONAL_INSTRUCTIONS }}
|
||||
REPOSITORY: ${{ github.repository }}
|
||||
with:
|
||||
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
||||
OTLP_GCP_WIF_PROVIDER: ${{ secrets.OTLP_GCP_WIF_PROVIDER }}
|
||||
OTLP_GOOGLE_CLOUD_PROJECT: ${{ secrets.OTLP_GOOGLE_CLOUD_PROJECT }}
|
||||
prompt: |
|
||||
You are a helpful GitHub issue assistant. Your task is to analyze and help with GitHub issues.
|
||||
|
||||
**Issue Details:**
|
||||
- Issue Number: #${ISSUE_NUMBER}
|
||||
- Repository: ${REPOSITORY}
|
||||
- Issue URL: ${{ github.event.issue.html_url }}
|
||||
|
||||
**Additional Instructions:** ${ADDITIONAL_INSTRUCTIONS}
|
||||
|
||||
**CRITICAL: When making code modifications, follow this EXACT workflow:**
|
||||
|
||||
**STEP 1: Analyze the Issue**
|
||||
- Use: `gh issue view ${ISSUE_NUMBER} --json title,body,labels,assignees`
|
||||
- Analyze issue content thoroughly
|
||||
- Search codebase for related files using `glob`, `search_file_content`, `list_directory`
|
||||
|
||||
**STEP 2: If Code Changes Are Needed**
|
||||
Create a new branch with 'gemini/' prefix:
|
||||
- Use: `git checkout -b gemini/issue-${ISSUE_NUMBER}-description`
|
||||
- Example: `git checkout -b gemini/issue-123-fix-sequential-tools`
|
||||
|
||||
**STEP 3: Make Code Modifications**
|
||||
- Use `read_file` to examine existing code
|
||||
- Use `write_file` or `replace` to make changes
|
||||
- Use `search_file_content` to find related code
|
||||
- Make focused, targeted changes to fix the issue
|
||||
|
||||
**STEP 4: Test Changes (if applicable)**
|
||||
- Run relevant tests if test files exist
|
||||
- Use `run_shell_command` to execute test commands
|
||||
|
||||
**STEP 5: Commit and Push Changes**
|
||||
- Use: `git add .` (or specific files)
|
||||
- Use: `git commit -m "Gemini: [Issue #${ISSUE_NUMBER}] Brief description of fix"`
|
||||
- Use: `git push -u origin gemini/issue-${ISSUE_NUMBER}-description`
|
||||
|
||||
**STEP 6: Create Pull Request**
|
||||
- Use: `gh pr create --title "Fix #${ISSUE_NUMBER}: Issue description" --body "Fixes #${ISSUE_NUMBER}\n\nSummary of changes:\n- Change 1\n- Change 2" --head gemini/issue-${ISSUE_NUMBER}-description --base main`
|
||||
- This will return a PR URL like: https://github.com/repo/pull/123
|
||||
|
||||
**STEP 7: Comment on Issue with Results**
|
||||
Use: `gh issue comment ${ISSUE_NUMBER} -b "MESSAGE"`
|
||||
|
||||
**Your final comment MUST include:**
|
||||
- Summary of what was analyzed
|
||||
- What changes were made (if any)
|
||||
- Link to the created PR (if applicable)
|
||||
- Brief explanation of the solution
|
||||
|
||||
**Example final comment:**
|
||||
```
|
||||
Hi! I've analyzed and fixed this issue.
|
||||
|
||||
**Problem:** Sequential tool calling was getting stuck after first tool call.
|
||||
|
||||
**Solution:** Added proper prompt handling after each tool call in the Ollama model integration.
|
||||
|
||||
**Changes Made:**
|
||||
- Modified `src/praisonai-agents/ollama-sequential.py`
|
||||
- Added continuation prompts for multi-step tool execution
|
||||
|
||||
**Pull Request:** https://github.com/MervinPraison/PraisonAI/pull/856
|
||||
|
||||
The fix is ready for review. Please test and let me know if you encounter any issues!
|
||||
```
|
||||
|
||||
**IMPORTANT NOTES:**
|
||||
- Always create branches with 'gemini/' prefix
|
||||
- Always include issue number in branch name and commit message
|
||||
- Always create PR that references the issue
|
||||
- Always provide PR link in your final response
|
||||
- Use the GITHUB_TOKEN environment variable for authentication
|
||||
|
||||
Please proceed with helping resolve this issue following this exact workflow.
|
||||
|
||||
settings_json: |
|
||||
{
|
||||
"coreTools": [
|
||||
"run_shell_command(echo)",
|
||||
"run_shell_command(gh issue view)",
|
||||
"run_shell_command(gh issue comment)",
|
||||
"run_shell_command(gh issue list)",
|
||||
"run_shell_command(gh issue edit)",
|
||||
"run_shell_command(gh pr create)",
|
||||
"run_shell_command(gh pr view)",
|
||||
"run_shell_command(gh pr list)",
|
||||
"run_shell_command(cat)",
|
||||
"run_shell_command(head)",
|
||||
"run_shell_command(tail)",
|
||||
"run_shell_command(grep)",
|
||||
"run_shell_command(find)",
|
||||
"run_shell_command(git checkout)",
|
||||
"run_shell_command(git add)",
|
||||
"run_shell_command(git commit)",
|
||||
"run_shell_command(git push)",
|
||||
"run_shell_command(git status)",
|
||||
"run_shell_command(git branch)",
|
||||
"list_directory",
|
||||
"read_file",
|
||||
"read_many_files",
|
||||
"write_file",
|
||||
"replace",
|
||||
"glob",
|
||||
"search_file_content",
|
||||
"web_fetch",
|
||||
"google_web_search",
|
||||
"save_memory"
|
||||
],
|
||||
"telemetry": {
|
||||
"enabled": false,
|
||||
"otlpGcpWifProvider": "${{ secrets.OTLP_GCP_WIF_PROVIDER }}",
|
||||
"googleCloudProject": "${{ secrets.OTLP_GOOGLE_CLOUD_PROJECT }}"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
name: Gemini PR Review
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
pr_number:
|
||||
description: 'PR number to review'
|
||||
required: true
|
||||
type: number
|
||||
|
||||
jobs:
|
||||
review-pr:
|
||||
if: >
|
||||
github.event_name == 'workflow_dispatch' ||
|
||||
(github.event_name == 'issue_comment' &&
|
||||
github.event.issue.pull_request &&
|
||||
contains(github.event.comment.body, '@gemini') &&
|
||||
(github.event.comment.author_association == 'OWNER' ||
|
||||
github.event.comment.author_association == 'MEMBER' ||
|
||||
github.event.comment.author_association == 'COLLABORATOR'))
|
||||
timeout-minutes: 15
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
pull-requests: write
|
||||
issues: write
|
||||
steps:
|
||||
- name: Generate GitHub App Token
|
||||
id: generate_token
|
||||
uses: actions/create-github-app-token@v1
|
||||
with:
|
||||
app-id: ${{ secrets.APP_ID }}
|
||||
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||
|
||||
- name: Determine checkout ref
|
||||
id: checkout_ref
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "issue_comment" ]; then
|
||||
echo "ref=refs/pull/${{ github.event.issue.number }}/head" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "ref=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Checkout PR code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ steps.generate_token.outputs.token }}
|
||||
ref: ${{ steps.checkout_ref.outputs.ref }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get PR details
|
||||
id: get_pr
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||
# Pass user-controlled inputs via environment variables to prevent script injection (GHSL-2025-093)
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
EVENT_INPUTS_PR_NUMBER: ${{ github.event.inputs.pr_number }}
|
||||
EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||
EVENT_PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
EVENT_COMMENT_BODY: ${{ github.event.comment.body }}
|
||||
run: |
|
||||
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
|
||||
PR_NUMBER=$EVENT_INPUTS_PR_NUMBER
|
||||
elif [ "$EVENT_NAME" = "issue_comment" ]; then
|
||||
PR_NUMBER=$EVENT_ISSUE_NUMBER
|
||||
else
|
||||
PR_NUMBER=$EVENT_PR_NUMBER
|
||||
fi
|
||||
|
||||
echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Extract additional instructions from comment (if triggered by comment)
|
||||
ADDITIONAL_INSTRUCTIONS=""
|
||||
if [ "$EVENT_NAME" = "issue_comment" ]; then
|
||||
COMMENT_BODY="$EVENT_COMMENT_BODY"
|
||||
ADDITIONAL_INSTRUCTIONS=$(echo "$COMMENT_BODY" | sed 's/.*@gemini//' | xargs)
|
||||
fi
|
||||
echo "additional_instructions=$ADDITIONAL_INSTRUCTIONS" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Get PR details
|
||||
PR_DATA=$(gh pr view $PR_NUMBER --json title,body,additions,deletions,changedFiles,baseRefName,headRefName)
|
||||
echo "pr_data=$PR_DATA" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Get file changes
|
||||
CHANGED_FILES=$(gh pr diff $PR_NUMBER --name-only)
|
||||
echo "changed_files<<EOF" >> "$GITHUB_OUTPUT"
|
||||
echo "$CHANGED_FILES" >> "$GITHUB_OUTPUT"
|
||||
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Run Gemini PR Review
|
||||
uses: ./.github/actions/gemini
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||
PR_NUMBER: ${{ steps.get_pr.outputs.pr_number }}
|
||||
PR_DATA: ${{ steps.get_pr.outputs.pr_data }}
|
||||
CHANGED_FILES: ${{ steps.get_pr.outputs.changed_files }}
|
||||
ADDITIONAL_INSTRUCTIONS: ${{ steps.get_pr.outputs.additional_instructions }}
|
||||
REPOSITORY: ${{ github.repository }}
|
||||
with:
|
||||
version: 0.1.8-rc.0
|
||||
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
||||
OTLP_GCP_WIF_PROVIDER: ${{ secrets.OTLP_GCP_WIF_PROVIDER }}
|
||||
OTLP_GOOGLE_CLOUD_PROJECT: ${{ secrets.OTLP_GOOGLE_CLOUD_PROJECT }}
|
||||
settings_json: |
|
||||
{
|
||||
"coreTools": [
|
||||
"run_shell_command(echo)",
|
||||
"run_shell_command(gh pr view)",
|
||||
"run_shell_command(gh pr diff)",
|
||||
"run_shell_command(gh pr comment)",
|
||||
"run_shell_command(gh pr list)",
|
||||
"run_shell_command(cat)",
|
||||
"run_shell_command(head)",
|
||||
"run_shell_command(tail)",
|
||||
"run_shell_command(grep)",
|
||||
"run_shell_command(find)",
|
||||
"run_shell_command(git checkout)",
|
||||
"run_shell_command(git add)",
|
||||
"run_shell_command(git commit)",
|
||||
"run_shell_command(git push)",
|
||||
"run_shell_command(git status)",
|
||||
"run_shell_command(git branch)",
|
||||
"run_shell_command(git fetch)",
|
||||
"list_directory",
|
||||
"read_file",
|
||||
"read_many_files",
|
||||
"write_file",
|
||||
"replace",
|
||||
"glob",
|
||||
"search_file_content",
|
||||
"web_fetch",
|
||||
"google_web_search",
|
||||
"save_memory"
|
||||
],
|
||||
"telemetry": {
|
||||
"enabled": false,
|
||||
"target": "gcp"
|
||||
},
|
||||
"sandbox": false
|
||||
}
|
||||
prompt: |
|
||||
You are an expert code reviewer and AI assistant for Pull Requests. You can review code AND make modifications to improve the PR.
|
||||
|
||||
**PR Details:**
|
||||
- PR Number: #$PR_NUMBER
|
||||
- Repository: $REPOSITORY
|
||||
- Additional Instructions: $ADDITIONAL_INSTRUCTIONS
|
||||
|
||||
**CRITICAL: When making code modifications, follow this EXACT workflow:**
|
||||
|
||||
**STEP 1: Analyze the PR**
|
||||
- Use: `echo "$PR_DATA"` to get PR details (JSON format)
|
||||
- Use: `echo "$CHANGED_FILES"` to get changed files list
|
||||
- Use: `gh pr diff ${PR_NUMBER}` to see the full diff
|
||||
- Use: `gh pr view ${PR_NUMBER} --json title,body,headRefName` to get PR info
|
||||
- Analyze the code changes thoroughly
|
||||
|
||||
**STEP 2: If Code Improvements Are Needed**
|
||||
**IMPORTANT:** DO NOT create a new branch! Work on the EXISTING PR branch.
|
||||
- Use: `git fetch origin` to get latest changes
|
||||
- Get PR branch name: `gh pr view ${PR_NUMBER} --json headRefName`
|
||||
- Switch to PR branch: `git checkout BRANCH_NAME` (use actual branch name from PR)
|
||||
- Use: `git pull origin BRANCH_NAME` to get latest PR changes
|
||||
|
||||
**STEP 3: Make Code Modifications**
|
||||
- Use `read_file` to examine existing code
|
||||
- Use `write_file` or `replace` to make improvements
|
||||
- Use `search_file_content` to find related code
|
||||
- Make focused, targeted improvements to the PR
|
||||
|
||||
**STEP 4: Test Changes (if applicable)**
|
||||
- Run relevant tests if test files exist
|
||||
- Use `run_shell_command` to execute test commands
|
||||
|
||||
**STEP 5: Commit and Push Changes to EXISTING PR Branch**
|
||||
- Use: `git add .` (or specific files)
|
||||
- Use: `git commit -m "Gemini: [PR #${PR_NUMBER}] Brief description of improvements"`
|
||||
- Use: `git push origin BRANCH_NAME` (push to EXISTING PR branch)
|
||||
|
||||
**STEP 6: Review and Comment on PR**
|
||||
Write comprehensive review and post comment with your analysis and any improvements made.
|
||||
Use: `gh pr comment ${PR_NUMBER} -b "MESSAGE"`
|
||||
|
||||
Review Guidelines:
|
||||
- Focus on code quality, security, performance, and maintainability
|
||||
- Check for common issues: potential bugs, security vulnerabilities, performance bottlenecks
|
||||
- Verify error handling and edge cases
|
||||
- Look for code style and best practices
|
||||
- Comment on architecture and design decisions if significant
|
||||
- Be constructive and specific in feedback
|
||||
- Highlight both issues and positive aspects
|
||||
- Suggest improvements with examples when possible
|
||||
|
||||
Review Areas:
|
||||
- **Security**: Authentication, authorization, input validation, data sanitization
|
||||
- **Performance**: Algorithms, database queries, caching, resource usage
|
||||
- **Reliability**: Error handling, logging, testing coverage, edge cases
|
||||
- **Maintainability**: Code structure, documentation, naming conventions
|
||||
- **Functionality**: Logic correctness, requirements fulfillment
|
||||
|
||||
Output Format:
|
||||
Structure your review using this exact format with markdown:
|
||||
|
||||
## 📋 Review Summary
|
||||
Provide a brief 2-3 sentence overview of the PR and overall assessment.
|
||||
|
||||
## 🔍 General Feedback
|
||||
- List general observations about code quality
|
||||
- Mention overall patterns or architectural decisions
|
||||
- Highlight positive aspects of the implementation
|
||||
- Note any recurring themes across files
|
||||
|
||||
## 🎯 Specific Feedback
|
||||
Only include sections below that have actual issues. If there are no issues in a priority category, omit that entire section.
|
||||
|
||||
### 🔴 Critical
|
||||
(Only include this section if there are critical issues)
|
||||
Issues that must be addressed before merging (security vulnerabilities, breaking changes, major bugs):
|
||||
- **File: `filename:line`** - Description of critical issue with specific recommendation
|
||||
|
||||
### 🟡 High
|
||||
(Only include this section if there are high priority issues)
|
||||
Important issues that should be addressed (performance problems, design flaws, significant bugs):
|
||||
- **File: `filename:line`** - Description of high priority issue with suggested fix
|
||||
|
||||
### 🟢 Medium
|
||||
(Only include this section if there are medium priority issues)
|
||||
Improvements that would enhance code quality (style issues, minor optimizations, better practices):
|
||||
- **File: `filename:line`** - Description of medium priority improvement
|
||||
|
||||
### 🔵 Low
|
||||
(Only include this section if there are suggestions)
|
||||
Nice-to-have improvements and suggestions (documentation, naming, minor refactoring):
|
||||
- **File: `filename:line`** - Description of suggestion or enhancement
|
||||
|
||||
**Note**: If no specific issues are found in any category, simply state "No specific issues identified in this review."
|
||||
|
||||
## ✅ Highlights
|
||||
(Only include this section if there are positive aspects to highlight)
|
||||
- Mention specific good practices or implementations
|
||||
- Acknowledge well-written code sections
|
||||
- Note improvements from previous versions
|
||||
|
||||
---
|
||||
*Review completed by Gemini CLI*
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
run: |
|
||||
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-5-nano' }}" >> $GITHUB_ENV
|
||||
echo "LOGLEVEL=DEBUG" >> $GITHUB_ENV
|
||||
|
||||
- name: Install dependencies
|
||||
|
||||
@@ -26,6 +26,10 @@ on:
|
||||
jobs:
|
||||
comprehensive-test:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
OPENAI_MODEL_NAME: gpt-4o-mini
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.11"]
|
||||
@@ -54,11 +58,13 @@ jobs:
|
||||
# Install knowledge dependencies from praisonai-agents
|
||||
uv pip install --system "praisonaiagents[knowledge]"
|
||||
|
||||
- name: Set environment variables
|
||||
- name: Verify environment variables
|
||||
run: |
|
||||
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}" >> $GITHUB_ENV
|
||||
if [ -n "$OPENAI_API_KEY" ]; then
|
||||
echo "✅ OPENAI_API_KEY is set (length: ${#OPENAI_API_KEY})"
|
||||
else
|
||||
echo "⚠️ OPENAI_API_KEY is NOT set"
|
||||
fi
|
||||
|
||||
- name: Run Comprehensive Test Suite
|
||||
run: |
|
||||
|
||||
@@ -9,6 +9,7 @@ on:
|
||||
jobs:
|
||||
test-core:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.11]
|
||||
@@ -33,7 +34,7 @@ jobs:
|
||||
cd src/praisonai
|
||||
uv pip install --system ."[ui,gradio,api,agentops,google,openai,anthropic,cohere,chat,code,realtime,call,crewai,autogen]"
|
||||
uv pip install --system duckduckgo_search
|
||||
uv pip install --system pytest pytest-asyncio pytest-cov
|
||||
uv pip install --system pytest pytest-asyncio pytest-cov pytest-timeout
|
||||
# Install knowledge dependencies from praisonai-agents
|
||||
uv pip install --system "praisonaiagents[knowledge]"
|
||||
|
||||
@@ -41,13 +42,13 @@ jobs:
|
||||
run: |
|
||||
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-5-nano' }}" >> $GITHUB_ENV
|
||||
echo "LOGLEVEL=DEBUG" >> $GITHUB_ENV
|
||||
echo "PYTHONPATH=${{ github.workspace }}/src/praisonai-agents:$PYTHONPATH" >> $GITHUB_ENV
|
||||
# Also export to current shell session for immediate availability
|
||||
export OPENAI_API_KEY="${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}"
|
||||
export OPENAI_API_BASE="${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}"
|
||||
export OPENAI_MODEL_NAME="${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}"
|
||||
export OPENAI_MODEL_NAME="${{ secrets.OPENAI_MODEL_NAME || 'gpt-5-nano' }}"
|
||||
export LOGLEVEL=DEBUG
|
||||
# Verify immediate availability
|
||||
echo "🔧 Immediate verification in same step:"
|
||||
@@ -125,7 +126,7 @@ jobs:
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}
|
||||
OPENAI_API_BASE: ${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}
|
||||
OPENAI_MODEL_NAME: ${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}
|
||||
OPENAI_MODEL_NAME: ${{ secrets.OPENAI_MODEL_NAME || 'gpt-5-nano' }}
|
||||
LOGLEVEL: DEBUG
|
||||
run: |
|
||||
echo "🔍 Testing PraisonAI API key usage directly..."
|
||||
@@ -151,7 +152,7 @@ jobs:
|
||||
return 'INVALID_TYPE'
|
||||
|
||||
print('🔧 Direct PraisonAI API Key Check:')
|
||||
env_api_key = os.environ.get(\\"OPENAI_API_KEY\\", \\"NOT_SET\\")
|
||||
env_api_key = os.environ.get(\"OPENAI_API_KEY\", \"NOT_SET\")
|
||||
print(f'Environment OPENAI_API_KEY: {get_key_display_value(env_api_key)}...')
|
||||
|
||||
from praisonai import PraisonAI
|
||||
@@ -163,9 +164,9 @@ jobs:
|
||||
|
||||
from praisonai.inc.models import PraisonAIModel
|
||||
|
||||
print('\\\\n🧪 Testing PraisonAIModel with explicit API key (CrewAI method):')
|
||||
print('\\n🧪 Testing PraisonAIModel with explicit API key (CrewAI method):')
|
||||
model_with_explicit_key = PraisonAIModel(
|
||||
model='openai/gpt-4o-mini',
|
||||
model='openai/gpt-5-nano',
|
||||
base_url=praisonai.config_list[0].get('base_url'),
|
||||
api_key=api_key_from_config # This will be a string from praisonai.config_list
|
||||
)
|
||||
@@ -250,7 +251,7 @@ jobs:
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}
|
||||
OPENAI_API_BASE: ${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}
|
||||
OPENAI_MODEL_NAME: ${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}
|
||||
OPENAI_MODEL_NAME: ${{ secrets.OPENAI_MODEL_NAME || 'gpt-5-nano' }}
|
||||
LOGLEVEL: DEBUG
|
||||
run: |
|
||||
echo "🧪 Running legacy tests with real API key..."
|
||||
@@ -261,7 +262,7 @@ jobs:
|
||||
export OPENAI_API_KEY="$OPENAI_API_KEY"
|
||||
export OPENAI_API_BASE="$OPENAI_API_BASE"
|
||||
export OPENAI_MODEL_NAME="$OPENAI_MODEL_NAME"
|
||||
cd src/praisonai && python -m pytest tests/test.py -v --tb=short --disable-warnings
|
||||
cd src/praisonai && python -m pytest tests/test.py -v --tb=short --disable-warnings -m "not real" --timeout=60
|
||||
|
||||
- name: Upload coverage reports to Codecov
|
||||
if: matrix.python-version == '3.11'
|
||||
|
||||
@@ -13,6 +13,7 @@ on:
|
||||
jobs:
|
||||
test-examples:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -41,8 +42,11 @@ jobs:
|
||||
run: |
|
||||
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-5-nano' }}" >> $GITHUB_ENV
|
||||
echo "PYTHONPATH=${{ github.workspace }}/src/praisonai-agents:$PYTHONPATH" >> $GITHUB_ENV
|
||||
echo "PRAISONAI_TELEMETRY_DISABLED=true" >> $GITHUB_ENV
|
||||
echo "PRAISONAI_DISABLE_TELEMETRY=true" >> $GITHUB_ENV
|
||||
echo "DO_NOT_TRACK=true" >> $GITHUB_ENV
|
||||
|
||||
- name: Test Key Example Scripts
|
||||
run: |
|
||||
@@ -73,6 +77,7 @@ jobs:
|
||||
|
||||
performance-test:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -97,6 +102,12 @@ jobs:
|
||||
# Install knowledge dependencies from praisonai-agents
|
||||
uv pip install --system "praisonaiagents[knowledge]"
|
||||
|
||||
- name: Set environment variables
|
||||
run: |
|
||||
echo "PRAISONAI_TELEMETRY_DISABLED=true" >> $GITHUB_ENV
|
||||
echo "PRAISONAI_DISABLE_TELEMETRY=true" >> $GITHUB_ENV
|
||||
echo "DO_NOT_TRACK=true" >> $GITHUB_ENV
|
||||
|
||||
- name: Run Performance Benchmarks
|
||||
run: |
|
||||
echo "🏃 Running performance benchmarks..."
|
||||
@@ -161,4 +172,4 @@ jobs:
|
||||
with:
|
||||
name: performance-report
|
||||
path: performance_report.md
|
||||
retention-days: 30
|
||||
retention-days: 5
|
||||
@@ -24,6 +24,7 @@ on:
|
||||
jobs:
|
||||
framework-tests:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.11]
|
||||
@@ -55,7 +56,7 @@ jobs:
|
||||
run: |
|
||||
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-5-nano' }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Test ${{ matrix.framework }} Framework
|
||||
run: |
|
||||
|
||||
@@ -26,6 +26,7 @@ jobs:
|
||||
real-tests:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event.inputs.confirm_costs == 'true' && github.event.inputs.framework != 'none' }}
|
||||
timeout-minutes: 15
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
|
||||
@@ -5,6 +5,7 @@ on: [push, pull_request]
|
||||
jobs:
|
||||
quick-test:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -26,7 +27,7 @@ jobs:
|
||||
cd src/praisonai
|
||||
uv pip install --system ."[ui,gradio,api,agentops,google,openai,anthropic,cohere,chat,code,realtime,call,crewai,autogen]"
|
||||
uv pip install --system duckduckgo_search
|
||||
uv pip install --system pytest pytest-asyncio pytest-cov
|
||||
uv pip install --system pytest pytest-asyncio pytest-cov pytest-timeout
|
||||
# Install knowledge dependencies from praisonai-agents
|
||||
uv pip install --system "praisonaiagents[knowledge]"
|
||||
|
||||
@@ -34,7 +35,7 @@ jobs:
|
||||
run: |
|
||||
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}" >> $GITHUB_ENV
|
||||
echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-5-nano' }}" >> $GITHUB_ENV
|
||||
echo "LOGLEVEL=DEBUG" >> $GITHUB_ENV
|
||||
echo "PYTHONPATH=${{ github.workspace }}/src/praisonai-agents:$PYTHONPATH" >> $GITHUB_ENV
|
||||
|
||||
@@ -315,8 +316,8 @@ jobs:
|
||||
try:
|
||||
from praisonai.inc.models import PraisonAIModel
|
||||
|
||||
# Test PraisonAIModel with openai/gpt-4o-mini (from YAML)
|
||||
model = PraisonAIModel(model='openai/gpt-4o-mini')
|
||||
# Test PraisonAIModel with openai/gpt-5-nano (from YAML)
|
||||
model = PraisonAIModel(model='openai/gpt-5-nano')
|
||||
|
||||
print('🤖 PraisonAIModel Configuration:')
|
||||
print(f' model: {model.model}')
|
||||
@@ -488,7 +489,7 @@ jobs:
|
||||
|
||||
- name: Run Legacy Example Tests
|
||||
run: |
|
||||
cd src/praisonai && python -m pytest tests/test.py -v --tb=short --disable-warnings
|
||||
cd src/praisonai && python -m pytest tests/test.py -v --tb=short --disable-warnings -m "not real" --timeout=60
|
||||
continue-on-error: true
|
||||
|
||||
- name: Upload coverage reports to Codecov
|
||||
|
||||
+8
-1
@@ -75,4 +75,11 @@ agents/praisonaiagents/praisonaiagents.egg-info
|
||||
# Local Netlify folder
|
||||
.netlify
|
||||
.qodo
|
||||
CopilotKit*
|
||||
CopilotKit*
|
||||
.gemini
|
||||
issue_details.json
|
||||
|
||||
# MCP Registry tokens
|
||||
.mcpregistry_*
|
||||
|
||||
*.log
|
||||
+2
-1
@@ -14,9 +14,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
RUN mkdir -p /root/.praison
|
||||
|
||||
# Install Python packages (using latest versions)
|
||||
# Note: praisonai is installed from PyPI - remove version pin to use latest available
|
||||
RUN pip install --no-cache-dir \
|
||||
flask \
|
||||
"praisonai>=2.2.33" \
|
||||
praisonai \
|
||||
"praisonai[api]" \
|
||||
gunicorn \
|
||||
markdown
|
||||
|
||||
@@ -16,7 +16,7 @@ RUN mkdir -p /root/.praison
|
||||
# Install Python packages (using latest versions)
|
||||
RUN pip install --no-cache-dir \
|
||||
praisonai_tools \
|
||||
"praisonai>=2.2.33" \
|
||||
"praisonai>=2.5.6" \
|
||||
"praisonai[chat]" \
|
||||
"embedchain[github,youtube]"
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ RUN mkdir -p /root/.praison
|
||||
# Install Python packages (using latest versions)
|
||||
RUN pip install --no-cache-dir \
|
||||
praisonai_tools \
|
||||
"praisonai>=2.2.33" \
|
||||
"praisonai>=2.5.6" \
|
||||
"praisonai[ui]" \
|
||||
"praisonai[chat]" \
|
||||
"praisonai[realtime]" \
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# Dockerfile for PraisonAI Serve API
|
||||
# Deploy to Railway, Render, Fly.io, or any container platform
|
||||
#
|
||||
# Build: docker build -f Dockerfile.serve -t praisonai-serve .
|
||||
# Run: docker run -p 8005:8005 -e OPENAI_API_KEY=sk-xxx praisonai-serve
|
||||
|
||||
FROM python:3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
RUN pip install --no-cache-dir praisonai praisonaiagents
|
||||
|
||||
# Copy agents configuration
|
||||
COPY agents.yaml .
|
||||
|
||||
# Expose the API port
|
||||
EXPOSE 8005
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8005/health || exit 1
|
||||
|
||||
# Start the API server
|
||||
CMD ["praisonai", "serve", "agents.yaml", "--host", "0.0.0.0", "--port", "8005"]
|
||||
@@ -16,7 +16,7 @@ RUN mkdir -p /root/.praison
|
||||
# Install Python packages (using latest versions)
|
||||
RUN pip install --no-cache-dir \
|
||||
praisonai_tools \
|
||||
"praisonai>=2.2.33" \
|
||||
"praisonai>=2.5.6" \
|
||||
"praisonai[ui]" \
|
||||
"praisonai[crewai]"
|
||||
|
||||
|
||||
+2
-2
@@ -121,7 +121,7 @@ healthcheck:
|
||||
## 📦 Package Versions
|
||||
|
||||
All Docker images use consistent, up-to-date versions:
|
||||
- PraisonAI: `>=2.2.33`
|
||||
- PraisonAI: `>=2.2.95`
|
||||
- PraisonAI Agents: `>=0.0.92`
|
||||
- Python: `3.11-slim`
|
||||
|
||||
@@ -218,7 +218,7 @@ docker-compose up -d
|
||||
### Version Pinning
|
||||
To use specific versions, update the Dockerfile:
|
||||
```dockerfile
|
||||
RUN pip install "praisonai==2.2.33" "praisonaiagents==0.0.92"
|
||||
RUN pip install "praisonai==2.2.95" "praisonaiagents==0.0.92"
|
||||
```
|
||||
|
||||
## 🌐 Production Deployment
|
||||
|
||||
@@ -137,22 +137,11 @@ services:
|
||||
POSTGRES_USER: praisonai
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-praisonai_dev_pass}
|
||||
volumes:
|
||||
database:
|
||||
image: postgres:15-alpine
|
||||
environment:
|
||||
POSTGRES_DB: praisonai_dev
|
||||
POSTGRES_USER: praisonai
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-praisonai_dev_pass}
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
read_only: true
|
||||
tmpfs:
|
||||
- /tmp
|
||||
- /var/tmp
|
||||
ports:
|
||||
- "5432:5432"
|
||||
networks:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
read_only: true
|
||||
tmpfs:
|
||||
- /tmp
|
||||
- /var/tmp
|
||||
ports:
|
||||
- "5432:5432"
|
||||
networks:
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
# PraisonAI Examples
|
||||
|
||||
This folder contains examples for PraisonAI. For detailed documentation, visit [docs.praison.ai](https://docs.praison.ai).
|
||||
|
||||
## Structure
|
||||
|
||||
```
|
||||
examples/
|
||||
├── python/ # Python examples
|
||||
│ ├── agents/ # Agent examples (single, multi, router, etc.)
|
||||
│ ├── workflows/ # Workflow patterns (routing, parallel, loop)
|
||||
│ ├── tools/ # Custom tools examples
|
||||
│ ├── mcp/ # MCP protocol examples
|
||||
│ ├── memory/ # Memory and sessions
|
||||
│ ├── code/ # Code editing and external CLI tools
|
||||
│ └── ...
|
||||
├── yaml/ # YAML workflow examples
|
||||
└── cookbooks/ # Complete use-case examples
|
||||
```
|
||||
|
||||
## Quick Links
|
||||
|
||||
| Category | Examples | Docs |
|
||||
|----------|----------|------|
|
||||
| **Agents** | [python/agents/](python/agents/) | [📖](https://docs.praison.ai/concepts/agents) |
|
||||
| **Workflows** | [python/workflows/](python/workflows/) | [📖](https://docs.praison.ai/features/workflows) |
|
||||
| **Model Router** | [python/agents/router-agent-cost-optimization.py](python/agents/router-agent-cost-optimization.py) | [📖](https://docs.praison.ai/features/model-router) |
|
||||
| **MCP** | [python/mcp/](python/mcp/) | [📖](https://docs.praison.ai/mcp) |
|
||||
| **Memory** | [python/memory/](python/memory/) | [📖](https://docs.praison.ai/concepts/memory) |
|
||||
| **Tools** | [python/tools/](python/tools/) | [📖](https://docs.praison.ai/tools) |
|
||||
| **Code** | [python/code/](python/code/) | [📖](https://docs.praison.ai/code) |
|
||||
| **YAML** | [yaml/](yaml/) | [📖](https://docs.praison.ai/features/yaml-workflows) |
|
||||
|
||||
## Running Examples
|
||||
|
||||
```bash
|
||||
# Install PraisonAI
|
||||
pip install praisonai
|
||||
|
||||
# Set API key
|
||||
export OPENAI_API_KEY=your_key_here
|
||||
|
||||
# Run an example
|
||||
python examples/python/agents/single-agent.py
|
||||
```
|
||||
|
||||
## CLI Commands
|
||||
|
||||
See the main [README.md](../README.md#-cli--no-code-interface) for all CLI commands.
|
||||
@@ -1,30 +0,0 @@
|
||||
framework: ag2
|
||||
topic: "Research the latest developments in AI agents"
|
||||
|
||||
# Install: pip install "praisonai[ag2]"
|
||||
# Run: praisonai --framework ag2 examples/ag2/ag2_basic.yaml
|
||||
# or praisonai run examples/ag2/ag2_basic.yaml --framework ag2
|
||||
|
||||
roles:
|
||||
research_agent:
|
||||
role: "AI Research Specialist"
|
||||
goal: "Research and summarise the latest developments in AI agent frameworks"
|
||||
backstory: |
|
||||
You are an experienced AI researcher with deep knowledge of multi-agent
|
||||
systems, large language models, and the latest trends in AI tooling.
|
||||
You excel at synthesising complex technical topics into clear summaries.
|
||||
tasks:
|
||||
research_task:
|
||||
description: |
|
||||
Research and summarise the latest developments in AI agent frameworks
|
||||
for the topic: {topic}
|
||||
|
||||
Focus on:
|
||||
1. Key frameworks and their unique capabilities
|
||||
2. Recent innovations and improvements
|
||||
3. Community adoption and ecosystem growth
|
||||
4. Practical use cases and success stories
|
||||
expected_output: |
|
||||
A concise research summary covering the key developments,
|
||||
major frameworks, and practical insights. Include 3-5 bullet
|
||||
points of the most important findings.
|
||||
@@ -1,42 +0,0 @@
|
||||
framework: ag2
|
||||
topic: "Cloud-native AI deployment strategies on AWS"
|
||||
|
||||
# AG2 exclusive feature: native AWS Bedrock support via LLMConfig(api_type="bedrock")
|
||||
#
|
||||
# Prerequisites:
|
||||
# pip install "praisonai[ag2]"
|
||||
# aws configure (or set AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION)
|
||||
#
|
||||
# Run:
|
||||
# praisonai --framework ag2 examples/ag2/ag2_bedrock.yaml
|
||||
#
|
||||
# The AG2 adapter detects api_type="bedrock" from the llm config and uses
|
||||
# LLMConfig(api_type="bedrock", model=...) — no OPENAI_API_KEY required.
|
||||
# AWS credentials are sourced from boto3 (env vars, ~/.aws/credentials, IAM role).
|
||||
|
||||
roles:
|
||||
cloud_architect:
|
||||
role: "AWS Cloud Architect"
|
||||
goal: "Design and explain cloud-native AI deployment strategies on AWS"
|
||||
backstory: |
|
||||
You are an AWS Solutions Architect specialising in AI/ML workloads.
|
||||
You have deep expertise in Amazon Bedrock, SageMaker, ECS, and Lambda,
|
||||
and you help organisations deploy AI agents at scale securely and cost-effectively.
|
||||
llm:
|
||||
model: "bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0"
|
||||
api_type: "bedrock"
|
||||
aws_region: "us-east-1"
|
||||
tasks:
|
||||
architecture_task:
|
||||
description: |
|
||||
Design a cloud-native deployment strategy for AI agents on AWS for: {topic}
|
||||
|
||||
Cover:
|
||||
1. Recommended AWS services (Bedrock, ECS, Lambda, etc.)
|
||||
2. Scalability and cost optimisation patterns
|
||||
3. Security and compliance considerations
|
||||
4. A simple reference architecture overview
|
||||
expected_output: |
|
||||
A concise architecture guide with service recommendations,
|
||||
a high-level deployment diagram description, and key
|
||||
best practices for production AI agent deployments on AWS.
|
||||
@@ -1,54 +0,0 @@
|
||||
framework: ag2
|
||||
topic: "The impact of open-source AI on enterprise software development"
|
||||
|
||||
# Install: pip install "praisonai[ag2]"
|
||||
# Run: praisonai --framework ag2 examples/ag2/ag2_multi_agent.yaml
|
||||
# or praisonai run examples/ag2/ag2_multi_agent.yaml --framework ag2
|
||||
#
|
||||
# This example demonstrates AG2's GroupChat multi-agent coordination.
|
||||
# Both agents participate in a collaborative conversation managed by
|
||||
# a GroupChatManager until the task is complete.
|
||||
|
||||
roles:
|
||||
researcher:
|
||||
role: "Research Specialist"
|
||||
goal: "Gather and analyse information on the given topic"
|
||||
backstory: |
|
||||
You are a meticulous researcher who excels at finding relevant
|
||||
information, analysing trends, and presenting data-backed insights.
|
||||
You always cite your reasoning and structure your findings clearly.
|
||||
tasks:
|
||||
research_task:
|
||||
description: |
|
||||
Research the topic: {topic}
|
||||
|
||||
Investigate:
|
||||
1. Current state and adoption rates
|
||||
2. Key players and projects driving the trend
|
||||
3. Technical advantages and challenges
|
||||
4. Business impact and cost implications
|
||||
expected_output: |
|
||||
A structured research briefing with findings on the topic,
|
||||
including key data points, trends, and technical observations.
|
||||
|
||||
writer:
|
||||
role: "Technical Content Writer"
|
||||
goal: "Transform research findings into clear, engaging written content"
|
||||
backstory: |
|
||||
You are a skilled technical writer who turns complex research into
|
||||
accessible, well-structured articles. You focus on clarity, logical
|
||||
flow, and actionable takeaways for a professional audience.
|
||||
tasks:
|
||||
writing_task:
|
||||
description: |
|
||||
Using the research findings provided by the Research Specialist,
|
||||
write a concise article on: {topic}
|
||||
|
||||
The article should:
|
||||
1. Open with a compelling hook
|
||||
2. Present key findings logically
|
||||
3. Include practical implications for developers
|
||||
4. Close with a forward-looking conclusion
|
||||
expected_output: |
|
||||
A 400-500 word article suitable for a technical blog,
|
||||
with clear sections, professional tone, and concrete takeaways.
|
||||
@@ -0,0 +1,35 @@
|
||||
"""
|
||||
Async Runs Examples
|
||||
===================
|
||||
|
||||
This directory contains examples for the PraisonAI Async Jobs API.
|
||||
|
||||
Examples:
|
||||
---------
|
||||
1. sdk_submit_poll_result.py - Python SDK example for submit/poll/result
|
||||
2. cli_submit_poll_result.sh - Bash/curl example for submit/poll/result
|
||||
3. idempotency.sh - Demonstrates idempotency key usage
|
||||
4. cancel.sh - Demonstrates job cancellation
|
||||
5. sse_stream.sh - Demonstrates SSE streaming
|
||||
|
||||
Prerequisites:
|
||||
--------------
|
||||
1. Set OPENAI_API_KEY environment variable
|
||||
2. Start the jobs server:
|
||||
|
||||
cd /path/to/praisonai-package/src/praisonai
|
||||
python -m uvicorn praisonai.jobs.server:create_app --port 8005 --factory
|
||||
|
||||
3. Run examples:
|
||||
|
||||
python sdk_submit_poll_result.py
|
||||
bash cli_submit_poll_result.sh
|
||||
bash idempotency.sh
|
||||
bash cancel.sh
|
||||
bash sse_stream.sh
|
||||
|
||||
Environment Variables:
|
||||
----------------------
|
||||
- OPENAI_API_KEY: Required for agent execution
|
||||
- PRAISONAI_BASE_URL: API server URL (default: http://127.0.0.1:8005)
|
||||
"""
|
||||
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
# CLI Example: Cancel a Running Job
|
||||
#
|
||||
# This example demonstrates how to cancel a running job.
|
||||
#
|
||||
# Requirements:
|
||||
# - Jobs server running on http://127.0.0.1:8005
|
||||
#
|
||||
# Usage:
|
||||
# bash cancel.sh
|
||||
|
||||
set -e
|
||||
|
||||
API_URL="${PRAISONAI_BASE_URL:-http://127.0.0.1:8005}"
|
||||
|
||||
echo "============================================================"
|
||||
echo "PraisonAI Job Cancellation Example"
|
||||
echo "============================================================"
|
||||
|
||||
# Submit a long-running job
|
||||
echo ""
|
||||
echo "1. Submitting a job..."
|
||||
RESPONSE=$(curl -s -X POST "$API_URL/api/v1/runs" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"prompt": "Write a detailed essay about the history of computing."}')
|
||||
|
||||
JOB_ID=$(echo "$RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin)['job_id'])")
|
||||
echo " Job ID: $JOB_ID"
|
||||
|
||||
# Wait briefly
|
||||
echo ""
|
||||
echo "2. Waiting 1 second..."
|
||||
sleep 1
|
||||
|
||||
# Cancel the job
|
||||
echo ""
|
||||
echo "3. Cancelling job..."
|
||||
CANCEL_RESPONSE=$(curl -s -X POST "$API_URL/api/v1/runs/$JOB_ID/cancel")
|
||||
STATUS=$(echo "$CANCEL_RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin)['status'])")
|
||||
echo " Status after cancel: $STATUS"
|
||||
|
||||
# Verify cancellation
|
||||
echo ""
|
||||
echo "4. Verification:"
|
||||
if [ "$STATUS" = "cancelled" ]; then
|
||||
echo " ✓ SUCCESS: Job was cancelled"
|
||||
else
|
||||
echo " ℹ Job status: $STATUS (may have completed before cancel)"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "============================================================"
|
||||
echo "Cancellation example completed!"
|
||||
echo "============================================================"
|
||||
@@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
# CLI Example: Submit, Poll, and Get Result for Async Jobs
|
||||
#
|
||||
# This example demonstrates how to use the PraisonAI CLI to:
|
||||
# 1. Submit an async job
|
||||
# 2. Check job status
|
||||
# 3. Get the result
|
||||
#
|
||||
# Requirements:
|
||||
# - OPENAI_API_KEY environment variable set
|
||||
# - Jobs server running on http://127.0.0.1:8005
|
||||
#
|
||||
# Usage:
|
||||
# bash cli_submit_poll_result.sh
|
||||
|
||||
set -e
|
||||
|
||||
API_URL="${PRAISONAI_BASE_URL:-http://127.0.0.1:8005}"
|
||||
|
||||
echo "============================================================"
|
||||
echo "PraisonAI Async Jobs CLI Example"
|
||||
echo "============================================================"
|
||||
|
||||
# Check if server is running
|
||||
echo ""
|
||||
echo "Checking server health..."
|
||||
if ! curl -s "$API_URL/health" > /dev/null 2>&1; then
|
||||
echo "✗ Server not available at $API_URL"
|
||||
echo " Start the server with: python -m uvicorn praisonai.jobs.server:create_app --port 8005 --factory"
|
||||
exit 1
|
||||
fi
|
||||
echo "✓ Server is healthy"
|
||||
|
||||
# 1. Submit a job
|
||||
echo ""
|
||||
echo "1. Submitting job..."
|
||||
RESPONSE=$(curl -s -X POST "$API_URL/api/v1/runs" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"prompt": "What is 2+2? Answer with just the number."}')
|
||||
|
||||
JOB_ID=$(echo "$RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin)['job_id'])")
|
||||
echo " Job ID: $JOB_ID"
|
||||
|
||||
# 2. Poll for status
|
||||
echo ""
|
||||
echo "2. Polling for status..."
|
||||
while true; do
|
||||
STATUS_RESPONSE=$(curl -s "$API_URL/api/v1/runs/$JOB_ID")
|
||||
STATUS=$(echo "$STATUS_RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin)['status'])")
|
||||
PROGRESS=$(echo "$STATUS_RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin)['progress']['percentage'])")
|
||||
|
||||
echo " Status: $STATUS | Progress: ${PROGRESS}%"
|
||||
|
||||
if [ "$STATUS" = "succeeded" ] || [ "$STATUS" = "failed" ] || [ "$STATUS" = "cancelled" ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# 3. Get result
|
||||
echo ""
|
||||
echo "3. Getting result..."
|
||||
if [ "$STATUS" = "succeeded" ]; then
|
||||
RESULT=$(curl -s "$API_URL/api/v1/runs/$JOB_ID/result")
|
||||
echo " Result: $(echo "$RESULT" | python3 -c "import sys,json; print(json.load(sys.stdin)['result'])")"
|
||||
echo " Duration: $(echo "$RESULT" | python3 -c "import sys,json; print(f\"{json.load(sys.stdin)['duration_seconds']:.2f}s\")")"
|
||||
else
|
||||
echo " Job did not succeed: $STATUS"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "============================================================"
|
||||
echo "Example completed!"
|
||||
echo "============================================================"
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
# CLI Example: Idempotency Key Usage
|
||||
#
|
||||
# This example demonstrates how idempotency keys prevent duplicate job submissions.
|
||||
# Submitting the same request with the same idempotency key returns the existing job.
|
||||
#
|
||||
# Requirements:
|
||||
# - Jobs server running on http://127.0.0.1:8005
|
||||
#
|
||||
# Usage:
|
||||
# bash idempotency.sh
|
||||
|
||||
set -e
|
||||
|
||||
API_URL="${PRAISONAI_BASE_URL:-http://127.0.0.1:8005}"
|
||||
IDEM_KEY="example-idem-key-$(date +%s)"
|
||||
|
||||
echo "============================================================"
|
||||
echo "PraisonAI Idempotency Key Example"
|
||||
echo "============================================================"
|
||||
|
||||
# First submission
|
||||
echo ""
|
||||
echo "1. First submission with Idempotency-Key: $IDEM_KEY"
|
||||
RESPONSE1=$(curl -s -X POST "$API_URL/api/v1/runs" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Idempotency-Key: $IDEM_KEY" \
|
||||
-d '{"prompt": "What is 1+1?"}')
|
||||
|
||||
JOB_ID1=$(echo "$RESPONSE1" | python3 -c "import sys,json; print(json.load(sys.stdin)['job_id'])")
|
||||
echo " Job ID: $JOB_ID1"
|
||||
|
||||
# Second submission with same key
|
||||
echo ""
|
||||
echo "2. Second submission with SAME Idempotency-Key: $IDEM_KEY"
|
||||
RESPONSE2=$(curl -s -X POST "$API_URL/api/v1/runs" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Idempotency-Key: $IDEM_KEY" \
|
||||
-d '{"prompt": "Different prompt but same key"}')
|
||||
|
||||
JOB_ID2=$(echo "$RESPONSE2" | python3 -c "import sys,json; print(json.load(sys.stdin)['job_id'])")
|
||||
echo " Job ID: $JOB_ID2"
|
||||
|
||||
# Verify same job ID
|
||||
echo ""
|
||||
echo "3. Verification:"
|
||||
if [ "$JOB_ID1" = "$JOB_ID2" ]; then
|
||||
echo " ✓ SUCCESS: Same job ID returned (no duplicate created)"
|
||||
else
|
||||
echo " ✗ FAILURE: Different job IDs returned"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "============================================================"
|
||||
echo "Idempotency example completed!"
|
||||
echo "============================================================"
|
||||
@@ -0,0 +1,121 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
SDK Example: Submit, Poll, and Get Result for Async Jobs
|
||||
|
||||
This example demonstrates how to use the PraisonAI Jobs SDK to:
|
||||
1. Submit an async job
|
||||
2. Poll for status
|
||||
3. Get the result
|
||||
|
||||
Requirements:
|
||||
- OPENAI_API_KEY environment variable set
|
||||
- Jobs server running on http://127.0.0.1:8005
|
||||
|
||||
Usage:
|
||||
python sdk_submit_poll_result.py
|
||||
"""
|
||||
|
||||
import os
|
||||
import time
|
||||
import httpx
|
||||
|
||||
# Configuration
|
||||
API_URL = os.getenv("PRAISONAI_BASE_URL", "http://127.0.0.1:8005")
|
||||
POLL_INTERVAL = 2 # seconds
|
||||
|
||||
|
||||
def submit_job(prompt: str, idempotency_key: str = None) -> dict:
|
||||
"""Submit a job and return the response."""
|
||||
headers = {}
|
||||
if idempotency_key:
|
||||
headers["Idempotency-Key"] = idempotency_key
|
||||
|
||||
with httpx.Client(timeout=30.0) as client:
|
||||
response = client.post(
|
||||
f"{API_URL}/api/v1/runs",
|
||||
json={"prompt": prompt},
|
||||
headers=headers if headers else None
|
||||
)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
|
||||
|
||||
def get_status(job_id: str) -> dict:
|
||||
"""Get job status."""
|
||||
with httpx.Client(timeout=30.0) as client:
|
||||
response = client.get(f"{API_URL}/api/v1/runs/{job_id}")
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
|
||||
|
||||
def get_result(job_id: str) -> dict:
|
||||
"""Get job result."""
|
||||
with httpx.Client(timeout=30.0) as client:
|
||||
response = client.get(f"{API_URL}/api/v1/runs/{job_id}/result")
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
|
||||
|
||||
def wait_for_completion(job_id: str, max_wait: int = 120) -> dict:
|
||||
"""Poll until job completes."""
|
||||
start = time.time()
|
||||
while time.time() - start < max_wait:
|
||||
status = get_status(job_id)
|
||||
print(f" Status: {status['status']} | Progress: {status['progress']['percentage']:.0f}%")
|
||||
|
||||
if status["status"] in ("succeeded", "failed", "cancelled"):
|
||||
return status
|
||||
|
||||
# Honor retry_after if present
|
||||
wait_time = status.get("retry_after") or POLL_INTERVAL
|
||||
time.sleep(wait_time)
|
||||
|
||||
raise TimeoutError(f"Job {job_id} did not complete within {max_wait}s")
|
||||
|
||||
|
||||
def main():
|
||||
print("=" * 60)
|
||||
print("PraisonAI Async Jobs SDK Example")
|
||||
print("=" * 60)
|
||||
|
||||
# Check if server is running
|
||||
try:
|
||||
with httpx.Client(timeout=5.0) as client:
|
||||
health = client.get(f"{API_URL}/health")
|
||||
health.raise_for_status()
|
||||
print(f"✓ Server healthy: {health.json()['status']}")
|
||||
except Exception as e:
|
||||
print(f"✗ Server not available at {API_URL}: {e}")
|
||||
print(" Start the server with: python -m uvicorn praisonai.jobs.server:create_app --port 8005 --factory")
|
||||
return
|
||||
|
||||
# 1. Submit a job
|
||||
print("\n1. Submitting job...")
|
||||
prompt = "What is the capital of France? Answer in one word."
|
||||
result = submit_job(prompt)
|
||||
job_id = result["job_id"]
|
||||
print(f" Job ID: {job_id}")
|
||||
print(f" Status: {result['status']}")
|
||||
print(f" Poll URL: {result['poll_url']}")
|
||||
|
||||
# 2. Wait for completion
|
||||
print("\n2. Waiting for completion...")
|
||||
final_status = wait_for_completion(job_id)
|
||||
print(f" Final status: {final_status['status']}")
|
||||
|
||||
# 3. Get result
|
||||
if final_status["status"] == "succeeded":
|
||||
print("\n3. Getting result...")
|
||||
result = get_result(job_id)
|
||||
print(f" Result: {result['result']}")
|
||||
print(f" Duration: {result['duration_seconds']:.2f}s")
|
||||
else:
|
||||
print(f"\n3. Job did not succeed: {final_status.get('error', 'Unknown error')}")
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("Example completed successfully!")
|
||||
print("=" * 60)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
# CLI Example: SSE Streaming
|
||||
#
|
||||
# This example demonstrates how to stream job progress via Server-Sent Events.
|
||||
#
|
||||
# Requirements:
|
||||
# - Jobs server running on http://127.0.0.1:8005
|
||||
#
|
||||
# Usage:
|
||||
# bash sse_stream.sh
|
||||
|
||||
set -e
|
||||
|
||||
API_URL="${PRAISONAI_BASE_URL:-http://127.0.0.1:8005}"
|
||||
|
||||
echo "============================================================"
|
||||
echo "PraisonAI SSE Streaming Example"
|
||||
echo "============================================================"
|
||||
|
||||
# Submit a job
|
||||
echo ""
|
||||
echo "1. Submitting job..."
|
||||
RESPONSE=$(curl -s -X POST "$API_URL/api/v1/runs" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"prompt": "Count from 1 to 5."}')
|
||||
|
||||
JOB_ID=$(echo "$RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin)['job_id'])")
|
||||
echo " Job ID: $JOB_ID"
|
||||
|
||||
# Stream progress
|
||||
echo ""
|
||||
echo "2. Streaming progress (Ctrl+C to stop)..."
|
||||
echo " Connecting to: $API_URL/api/v1/runs/$JOB_ID/stream"
|
||||
echo ""
|
||||
|
||||
# Use curl to stream SSE events (timeout after 60s)
|
||||
curl -s -N --max-time 60 "$API_URL/api/v1/runs/$JOB_ID/stream" | while read -r line; do
|
||||
if [[ "$line" == data:* ]]; then
|
||||
data="${line#data: }"
|
||||
if [ "$data" = "[DONE]" ]; then
|
||||
echo " Stream completed"
|
||||
break
|
||||
fi
|
||||
echo " Event: $data"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "============================================================"
|
||||
echo "Streaming example completed!"
|
||||
echo "============================================================"
|
||||
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Basic Background Tasks Example for PraisonAI Agents.
|
||||
|
||||
This example demonstrates how to use the background task system to:
|
||||
1. Run tasks asynchronously
|
||||
2. Track task progress
|
||||
3. Cancel running tasks
|
||||
4. Handle task completion
|
||||
|
||||
Usage:
|
||||
python basic_background.py
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import time
|
||||
|
||||
from praisonaiagents.background import BackgroundRunner, BackgroundConfig, TaskStatus
|
||||
|
||||
|
||||
async def main():
|
||||
print("=" * 60)
|
||||
print("Background Tasks Demo")
|
||||
print("=" * 60)
|
||||
|
||||
# Create a background runner with config
|
||||
config = BackgroundConfig(max_concurrent_tasks=3)
|
||||
runner = BackgroundRunner(config=config)
|
||||
|
||||
# Define some example tasks
|
||||
def slow_task(duration: float, name: str) -> str:
|
||||
"""A slow task that simulates work."""
|
||||
print(f" 🔄 Task '{name}' starting (will take {duration}s)")
|
||||
time.sleep(duration)
|
||||
return f"Task '{name}' completed after {duration}s"
|
||||
|
||||
async def async_task(duration: float, name: str) -> str:
|
||||
"""An async task that simulates work."""
|
||||
print(f" 🔄 Async task '{name}' starting (will take {duration}s)")
|
||||
await asyncio.sleep(duration)
|
||||
return f"Async task '{name}' completed after {duration}s"
|
||||
|
||||
# Submit tasks
|
||||
print("\n--- Submitting Tasks ---")
|
||||
|
||||
task1 = await runner.submit(slow_task, args=(1.0, "quick-job"), name="task1")
|
||||
print(f"✅ Submitted task 1: {task1.id[:8]}")
|
||||
|
||||
task2 = await runner.submit(slow_task, args=(2.0, "medium-job"), name="task2")
|
||||
print(f"✅ Submitted task 2: {task2.id[:8]}")
|
||||
|
||||
task3 = await runner.submit(async_task, args=(1.5, "async-job"), name="task3")
|
||||
print(f"✅ Submitted async task 3: {task3.id[:8]}")
|
||||
|
||||
# List all tasks
|
||||
print("\n--- Task Status ---")
|
||||
for task in runner.tasks:
|
||||
print(f" [{task.id[:8]}] {task.status.value}")
|
||||
|
||||
# Wait for task 1 to complete
|
||||
print("\n--- Waiting for Task 1 ---")
|
||||
await task1.wait(timeout=5.0)
|
||||
print(f"✅ Task 1 result: {task1.result}")
|
||||
|
||||
# Check status of all tasks
|
||||
print("\n--- Updated Task Status ---")
|
||||
for task in [task1, task2, task3]:
|
||||
status = "✅" if task.status == TaskStatus.COMPLETED else "🔄"
|
||||
print(f" {status} [{task.id[:8]}] {task.status.value}")
|
||||
|
||||
# Wait for all remaining tasks
|
||||
print("\n--- Waiting for All Tasks ---")
|
||||
await task2.wait(timeout=10.0)
|
||||
await task3.wait(timeout=10.0)
|
||||
|
||||
# Final status
|
||||
print("\n--- Final Results ---")
|
||||
for task in [task1, task2, task3]:
|
||||
if task.result:
|
||||
print(f" ✅ {task.result}")
|
||||
|
||||
# Cleanup
|
||||
runner.clear_completed()
|
||||
print("\n✅ Cleared completed tasks")
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("Demo Complete!")
|
||||
print("=" * 60)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -0,0 +1,110 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Basic Checkpoints Example for PraisonAI Agents.
|
||||
|
||||
This example demonstrates how to use the shadow git checkpointing system to:
|
||||
1. Save checkpoints before making changes
|
||||
2. List available checkpoints
|
||||
3. View diffs between checkpoints
|
||||
4. Restore to a previous checkpoint
|
||||
|
||||
Usage:
|
||||
python basic_checkpoints.py
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
from praisonaiagents.checkpoints import CheckpointService
|
||||
|
||||
|
||||
async def main():
|
||||
# Create a temporary workspace for demonstration
|
||||
with tempfile.TemporaryDirectory() as workspace:
|
||||
print("=" * 60)
|
||||
print("Shadow Git Checkpointing Demo")
|
||||
print("=" * 60)
|
||||
print(f"\nWorkspace: {workspace}")
|
||||
|
||||
# Create some initial files
|
||||
test_file = Path(workspace) / "example.py"
|
||||
test_file.write_text("# Initial content\nprint('Hello, World!')\n")
|
||||
print(f"\n✅ Created initial file: {test_file.name}")
|
||||
|
||||
# Initialize the checkpoint service
|
||||
service = CheckpointService(workspace_dir=workspace)
|
||||
|
||||
try:
|
||||
# Initialize the shadow git repository
|
||||
print("\n--- Initializing Checkpoint Service ---")
|
||||
await service.initialize()
|
||||
print("✅ Shadow git repository initialized")
|
||||
|
||||
# Save first checkpoint
|
||||
print("\n--- Saving Checkpoint 1: Initial State ---")
|
||||
result1 = await service.save("Initial state")
|
||||
print(f"✅ Checkpoint saved: {result1.checkpoint.id[:8]}")
|
||||
print(f" Message: {result1.checkpoint.message}")
|
||||
|
||||
# Make some changes
|
||||
print("\n--- Making Changes ---")
|
||||
test_file.write_text("# Modified content\nprint('Hello, PraisonAI!')\nprint('Checkpoints are awesome!')\n")
|
||||
print("✅ Modified example.py")
|
||||
|
||||
# Create a new file
|
||||
new_file = Path(workspace) / "utils.py"
|
||||
new_file.write_text("def helper():\n return 'I help!'\n")
|
||||
print("✅ Created utils.py")
|
||||
|
||||
# Save second checkpoint
|
||||
print("\n--- Saving Checkpoint 2: After Changes ---")
|
||||
result2 = await service.save("Added features")
|
||||
print(f"✅ Checkpoint saved: {result2.checkpoint.id[:8]}")
|
||||
|
||||
# List all checkpoints
|
||||
print("\n--- Listing All Checkpoints ---")
|
||||
checkpoints = await service.list_checkpoints()
|
||||
for i, cp in enumerate(checkpoints, 1):
|
||||
print(f" {i}. [{cp.id[:8]}] {cp.message} ({cp.timestamp})")
|
||||
|
||||
# Show diff
|
||||
print("\n--- Current Diff (uncommitted changes) ---")
|
||||
diff = await service.diff()
|
||||
if diff.files:
|
||||
for f in diff.files:
|
||||
print(f" {f.status}: {f.path}")
|
||||
else:
|
||||
print(" No uncommitted changes")
|
||||
|
||||
# Make more changes to show diff
|
||||
test_file.write_text("# Even more changes\nprint('This will be reverted')\n")
|
||||
print("\n✅ Made more changes to example.py")
|
||||
|
||||
diff = await service.diff()
|
||||
print("\n--- New Diff ---")
|
||||
if diff.files:
|
||||
for f in diff.files:
|
||||
print(f" {f.status}: {f.path}")
|
||||
|
||||
# Restore to checkpoint 2
|
||||
print(f"\n--- Restoring to Checkpoint: {result2.checkpoint.id[:8]} ---")
|
||||
await service.restore(result2.checkpoint.id)
|
||||
print("✅ Restored successfully!")
|
||||
|
||||
# Verify restoration
|
||||
content = test_file.read_text()
|
||||
print(f"\n--- Verified Content After Restore ---")
|
||||
print(content)
|
||||
|
||||
except Exception as e:
|
||||
print(f"\n❌ Error: {e}")
|
||||
raise
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("Demo Complete!")
|
||||
print("=" * 60)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -0,0 +1,93 @@
|
||||
# Persistence CLI Commands
|
||||
|
||||
## Quick Reference
|
||||
|
||||
```bash
|
||||
# Check database connectivity
|
||||
praisonai persistence doctor \
|
||||
--conversation-url postgresql://localhost:5432/praisonai \
|
||||
--state-url redis://localhost:6379
|
||||
|
||||
# Run agent with persistence
|
||||
praisonai persistence run \
|
||||
--conversation-url postgresql://localhost:5432/praisonai \
|
||||
--session-id my-session
|
||||
|
||||
# Resume a session
|
||||
praisonai persistence resume \
|
||||
--conversation-url postgresql://localhost:5432/praisonai \
|
||||
--session-id my-session
|
||||
|
||||
# Export session to file
|
||||
praisonai persistence export \
|
||||
--conversation-url postgresql://localhost:5432/praisonai \
|
||||
--session-id my-session \
|
||||
--output session_backup.jsonl
|
||||
|
||||
# Import session from file
|
||||
praisonai persistence import \
|
||||
--conversation-url postgresql://localhost:5432/praisonai \
|
||||
--file session_backup.jsonl
|
||||
|
||||
# Check schema status
|
||||
praisonai persistence status \
|
||||
--conversation-url postgresql://localhost:5432/praisonai \
|
||||
--state-url redis://localhost:6379
|
||||
|
||||
# Apply migrations
|
||||
praisonai persistence migrate \
|
||||
--conversation-url postgresql://localhost:5432/praisonai \
|
||||
--state-url redis://localhost:6379
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Instead of CLI flags, you can use environment variables:
|
||||
|
||||
```bash
|
||||
export PRAISON_CONVERSATION_URL=postgresql://localhost:5432/praisonai
|
||||
export PRAISON_STATE_URL=redis://localhost:6379
|
||||
export PRAISON_KNOWLEDGE_URL=http://localhost:6333
|
||||
|
||||
# Then run without URL flags
|
||||
praisonai persistence doctor
|
||||
praisonai persistence status
|
||||
```
|
||||
|
||||
## Docker Setup
|
||||
|
||||
```bash
|
||||
# Start all services
|
||||
docker run -d --name praison-postgres \
|
||||
-e POSTGRES_PASSWORD=praison123 \
|
||||
-e POSTGRES_DB=praisonai \
|
||||
-p 5432:5432 postgres:16
|
||||
|
||||
docker run -d --name praison-redis \
|
||||
-p 6379:6379 redis:7
|
||||
|
||||
docker run -d --name praison-qdrant \
|
||||
-p 6333:6333 -p 6334:6334 qdrant/qdrant
|
||||
|
||||
# Verify
|
||||
docker ps
|
||||
```
|
||||
|
||||
## Example Workflow
|
||||
|
||||
```bash
|
||||
# 1. Start services
|
||||
docker-compose up -d
|
||||
|
||||
# 2. Check connectivity
|
||||
praisonai persistence doctor
|
||||
|
||||
# 3. Run agent
|
||||
praisonai persistence run --session-id demo-session
|
||||
|
||||
# 4. Export for backup
|
||||
praisonai persistence export --session-id demo-session --output backup.jsonl
|
||||
|
||||
# 5. Import to another environment
|
||||
praisonai persistence import --file backup.jsonl
|
||||
```
|
||||
@@ -0,0 +1,124 @@
|
||||
# PraisonAI Persistence CLI - End-to-End Guide
|
||||
|
||||
This guide demonstrates the CLI commands for database persistence.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
```bash
|
||||
pip install "praisonai[tools]"
|
||||
|
||||
# Start Docker containers
|
||||
docker run -d --name praison-postgres -p 5432:5432 \
|
||||
-e POSTGRES_PASSWORD=praison123 \
|
||||
-e POSTGRES_DB=praisonai \
|
||||
postgres:16
|
||||
|
||||
docker run -d --name praison-qdrant -p 6333:6333 qdrant/qdrant
|
||||
docker run -d --name praison-redis -p 6379:6379 redis:7
|
||||
```
|
||||
|
||||
## 1. Doctor Command - Validate Connectivity
|
||||
|
||||
```bash
|
||||
# Check all stores
|
||||
praisonai persistence doctor \
|
||||
--conversation-url "postgresql://postgres:praison123@localhost:5432/praisonai" \
|
||||
--knowledge-url "http://localhost:6333" \
|
||||
--state-url "redis://localhost:6379"
|
||||
```
|
||||
|
||||
**Expected Output:**
|
||||
```
|
||||
==================================================
|
||||
PraisonAI Persistence Doctor
|
||||
==================================================
|
||||
|
||||
[Conversation Store] Testing: postgresql://postgres:****@localhost:5432/praisonai
|
||||
✅ Connected (postgres)
|
||||
|
||||
[Knowledge Store] Testing: http://localhost:6333
|
||||
✅ Connected (qdrant)
|
||||
|
||||
[State Store] Testing: redis://localhost:6379
|
||||
✅ Connected (redis)
|
||||
|
||||
==================================================
|
||||
Results: 3/3 stores connected successfully
|
||||
==================================================
|
||||
```
|
||||
|
||||
## 2. Run Command - Execute Agent with Persistence
|
||||
|
||||
```bash
|
||||
# Run agent with persistence (dry-run first)
|
||||
praisonai persistence run \
|
||||
--session-id "cli-demo-001" \
|
||||
--conversation-url "postgresql://postgres:praison123@localhost:5432/praisonai" \
|
||||
--dry-run \
|
||||
"Hello, my name is Bob"
|
||||
|
||||
# Actually run it
|
||||
praisonai persistence run \
|
||||
--session-id "cli-demo-001" \
|
||||
--conversation-url "postgresql://postgres:praison123@localhost:5432/praisonai" \
|
||||
"Hello, my name is Bob"
|
||||
```
|
||||
|
||||
**Expected Output:**
|
||||
```
|
||||
[Session: cli-demo-001]
|
||||
Agent: Hello Bob! Nice to meet you. How can I help you today?
|
||||
```
|
||||
|
||||
## 3. Resume Command - Continue a Session
|
||||
|
||||
```bash
|
||||
# Show history
|
||||
praisonai persistence resume \
|
||||
--session-id "cli-demo-001" \
|
||||
--conversation-url "postgresql://postgres:praison123@localhost:5432/praisonai" \
|
||||
--show-history
|
||||
|
||||
# Continue conversation
|
||||
praisonai persistence resume \
|
||||
--session-id "cli-demo-001" \
|
||||
--conversation-url "postgresql://postgres:praison123@localhost:5432/praisonai" \
|
||||
--continue "What's my name?"
|
||||
```
|
||||
|
||||
**Expected Output:**
|
||||
```
|
||||
[Session: cli-demo-001]
|
||||
Messages in history: 2
|
||||
|
||||
--- Conversation History ---
|
||||
[USER] Hello, my name is Bob
|
||||
[ASSISTANT] Hello Bob! Nice to meet you...
|
||||
--- End History ---
|
||||
|
||||
Agent: Your name is Bob!
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Instead of passing URLs on command line, use environment variables:
|
||||
|
||||
```bash
|
||||
export PRAISON_CONVERSATION_URL="postgresql://postgres:praison123@localhost:5432/praisonai"
|
||||
export PRAISON_KNOWLEDGE_URL="http://localhost:6333"
|
||||
export PRAISON_STATE_URL="redis://localhost:6379"
|
||||
export OPENAI_API_KEY="your-key"
|
||||
|
||||
# Now commands are simpler
|
||||
praisonai persistence doctor --all
|
||||
praisonai persistence run --session-id "my-session" "Hello!"
|
||||
```
|
||||
|
||||
## Full CLI Reference
|
||||
|
||||
```
|
||||
praisonai persistence --help
|
||||
praisonai persistence doctor --help
|
||||
praisonai persistence run --help
|
||||
praisonai persistence resume --help
|
||||
```
|
||||
@@ -0,0 +1,146 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Basic Context Compaction Example for PraisonAI Agents.
|
||||
|
||||
This example demonstrates how to use context compaction to:
|
||||
1. Manage conversation context length
|
||||
2. Use different compaction strategies
|
||||
3. Track compaction results
|
||||
4. Preserve important messages
|
||||
|
||||
Usage:
|
||||
python basic_compaction.py
|
||||
"""
|
||||
|
||||
from praisonaiagents.compaction import (
|
||||
ContextCompactor, CompactionConfig, CompactionStrategy, CompactionResult
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
print("=" * 60)
|
||||
print("Context Compaction Demo")
|
||||
print("=" * 60)
|
||||
|
||||
# ==========================================================================
|
||||
# Sample Messages
|
||||
# ==========================================================================
|
||||
messages = [
|
||||
{"role": "system", "content": "You are a helpful AI assistant."},
|
||||
{"role": "user", "content": "Hello! Can you help me with Python?"},
|
||||
{"role": "assistant", "content": "Of course! I'd be happy to help you with Python. What would you like to know?"},
|
||||
{"role": "user", "content": "How do I read a file in Python?"},
|
||||
{"role": "assistant", "content": "To read a file in Python, you can use the built-in open() function. Here's an example:\n\nwith open('filename.txt', 'r') as f:\n content = f.read()\n\nThis opens the file, reads its content, and automatically closes it."},
|
||||
{"role": "user", "content": "What about writing to a file?"},
|
||||
{"role": "assistant", "content": "To write to a file, use the 'w' mode:\n\nwith open('filename.txt', 'w') as f:\n f.write('Hello, World!')\n\nUse 'a' mode to append instead of overwriting."},
|
||||
{"role": "user", "content": "Can you explain list comprehensions?"},
|
||||
{"role": "assistant", "content": "List comprehensions are a concise way to create lists. Instead of:\n\nresult = []\nfor x in range(10):\n result.append(x * 2)\n\nYou can write:\n\nresult = [x * 2 for x in range(10)]"},
|
||||
]
|
||||
|
||||
print(f"\n--- Original Messages ---")
|
||||
print(f" Message count: {len(messages)}")
|
||||
|
||||
# ==========================================================================
|
||||
# Basic Compaction
|
||||
# ==========================================================================
|
||||
print("\n--- Basic Compaction (Truncate Strategy) ---")
|
||||
|
||||
compactor = ContextCompactor(
|
||||
max_tokens=50, # Low limit to trigger compaction
|
||||
strategy=CompactionStrategy.TRUNCATE,
|
||||
preserve_system=True,
|
||||
preserve_recent=2
|
||||
)
|
||||
|
||||
# Check stats before
|
||||
stats = compactor.get_stats(messages)
|
||||
print(f" Total tokens: {stats['total_tokens']}")
|
||||
print(f" Max tokens: {stats['max_tokens']}")
|
||||
print(f" Needs compaction: {stats['needs_compaction']}")
|
||||
|
||||
# Compact
|
||||
compacted, result = compactor.compact(messages)
|
||||
|
||||
print(f"\n After compaction:")
|
||||
print(f" Messages: {len(messages)} -> {len(compacted)}")
|
||||
print(f" Tokens: {result.original_tokens} -> {result.compacted_tokens}")
|
||||
print(f" Saved: {result.tokens_saved} tokens")
|
||||
print(f" Compression: {result.compression_ratio:.1%}")
|
||||
|
||||
# ==========================================================================
|
||||
# Sliding Window Strategy
|
||||
# ==========================================================================
|
||||
print("\n--- Sliding Window Strategy ---")
|
||||
|
||||
compactor = ContextCompactor(
|
||||
max_tokens=50,
|
||||
strategy=CompactionStrategy.SLIDING,
|
||||
preserve_system=True,
|
||||
preserve_recent=3
|
||||
)
|
||||
|
||||
compacted, result = compactor.compact(messages)
|
||||
|
||||
print(f" Messages kept: {result.messages_kept}")
|
||||
print(f" Messages removed: {result.messages_removed}")
|
||||
print(f" Strategy: {result.strategy_used.value}")
|
||||
|
||||
# ==========================================================================
|
||||
# Summarize Strategy
|
||||
# ==========================================================================
|
||||
print("\n--- Summarize Strategy ---")
|
||||
|
||||
compactor = ContextCompactor(
|
||||
max_tokens=50,
|
||||
strategy=CompactionStrategy.SUMMARIZE,
|
||||
preserve_system=True,
|
||||
preserve_recent=2
|
||||
)
|
||||
|
||||
compacted, result = compactor.compact(messages)
|
||||
|
||||
print(f" Messages kept: {result.messages_kept}")
|
||||
print(f" Strategy: {result.strategy_used.value}")
|
||||
|
||||
# Show what messages remain
|
||||
print(f"\n Remaining message roles:")
|
||||
for msg in compacted:
|
||||
role = msg.get("role", "unknown")
|
||||
content_preview = msg.get("content", "")[:50]
|
||||
print(f" [{role}] {content_preview}...")
|
||||
|
||||
# ==========================================================================
|
||||
# No Compaction Needed
|
||||
# ==========================================================================
|
||||
print("\n--- No Compaction Needed ---")
|
||||
|
||||
compactor = ContextCompactor(
|
||||
max_tokens=10000, # High limit
|
||||
strategy=CompactionStrategy.TRUNCATE
|
||||
)
|
||||
|
||||
compacted, result = compactor.compact(messages)
|
||||
|
||||
print(f" Was compacted: {result.was_compacted}")
|
||||
print(f" Messages unchanged: {len(compacted) == len(messages)}")
|
||||
|
||||
# ==========================================================================
|
||||
# Result Serialization
|
||||
# ==========================================================================
|
||||
print("\n--- Result Serialization ---")
|
||||
|
||||
compactor = ContextCompactor(max_tokens=50)
|
||||
_, result = compactor.compact(messages)
|
||||
|
||||
data = result.to_dict()
|
||||
print(f" Original tokens: {data['original_tokens']}")
|
||||
print(f" Compacted tokens: {data['compacted_tokens']}")
|
||||
print(f" Compression ratio: {data['compression_ratio']:.2f}")
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("Demo Complete!")
|
||||
print("=" * 60)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,85 @@
|
||||
"""
|
||||
CLI Compare Example - Advanced Usage
|
||||
|
||||
This example demonstrates advanced comparison features including
|
||||
custom mode configurations and result analysis.
|
||||
"""
|
||||
|
||||
from praisonai.cli.features.compare import (
|
||||
CompareHandler,
|
||||
CompareResult,
|
||||
ModeResult,
|
||||
get_mode_config,
|
||||
save_compare_result,
|
||||
format_comparison_table,
|
||||
)
|
||||
|
||||
# Create custom mode configurations
|
||||
custom_modes = {
|
||||
"fast": {"llm": "gpt-4o-mini"},
|
||||
"accurate": {"llm": "gpt-4o", "planning": True},
|
||||
"research": {"research": True, "web_search": True},
|
||||
}
|
||||
|
||||
# Create handler with verbose output
|
||||
handler = CompareHandler(verbose=True)
|
||||
|
||||
# Example: Manually create comparison results for analysis
|
||||
# (useful for testing without API calls)
|
||||
mock_result = CompareResult(
|
||||
query="What are the latest AI trends?",
|
||||
comparisons=[
|
||||
ModeResult(
|
||||
mode="basic",
|
||||
output="AI trends include LLMs, multimodal models, and agents.",
|
||||
execution_time_ms=1234.5,
|
||||
model_used="gpt-4o-mini",
|
||||
tools_used=[]
|
||||
),
|
||||
ModeResult(
|
||||
mode="tools",
|
||||
output="Based on recent search results, AI trends in 2024 include...",
|
||||
execution_time_ms=2567.8,
|
||||
model_used="gpt-4o-mini",
|
||||
tools_used=["internet_search"]
|
||||
),
|
||||
ModeResult(
|
||||
mode="research",
|
||||
output="Comprehensive research shows that AI trends...",
|
||||
execution_time_ms=5432.1,
|
||||
model_used="gpt-4o-mini",
|
||||
tools_used=["internet_search", "web_scraper"]
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
# Get summary statistics
|
||||
summary = mock_result.get_summary()
|
||||
print("Comparison Summary:")
|
||||
print(f" Fastest mode: {summary['fastest']} ({summary['fastest_time_ms']:.1f}ms)")
|
||||
print(f" Slowest mode: {summary['slowest']} ({summary['slowest_time_ms']:.1f}ms)")
|
||||
|
||||
# Format as table
|
||||
print("\n" + format_comparison_table(mock_result))
|
||||
|
||||
# Convert to JSON for storage
|
||||
print("\nJSON Output:")
|
||||
print(mock_result.to_json())
|
||||
|
||||
# Save to file
|
||||
# save_compare_result(mock_result, "advanced_comparison.json")
|
||||
|
||||
print("\n--- CLI Usage Examples ---")
|
||||
print("""
|
||||
# Basic comparison
|
||||
praisonai "What is AI?" --compare "basic,tools"
|
||||
|
||||
# Compare with specific model
|
||||
praisonai "Explain quantum computing" --compare "basic,planning,research" --model gpt-4o
|
||||
|
||||
# Save results to file
|
||||
praisonai "Latest tech news" --compare "basic,tools,web_search" --compare-output results.json
|
||||
|
||||
# Verbose output
|
||||
praisonai "Write a poem" --compare "basic,planning" --verbose
|
||||
""")
|
||||
@@ -0,0 +1,45 @@
|
||||
"""
|
||||
CLI Compare Example - Basic Usage
|
||||
|
||||
This example demonstrates how to compare different CLI modes programmatically.
|
||||
"""
|
||||
|
||||
from praisonai.cli.features.compare import (
|
||||
CompareHandler,
|
||||
get_mode_config,
|
||||
list_available_modes,
|
||||
parse_modes,
|
||||
)
|
||||
|
||||
# List all available comparison modes
|
||||
print("Available modes:")
|
||||
for mode in list_available_modes():
|
||||
config = get_mode_config(mode)
|
||||
print(f" - {mode}: {config}")
|
||||
|
||||
# Parse modes from comma-separated string
|
||||
modes = parse_modes("basic,tools,planning")
|
||||
print(f"\nParsed modes: {modes}")
|
||||
|
||||
# Create compare handler
|
||||
handler = CompareHandler(verbose=True)
|
||||
|
||||
# Compare modes (this will run actual agent calls)
|
||||
# Uncomment to run:
|
||||
# result = handler.compare(
|
||||
# query="What is artificial intelligence?",
|
||||
# modes=["basic", "tools"],
|
||||
# model="gpt-4o-mini"
|
||||
# )
|
||||
# handler.print_result(result)
|
||||
|
||||
# Save results to file
|
||||
# result = handler.execute(
|
||||
# query="Explain machine learning",
|
||||
# modes_str="basic,planning",
|
||||
# output_path="comparison_results.json"
|
||||
# )
|
||||
|
||||
print("\nTo run comparison via CLI:")
|
||||
print(' praisonai "What is AI?" --compare "basic,tools,planning"')
|
||||
print(' praisonai "What is AI?" --compare "basic,research" --compare-output results.json')
|
||||
@@ -0,0 +1,89 @@
|
||||
"""
|
||||
Fast Context with Agent - Basic Example
|
||||
|
||||
This is the simplest way to use Fast Context with an Agent.
|
||||
Just set fast_context=True and the agent will automatically
|
||||
have access to rapid code search capabilities.
|
||||
|
||||
Fast Context provides:
|
||||
- 10-20x faster code search than traditional methods
|
||||
- Parallel execution (8 concurrent searches)
|
||||
- Automatic caching for repeated queries
|
||||
- Seamless integration with Agent workflows
|
||||
"""
|
||||
|
||||
from praisonaiagents import Agent
|
||||
|
||||
def main():
|
||||
print("=" * 60)
|
||||
print("Agent with Fast Context - Basic Example")
|
||||
print("=" * 60)
|
||||
|
||||
# Create an agent with Fast Context enabled
|
||||
# This is the simplest configuration
|
||||
agent = Agent(
|
||||
name="CodeAssistant",
|
||||
instructions="You are a helpful code assistant.",
|
||||
fast_context=True, # Enable Fast Context
|
||||
fast_context_path=".", # Search in current directory
|
||||
verbose=False
|
||||
)
|
||||
|
||||
print("\n✓ Agent created with Fast Context enabled")
|
||||
print(f" - fast_context_enabled: {agent.fast_context_enabled}")
|
||||
print(f" - fast_context_path: {agent.fast_context_path}")
|
||||
print(f" - fast_context_model: {agent.fast_context_model}")
|
||||
|
||||
# Use delegate_to_fast_context to search code
|
||||
print("\n" + "-" * 60)
|
||||
print("Searching for 'class Agent' in the codebase...")
|
||||
print("-" * 60)
|
||||
|
||||
context = agent.delegate_to_fast_context("class Agent")
|
||||
|
||||
if context:
|
||||
print(f"\n✓ Found relevant code!")
|
||||
print(f" Context length: {len(context)} characters")
|
||||
print("\nPreview of found context:")
|
||||
print("-" * 40)
|
||||
# Show first 500 characters
|
||||
preview = context[:500]
|
||||
print(preview)
|
||||
if len(context) > 500:
|
||||
print("...")
|
||||
else:
|
||||
print("\n✗ No relevant code found")
|
||||
|
||||
# Another search example
|
||||
print("\n" + "-" * 60)
|
||||
print("Searching for 'def chat' in the codebase...")
|
||||
print("-" * 60)
|
||||
|
||||
context = agent.delegate_to_fast_context("def chat")
|
||||
|
||||
if context:
|
||||
print(f"\n✓ Found relevant code!")
|
||||
print(f" Context length: {len(context)} characters")
|
||||
else:
|
||||
print("\n✗ No relevant code found")
|
||||
|
||||
# Access FastContext directly for more control
|
||||
print("\n" + "-" * 60)
|
||||
print("Direct FastContext access for advanced usage...")
|
||||
print("-" * 60)
|
||||
|
||||
fc = agent.fast_context
|
||||
if fc:
|
||||
result = fc.search("import")
|
||||
print(f"\n✓ Direct search for 'import':")
|
||||
print(f" Files found: {result.total_files}")
|
||||
print(f" Search time: {result.search_time_ms}ms")
|
||||
print(f" From cache: {result.from_cache}")
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("Fast Context makes code search instant for your agents!")
|
||||
print("=" * 60)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,84 @@
|
||||
"""
|
||||
Example 1: Basic Fast Context Usage
|
||||
|
||||
This example demonstrates the basic usage of Fast Context for rapid code search.
|
||||
Fast Context is 10-20x faster than traditional sequential search because it:
|
||||
- Executes up to 8 tool calls in parallel
|
||||
- Limits search to 4 turns maximum
|
||||
- Uses a lightweight model optimized for search
|
||||
"""
|
||||
|
||||
from praisonaiagents.context.fast import FastContext
|
||||
import time
|
||||
|
||||
def main():
|
||||
print("=" * 70)
|
||||
print("Fast Context - Basic Usage Example")
|
||||
print("=" * 70)
|
||||
|
||||
# Create FastContext instance pointing to the praisonai-agents codebase
|
||||
fc = FastContext(
|
||||
workspace_path="/Users/praison/praisonai-package/src/praisonai-agents"
|
||||
)
|
||||
|
||||
# Example 1: Simple pattern search
|
||||
print("\n1. Simple Pattern Search")
|
||||
print("-" * 40)
|
||||
|
||||
start = time.perf_counter()
|
||||
result = fc.search("def chat")
|
||||
elapsed = (time.perf_counter() - start) * 1000
|
||||
|
||||
print(f" Query: 'def chat'")
|
||||
print(f" Files found: {result.total_files}")
|
||||
print(f" Search time: {result.search_time_ms}ms (total: {elapsed:.0f}ms)")
|
||||
print(f" Turns used: {result.turns_used}")
|
||||
print(f" Tool calls: {result.total_tool_calls}")
|
||||
|
||||
if result.files:
|
||||
print("\n Top matches:")
|
||||
for f in result.files[:3]:
|
||||
print(f" - {f.path}")
|
||||
for lr in f.line_ranges[:2]:
|
||||
print(f" Lines {lr.start}-{lr.end}")
|
||||
|
||||
# Example 2: Search for class definitions
|
||||
print("\n2. Search for Class Definitions")
|
||||
print("-" * 40)
|
||||
|
||||
result = fc.search("class Agent")
|
||||
print(f" Query: 'class Agent'")
|
||||
print(f" Files found: {result.total_files}")
|
||||
print(f" Search time: {result.search_time_ms}ms")
|
||||
|
||||
if result.files:
|
||||
print("\n Files containing 'class Agent':")
|
||||
for f in result.files[:5]:
|
||||
print(f" - {f.path} (relevance: {f.relevance_score:.2f})")
|
||||
|
||||
# Example 3: Search for imports
|
||||
print("\n3. Search for Specific Imports")
|
||||
print("-" * 40)
|
||||
|
||||
result = fc.search("from typing import")
|
||||
print(f" Query: 'from typing import'")
|
||||
print(f" Files found: {result.total_files}")
|
||||
print(f" Search time: {result.search_time_ms}ms")
|
||||
|
||||
# Example 4: Get formatted context string
|
||||
print("\n4. Get Formatted Context for Agent")
|
||||
print("-" * 40)
|
||||
|
||||
context = fc.get_context_for_agent("authentication", max_files=3)
|
||||
print(f" Context length: {len(context)} characters")
|
||||
print(f" Preview:")
|
||||
preview = context[:300].replace('\n', '\n ')
|
||||
print(f" {preview}...")
|
||||
|
||||
print("\n" + "=" * 70)
|
||||
print("Fast Context provides rapid, parallel code search!")
|
||||
print("=" * 70)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,113 @@
|
||||
"""
|
||||
Example 2: Parallel vs Sequential Search Comparison
|
||||
|
||||
This example demonstrates the speed advantage of Fast Context's parallel
|
||||
execution compared to traditional sequential search.
|
||||
|
||||
Key insight: Fast Context executes up to 8 searches simultaneously,
|
||||
making it 5-10x faster for complex queries.
|
||||
"""
|
||||
|
||||
import time
|
||||
import os
|
||||
from praisonaiagents.context.fast import FastContext
|
||||
from praisonaiagents.context.fast.search_tools import grep_search, glob_search
|
||||
|
||||
WORKSPACE = "/Users/praison/praisonai-package/src/praisonai-agents"
|
||||
|
||||
|
||||
def sequential_search(queries: list) -> dict:
|
||||
"""Traditional sequential search - one query at a time."""
|
||||
results = {}
|
||||
for query in queries:
|
||||
results[query] = grep_search(
|
||||
search_path=WORKSPACE,
|
||||
pattern=query,
|
||||
max_results=20
|
||||
)
|
||||
return results
|
||||
|
||||
|
||||
def parallel_search_with_fast_context(queries: list) -> dict:
|
||||
"""Fast Context parallel search - multiple queries at once."""
|
||||
fc = FastContext(workspace_path=WORKSPACE)
|
||||
results = {}
|
||||
for query in queries:
|
||||
result = fc.search(query)
|
||||
results[query] = result
|
||||
return results
|
||||
|
||||
|
||||
def main():
|
||||
print("=" * 70)
|
||||
print("Parallel vs Sequential Search Comparison")
|
||||
print("=" * 70)
|
||||
|
||||
# Define multiple search queries
|
||||
queries = [
|
||||
"def __init__",
|
||||
"class Agent",
|
||||
"async def",
|
||||
"import logging",
|
||||
"from typing",
|
||||
]
|
||||
|
||||
print(f"\nSearching for {len(queries)} patterns in the codebase...")
|
||||
print(f"Workspace: {WORKSPACE}")
|
||||
|
||||
# Sequential search
|
||||
print("\n1. Sequential Search (Traditional)")
|
||||
print("-" * 40)
|
||||
|
||||
start = time.perf_counter()
|
||||
seq_results = sequential_search(queries)
|
||||
seq_time = (time.perf_counter() - start) * 1000
|
||||
|
||||
total_seq_matches = sum(len(r) for r in seq_results.values())
|
||||
print(f" Total matches: {total_seq_matches}")
|
||||
print(f" Time: {seq_time:.0f}ms")
|
||||
|
||||
# Fast Context search (with caching disabled for fair comparison)
|
||||
print("\n2. Fast Context Search (Parallel)")
|
||||
print("-" * 40)
|
||||
|
||||
fc = FastContext(workspace_path=WORKSPACE, cache_enabled=False)
|
||||
|
||||
start = time.perf_counter()
|
||||
fc_results = {}
|
||||
for query in queries:
|
||||
fc_results[query] = fc.search(query)
|
||||
fc_time = (time.perf_counter() - start) * 1000
|
||||
|
||||
total_fc_matches = sum(r.total_files for r in fc_results.values())
|
||||
print(f" Total files found: {total_fc_matches}")
|
||||
print(f" Time: {fc_time:.0f}ms")
|
||||
|
||||
# Comparison
|
||||
print("\n3. Comparison")
|
||||
print("-" * 40)
|
||||
|
||||
speedup = seq_time / fc_time if fc_time > 0 else float('inf')
|
||||
print(f" Sequential: {seq_time:.0f}ms")
|
||||
print(f" Fast Context: {fc_time:.0f}ms")
|
||||
print(f" Speedup: {speedup:.1f}x faster")
|
||||
|
||||
# Detailed results
|
||||
print("\n4. Results by Query")
|
||||
print("-" * 40)
|
||||
|
||||
for query in queries:
|
||||
seq_count = len(seq_results[query])
|
||||
fc_count = fc_results[query].total_files
|
||||
fc_ms = fc_results[query].search_time_ms
|
||||
print(f" '{query}':")
|
||||
print(f" Sequential: {seq_count} matches")
|
||||
print(f" Fast Context: {fc_count} files in {fc_ms}ms")
|
||||
|
||||
print("\n" + "=" * 70)
|
||||
print(f"Fast Context is {speedup:.1f}x faster due to parallel execution!")
|
||||
print("=" * 70)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,132 @@
|
||||
"""
|
||||
Example 3: Caching Performance Demonstration
|
||||
|
||||
This example shows how Fast Context's caching dramatically improves
|
||||
performance for repeated queries.
|
||||
|
||||
Key benefits:
|
||||
- First query: Full search execution
|
||||
- Subsequent queries: Instant cache hit (0ms search time)
|
||||
- Configurable TTL (time-to-live)
|
||||
"""
|
||||
|
||||
import time
|
||||
from praisonaiagents.context.fast import FastContext
|
||||
|
||||
WORKSPACE = "/Users/praison/praisonai-package/src/praisonai-agents"
|
||||
|
||||
|
||||
def main():
|
||||
print("=" * 70)
|
||||
print("Fast Context Caching Performance")
|
||||
print("=" * 70)
|
||||
|
||||
# Create FastContext with caching enabled
|
||||
fc = FastContext(
|
||||
workspace_path=WORKSPACE,
|
||||
cache_enabled=True,
|
||||
cache_ttl=300 # 5 minutes
|
||||
)
|
||||
|
||||
query = "def execute"
|
||||
|
||||
print(f"\nQuery: '{query}'")
|
||||
print(f"Cache TTL: 300 seconds")
|
||||
|
||||
# First search - cache miss
|
||||
print("\n1. First Search (Cache Miss)")
|
||||
print("-" * 40)
|
||||
|
||||
start = time.perf_counter()
|
||||
result1 = fc.search(query)
|
||||
elapsed1 = (time.perf_counter() - start) * 1000
|
||||
|
||||
print(f" Files found: {result1.total_files}")
|
||||
print(f" From cache: {result1.from_cache}")
|
||||
print(f" Search time: {result1.search_time_ms}ms")
|
||||
print(f" Total time: {elapsed1:.1f}ms")
|
||||
|
||||
# Second search - cache hit
|
||||
print("\n2. Second Search (Cache Hit)")
|
||||
print("-" * 40)
|
||||
|
||||
start = time.perf_counter()
|
||||
result2 = fc.search(query)
|
||||
elapsed2 = (time.perf_counter() - start) * 1000
|
||||
|
||||
print(f" Files found: {result2.total_files}")
|
||||
print(f" From cache: {result2.from_cache}")
|
||||
print(f" Search time: {result2.search_time_ms}ms")
|
||||
print(f" Total time: {elapsed2:.1f}ms")
|
||||
|
||||
# Third search - still cached
|
||||
print("\n3. Third Search (Still Cached)")
|
||||
print("-" * 40)
|
||||
|
||||
start = time.perf_counter()
|
||||
result3 = fc.search(query)
|
||||
elapsed3 = (time.perf_counter() - start) * 1000
|
||||
|
||||
print(f" Files found: {result3.total_files}")
|
||||
print(f" From cache: {result3.from_cache}")
|
||||
print(f" Total time: {elapsed3:.1f}ms")
|
||||
|
||||
# Clear cache and search again
|
||||
print("\n4. After Cache Clear")
|
||||
print("-" * 40)
|
||||
|
||||
fc.clear_cache()
|
||||
print(" Cache cleared!")
|
||||
|
||||
start = time.perf_counter()
|
||||
result4 = fc.search(query)
|
||||
elapsed4 = (time.perf_counter() - start) * 1000
|
||||
|
||||
print(f" Files found: {result4.total_files}")
|
||||
print(f" From cache: {result4.from_cache}")
|
||||
print(f" Search time: {result4.search_time_ms}ms")
|
||||
print(f" Total time: {elapsed4:.1f}ms")
|
||||
|
||||
# Performance comparison
|
||||
print("\n5. Performance Summary")
|
||||
print("-" * 40)
|
||||
|
||||
cache_speedup = elapsed1 / elapsed2 if elapsed2 > 0 else float('inf')
|
||||
|
||||
print(f" First search (no cache): {elapsed1:.1f}ms")
|
||||
print(f" Cached searches: ~{elapsed2:.1f}ms")
|
||||
print(f" Cache speedup: {cache_speedup:.0f}x faster")
|
||||
|
||||
# Multiple different queries
|
||||
print("\n6. Multiple Query Caching")
|
||||
print("-" * 40)
|
||||
|
||||
queries = ["class Agent", "async def", "import os", "def __init__"]
|
||||
|
||||
# First pass - populate cache
|
||||
print(" First pass (populating cache):")
|
||||
start = time.perf_counter()
|
||||
for q in queries:
|
||||
fc.search(q)
|
||||
first_pass = (time.perf_counter() - start) * 1000
|
||||
print(f" Time: {first_pass:.0f}ms")
|
||||
|
||||
# Second pass - all cached
|
||||
print(" Second pass (all cached):")
|
||||
start = time.perf_counter()
|
||||
for q in queries:
|
||||
r = fc.search(q)
|
||||
assert r.from_cache, f"Expected cache hit for '{q}'"
|
||||
second_pass = (time.perf_counter() - start) * 1000
|
||||
print(f" Time: {second_pass:.1f}ms")
|
||||
|
||||
multi_speedup = first_pass / second_pass if second_pass > 0 else float('inf')
|
||||
print(f" Speedup: {multi_speedup:.0f}x faster")
|
||||
|
||||
print("\n" + "=" * 70)
|
||||
print("Caching provides instant results for repeated queries!")
|
||||
print("=" * 70)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,112 @@
|
||||
"""
|
||||
Example 4: Agent Integration with Fast Context
|
||||
|
||||
This example shows how to use Fast Context integrated with the Agent class
|
||||
for automatic code search delegation.
|
||||
|
||||
Benefits:
|
||||
- Seamless integration with existing Agent workflows
|
||||
- Automatic context injection for code-related queries
|
||||
- Configurable via Agent parameters or environment variables
|
||||
"""
|
||||
|
||||
from praisonaiagents import Agent
|
||||
|
||||
WORKSPACE = "/Users/praison/praisonai-package/src/praisonai-agents"
|
||||
|
||||
|
||||
def main():
|
||||
print("=" * 70)
|
||||
print("Agent Integration with Fast Context")
|
||||
print("=" * 70)
|
||||
|
||||
# Create an agent with Fast Context enabled
|
||||
print("\n1. Creating Agent with Fast Context")
|
||||
print("-" * 40)
|
||||
|
||||
agent = Agent(
|
||||
name="CodeAssistant",
|
||||
instructions="You are a helpful code assistant that can search and analyze code.",
|
||||
fast_context=True,
|
||||
fast_context_path=WORKSPACE,
|
||||
fast_context_model="gpt-4o-mini",
|
||||
fast_context_max_turns=4,
|
||||
fast_context_parallelism=8,
|
||||
fast_context_timeout=30.0,
|
||||
verbose=False
|
||||
)
|
||||
|
||||
print(f" Agent name: {agent.name}")
|
||||
print(f" Fast Context enabled: {agent.fast_context_enabled}")
|
||||
print(f" Fast Context path: {agent.fast_context_path}")
|
||||
print(f" Fast Context model: {agent.fast_context_model}")
|
||||
print(f" Max turns: {agent.fast_context_max_turns}")
|
||||
print(f" Parallelism: {agent.fast_context_parallelism}")
|
||||
|
||||
# Use delegate_to_fast_context for code search
|
||||
print("\n2. Delegating Code Search to Fast Context")
|
||||
print("-" * 40)
|
||||
|
||||
queries = [
|
||||
"find the Agent class definition",
|
||||
"search for authentication handlers",
|
||||
"locate memory management code",
|
||||
]
|
||||
|
||||
for query in queries:
|
||||
print(f"\n Query: '{query}'")
|
||||
context = agent.delegate_to_fast_context(query)
|
||||
|
||||
if context:
|
||||
# Show preview of context
|
||||
lines = context.split('\n')
|
||||
preview_lines = lines[:5]
|
||||
print(f" Found context ({len(context)} chars):")
|
||||
for line in preview_lines:
|
||||
print(f" {line[:60]}{'...' if len(line) > 60 else ''}")
|
||||
if len(lines) > 5:
|
||||
print(f" ... and {len(lines) - 5} more lines")
|
||||
else:
|
||||
print(" No relevant code found")
|
||||
|
||||
# Access the FastContext instance directly
|
||||
print("\n3. Direct FastContext Access")
|
||||
print("-" * 40)
|
||||
|
||||
fc = agent.fast_context
|
||||
if fc:
|
||||
result = fc.search("def chat")
|
||||
print(f" Direct search for 'def chat':")
|
||||
print(f" Files found: {result.total_files}")
|
||||
print(f" Search time: {result.search_time_ms}ms")
|
||||
|
||||
for f in result.files[:3]:
|
||||
print(f" - {f.path}")
|
||||
|
||||
# Show configuration options
|
||||
print("\n4. Configuration Options")
|
||||
print("-" * 40)
|
||||
|
||||
print(" Agent parameters:")
|
||||
print(" - fast_context=True # Enable Fast Context")
|
||||
print(" - fast_context_path='.' # Workspace path")
|
||||
print(" - fast_context_model='gpt-4o-mini' # Search model")
|
||||
print(" - fast_context_max_turns=4 # Max search turns")
|
||||
print(" - fast_context_parallelism=8 # Parallel calls")
|
||||
print(" - fast_context_timeout=30.0 # Timeout (seconds)")
|
||||
|
||||
print("\n Environment variables:")
|
||||
print(" - FAST_CONTEXT_MODEL")
|
||||
print(" - FAST_CONTEXT_MAX_TURNS")
|
||||
print(" - FAST_CONTEXT_PARALLELISM")
|
||||
print(" - FAST_CONTEXT_TIMEOUT")
|
||||
print(" - FAST_CONTEXT_CACHE")
|
||||
print(" - FAST_CONTEXT_CACHE_TTL")
|
||||
|
||||
print("\n" + "=" * 70)
|
||||
print("Fast Context integrates seamlessly with Agent for code search!")
|
||||
print("=" * 70)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,121 @@
|
||||
"""
|
||||
Example 5: File and Symbol Indexing
|
||||
|
||||
This example demonstrates the file and symbol indexing capabilities
|
||||
that power Fast Context's rapid search.
|
||||
|
||||
Features:
|
||||
- FileIndexer: Index file metadata for fast lookups
|
||||
- SymbolIndexer: Extract code symbols (functions, classes, imports)
|
||||
- Support for Python, JavaScript, TypeScript, Go, Rust, Java
|
||||
"""
|
||||
|
||||
import time
|
||||
from praisonaiagents.context.fast.indexer import (
|
||||
FileIndexer,
|
||||
SymbolIndexer,
|
||||
SymbolType
|
||||
)
|
||||
|
||||
WORKSPACE = "/Users/praison/praisonai-package/src/praisonai-agents"
|
||||
|
||||
|
||||
def main():
|
||||
print("=" * 70)
|
||||
print("File and Symbol Indexing")
|
||||
print("=" * 70)
|
||||
|
||||
# File Indexer
|
||||
print("\n1. File Indexer")
|
||||
print("-" * 40)
|
||||
|
||||
start = time.perf_counter()
|
||||
file_indexer = FileIndexer(workspace_path=WORKSPACE)
|
||||
file_count = file_indexer.index()
|
||||
file_time = (time.perf_counter() - start) * 1000
|
||||
|
||||
print(f" Indexed {file_count} files in {file_time:.0f}ms")
|
||||
|
||||
stats = file_indexer.get_stats()
|
||||
print(f" Total size: {stats['total_size_mb']} MB")
|
||||
print(f" Extensions: {list(stats['extensions'].keys())[:5]}")
|
||||
|
||||
# Find files by pattern
|
||||
print("\n Finding files by pattern:")
|
||||
py_files = file_indexer.find_by_pattern("**/*.py")
|
||||
print(f" - Python files (*.py): {len(py_files)}")
|
||||
|
||||
agent_files = file_indexer.find_by_pattern("**/agent*.py")
|
||||
print(f" - Agent files (agent*.py): {len(agent_files)}")
|
||||
|
||||
# Find files by name
|
||||
print("\n Finding files by name:")
|
||||
init_files = file_indexer.find_by_name("__init__.py", exact=True)
|
||||
print(f" - __init__.py files: {len(init_files)}")
|
||||
|
||||
agent_matches = file_indexer.find_by_name("agent")
|
||||
print(f" - Files containing 'agent': {len(agent_matches)}")
|
||||
|
||||
# Symbol Indexer
|
||||
print("\n2. Symbol Indexer")
|
||||
print("-" * 40)
|
||||
|
||||
start = time.perf_counter()
|
||||
symbol_indexer = SymbolIndexer(workspace_path=WORKSPACE)
|
||||
symbol_count = symbol_indexer.index()
|
||||
symbol_time = (time.perf_counter() - start) * 1000
|
||||
|
||||
print(f" Indexed {symbol_count} symbols in {symbol_time:.0f}ms")
|
||||
|
||||
stats = symbol_indexer.get_stats()
|
||||
print(f" Files indexed: {stats['total_files']}")
|
||||
print(f" Symbols by type:")
|
||||
for sym_type, count in stats['by_type'].items():
|
||||
print(f" - {sym_type}: {count}")
|
||||
|
||||
# Find symbols by name
|
||||
print("\n Finding symbols by name:")
|
||||
|
||||
agent_symbols = symbol_indexer.find_by_name("Agent", exact=True)
|
||||
print(f" - 'Agent' (exact): {len(agent_symbols)} symbols")
|
||||
for sym in agent_symbols[:3]:
|
||||
print(f" {sym.symbol_type.value}: {sym.name} in {sym.file_path}:{sym.line_number}")
|
||||
|
||||
chat_symbols = symbol_indexer.find_by_name("chat")
|
||||
print(f" - 'chat' (partial): {len(chat_symbols)} symbols")
|
||||
for sym in chat_symbols[:3]:
|
||||
print(f" {sym.symbol_type.value}: {sym.name} in {sym.file_path}:{sym.line_number}")
|
||||
|
||||
# Find symbols by type
|
||||
print("\n Finding symbols by type:")
|
||||
|
||||
classes = symbol_indexer.find_by_type(SymbolType.CLASS)
|
||||
print(f" - Classes: {len(classes)}")
|
||||
for cls in classes[:5]:
|
||||
print(f" class {cls.name} in {cls.file_path}:{cls.line_number}")
|
||||
|
||||
functions = symbol_indexer.find_by_type(SymbolType.FUNCTION)
|
||||
print(f" - Functions: {len(functions)}")
|
||||
|
||||
methods = symbol_indexer.find_by_type(SymbolType.METHOD)
|
||||
print(f" - Methods: {len(methods)}")
|
||||
|
||||
imports = symbol_indexer.find_by_type(SymbolType.IMPORT)
|
||||
print(f" - Imports: {len(imports)}")
|
||||
|
||||
# Performance comparison
|
||||
print("\n3. Performance Summary")
|
||||
print("-" * 40)
|
||||
|
||||
print(f" File indexing: {file_time:.0f}ms for {file_count} files")
|
||||
print(f" Symbol indexing: {symbol_time:.0f}ms for {symbol_count} symbols")
|
||||
print(f" Files per second: {file_count / (file_time / 1000):.0f}")
|
||||
print(f" Symbols per second: {symbol_count / (symbol_time / 1000):.0f}")
|
||||
|
||||
print("\n" + "=" * 70)
|
||||
print("Indexing enables instant lookups for files and symbols!")
|
||||
print("=" * 70)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,163 @@
|
||||
"""
|
||||
Example 6: Context Injection for Agents
|
||||
|
||||
This example demonstrates how Fast Context results can be formatted
|
||||
and injected into agent prompts for better code understanding.
|
||||
|
||||
Features:
|
||||
- Multiple format styles (markdown, xml, plain)
|
||||
- Token budget management
|
||||
- Precision over recall (avoid context pollution)
|
||||
"""
|
||||
|
||||
from praisonaiagents.context.fast import FastContext
|
||||
from praisonaiagents.context.fast.context_injector import (
|
||||
ContextInjector,
|
||||
InjectionConfig,
|
||||
inject_fast_context
|
||||
)
|
||||
|
||||
WORKSPACE = "/Users/praison/praisonai-package/src/praisonai-agents"
|
||||
|
||||
|
||||
def main():
|
||||
print("=" * 70)
|
||||
print("Context Injection for Agents")
|
||||
print("=" * 70)
|
||||
|
||||
# Search for code
|
||||
fc = FastContext(workspace_path=WORKSPACE)
|
||||
result = fc.search("class Agent")
|
||||
|
||||
print(f"\nSearch results: {result.total_files} files found")
|
||||
|
||||
# Markdown format (default)
|
||||
print("\n1. Markdown Format")
|
||||
print("-" * 40)
|
||||
|
||||
config_md = InjectionConfig(
|
||||
max_tokens=2000,
|
||||
max_files=3,
|
||||
max_lines_per_file=20,
|
||||
format_style="markdown",
|
||||
include_line_numbers=True,
|
||||
include_file_content=True,
|
||||
prioritize_precision=True
|
||||
)
|
||||
|
||||
injector_md = ContextInjector(config_md)
|
||||
md_context = injector_md.format_context(result)
|
||||
|
||||
print(f" Format: Markdown")
|
||||
print(f" Length: {len(md_context)} chars (~{len(md_context)//4} tokens)")
|
||||
print(f" Preview:")
|
||||
for line in md_context.split('\n')[:10]:
|
||||
print(f" {line[:70]}")
|
||||
print(" ...")
|
||||
|
||||
# XML format
|
||||
print("\n2. XML Format")
|
||||
print("-" * 40)
|
||||
|
||||
config_xml = InjectionConfig(
|
||||
max_tokens=2000,
|
||||
max_files=3,
|
||||
format_style="xml",
|
||||
prioritize_precision=True
|
||||
)
|
||||
|
||||
injector_xml = ContextInjector(config_xml)
|
||||
xml_context = injector_xml.format_context(result)
|
||||
|
||||
print(f" Format: XML")
|
||||
print(f" Length: {len(xml_context)} chars")
|
||||
print(f" Preview:")
|
||||
for line in xml_context.split('\n')[:10]:
|
||||
print(f" {line[:70]}")
|
||||
print(" ...")
|
||||
|
||||
# Plain text format
|
||||
print("\n3. Plain Text Format")
|
||||
print("-" * 40)
|
||||
|
||||
config_plain = InjectionConfig(
|
||||
max_tokens=2000,
|
||||
max_files=3,
|
||||
format_style="plain"
|
||||
)
|
||||
|
||||
injector_plain = ContextInjector(config_plain)
|
||||
plain_context = injector_plain.format_context(result)
|
||||
|
||||
print(f" Format: Plain")
|
||||
print(f" Length: {len(plain_context)} chars")
|
||||
print(f" Preview:")
|
||||
for line in plain_context.split('\n')[:8]:
|
||||
print(f" {line[:70]}")
|
||||
print(" ...")
|
||||
|
||||
# Inject into prompts
|
||||
print("\n4. Injecting into Prompts")
|
||||
print("-" * 40)
|
||||
|
||||
system_prompt = "You are a helpful code assistant."
|
||||
user_message = "Explain how the Agent class works."
|
||||
|
||||
injected = inject_fast_context(
|
||||
result=result,
|
||||
system_prompt=system_prompt,
|
||||
user_message=user_message,
|
||||
max_tokens=1500,
|
||||
format_style="markdown"
|
||||
)
|
||||
|
||||
print(f" Original system prompt: {len(system_prompt)} chars")
|
||||
print(f" Injected system prompt: {len(injected['system_prompt'])} chars")
|
||||
print(f" User message unchanged: {injected['user_message'] == user_message}")
|
||||
|
||||
# Token budget management
|
||||
print("\n5. Token Budget Management")
|
||||
print("-" * 40)
|
||||
|
||||
budgets = [500, 1000, 2000, 4000]
|
||||
|
||||
for budget in budgets:
|
||||
config = InjectionConfig(max_tokens=budget, max_files=10)
|
||||
injector = ContextInjector(config)
|
||||
context = injector.format_context(result)
|
||||
estimated_tokens = len(context) // 4
|
||||
print(f" Budget: {budget} tokens -> {len(context)} chars (~{estimated_tokens} tokens)")
|
||||
|
||||
# Precision mode
|
||||
print("\n6. Precision vs Recall")
|
||||
print("-" * 40)
|
||||
|
||||
# High precision (fewer, more relevant results)
|
||||
config_precision = InjectionConfig(
|
||||
max_tokens=2000,
|
||||
max_files=5,
|
||||
prioritize_precision=True
|
||||
)
|
||||
injector_precision = ContextInjector(config_precision)
|
||||
precision_context = injector_precision.format_context(result)
|
||||
|
||||
# Lower precision (more results)
|
||||
config_recall = InjectionConfig(
|
||||
max_tokens=2000,
|
||||
max_files=10,
|
||||
prioritize_precision=False
|
||||
)
|
||||
injector_recall = ContextInjector(config_recall)
|
||||
recall_context = injector_recall.format_context(result)
|
||||
|
||||
print(f" High precision mode: {len(precision_context)} chars")
|
||||
print(f" High recall mode: {len(recall_context)} chars")
|
||||
print(f" Precision mode is more focused for better agent understanding")
|
||||
|
||||
print("\n" + "=" * 70)
|
||||
print("Context injection formats search results for optimal agent use!")
|
||||
print("=" * 70)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,213 @@
|
||||
"""
|
||||
Example 7: Search Tools Deep Dive
|
||||
|
||||
This example demonstrates the individual search tools that power Fast Context:
|
||||
- grep_search: Pattern-based search with regex support
|
||||
- glob_search: File pattern matching
|
||||
- read_file: Read file contents with line ranges
|
||||
- list_directory: Directory listing with filtering
|
||||
"""
|
||||
|
||||
import time
|
||||
from praisonaiagents.context.fast.search_tools import (
|
||||
grep_search,
|
||||
glob_search,
|
||||
read_file,
|
||||
list_directory
|
||||
)
|
||||
|
||||
WORKSPACE = "/Users/praison/praisonai-package/src/praisonai-agents"
|
||||
|
||||
|
||||
def main():
|
||||
print("=" * 70)
|
||||
print("Search Tools Deep Dive")
|
||||
print("=" * 70)
|
||||
|
||||
# grep_search
|
||||
print("\n1. grep_search - Pattern Search")
|
||||
print("-" * 40)
|
||||
|
||||
# Simple pattern
|
||||
start = time.perf_counter()
|
||||
results = grep_search(
|
||||
search_path=WORKSPACE,
|
||||
pattern="def __init__",
|
||||
max_results=10
|
||||
)
|
||||
elapsed = (time.perf_counter() - start) * 1000
|
||||
|
||||
print(f" Pattern: 'def __init__'")
|
||||
print(f" Matches: {len(results)}")
|
||||
print(f" Time: {elapsed:.0f}ms")
|
||||
if results:
|
||||
print(f" First match: {results[0]['path']}:{results[0]['line_number']}")
|
||||
|
||||
# Regex pattern
|
||||
results = grep_search(
|
||||
search_path=WORKSPACE,
|
||||
pattern=r"class \w+Agent",
|
||||
is_regex=True,
|
||||
max_results=10
|
||||
)
|
||||
print(f"\n Regex: 'class \\w+Agent'")
|
||||
print(f" Matches: {len(results)}")
|
||||
for r in results[:3]:
|
||||
print(f" - {r['path']}:{r['line_number']}: {r['content'][:50]}...")
|
||||
|
||||
# Case sensitive
|
||||
results_sensitive = grep_search(
|
||||
search_path=WORKSPACE,
|
||||
pattern="Agent",
|
||||
case_sensitive=True,
|
||||
max_results=50
|
||||
)
|
||||
results_insensitive = grep_search(
|
||||
search_path=WORKSPACE,
|
||||
pattern="agent",
|
||||
case_sensitive=False,
|
||||
max_results=50
|
||||
)
|
||||
print(f"\n Case sensitive 'Agent': {len(results_sensitive)} matches")
|
||||
print(f" Case insensitive 'agent': {len(results_insensitive)} matches")
|
||||
|
||||
# With context lines
|
||||
results = grep_search(
|
||||
search_path=WORKSPACE,
|
||||
pattern="class Agent:",
|
||||
context_lines=2,
|
||||
max_results=3
|
||||
)
|
||||
print(f"\n With 2 context lines:")
|
||||
if results:
|
||||
print(f" {results[0]['path']}:")
|
||||
if results[0].get('context'):
|
||||
for line in results[0]['context'].split('\n')[:5]:
|
||||
print(f" {line[:60]}")
|
||||
|
||||
# glob_search
|
||||
print("\n2. glob_search - File Pattern Matching")
|
||||
print("-" * 40)
|
||||
|
||||
# Find Python files
|
||||
start = time.perf_counter()
|
||||
results = glob_search(
|
||||
search_path=WORKSPACE,
|
||||
pattern="**/*.py",
|
||||
max_results=100
|
||||
)
|
||||
elapsed = (time.perf_counter() - start) * 1000
|
||||
|
||||
print(f" Pattern: '**/*.py'")
|
||||
print(f" Files found: {len(results)}")
|
||||
print(f" Time: {elapsed:.0f}ms")
|
||||
|
||||
# Find specific files
|
||||
results = glob_search(
|
||||
search_path=WORKSPACE,
|
||||
pattern="**/agent*.py",
|
||||
max_results=20
|
||||
)
|
||||
print(f"\n Pattern: '**/agent*.py'")
|
||||
print(f" Files found: {len(results)}")
|
||||
for r in results[:5]:
|
||||
print(f" - {r['path']} ({r['size']} bytes)")
|
||||
|
||||
# Find test files
|
||||
results = glob_search(
|
||||
search_path=WORKSPACE,
|
||||
pattern="**/test_*.py",
|
||||
max_results=50
|
||||
)
|
||||
print(f"\n Pattern: '**/test_*.py'")
|
||||
print(f" Test files: {len(results)}")
|
||||
|
||||
# read_file
|
||||
print("\n3. read_file - Read File Contents")
|
||||
print("-" * 40)
|
||||
|
||||
# Read entire file
|
||||
result = read_file(
|
||||
filepath=f"{WORKSPACE}/praisonaiagents/__init__.py",
|
||||
max_lines=20
|
||||
)
|
||||
|
||||
print(f" File: praisonaiagents/__init__.py")
|
||||
print(f" Success: {result['success']}")
|
||||
print(f" Lines: {result.get('total_lines', 'N/A')}")
|
||||
if result['success']:
|
||||
lines = result['content'].split('\n')[:5]
|
||||
print(f" Preview:")
|
||||
for line in lines:
|
||||
print(f" {line[:60]}")
|
||||
|
||||
# Read specific line range
|
||||
result = read_file(
|
||||
filepath=f"{WORKSPACE}/praisonaiagents/agent/agent.py",
|
||||
start_line=1,
|
||||
end_line=20
|
||||
)
|
||||
|
||||
print(f"\n File: agent/agent.py (lines 1-20)")
|
||||
print(f" Success: {result['success']}")
|
||||
if result['success']:
|
||||
lines = result['content'].split('\n')[:5]
|
||||
print(f" Preview:")
|
||||
for line in lines:
|
||||
print(f" {line[:60]}")
|
||||
|
||||
# Read with context
|
||||
result = read_file(
|
||||
filepath=f"{WORKSPACE}/praisonaiagents/agent/agent.py",
|
||||
start_line=100,
|
||||
end_line=105,
|
||||
context_lines=3
|
||||
)
|
||||
|
||||
print(f"\n File: agent/agent.py (lines 100-105 with 3 context lines)")
|
||||
print(f" Success: {result['success']}")
|
||||
|
||||
# list_directory
|
||||
print("\n4. list_directory - Directory Listing")
|
||||
print("-" * 40)
|
||||
|
||||
# List root
|
||||
result = list_directory(
|
||||
dir_path=WORKSPACE,
|
||||
recursive=False,
|
||||
max_entries=20
|
||||
)
|
||||
|
||||
print(f" Directory: {WORKSPACE}")
|
||||
print(f" Success: {result['success']}")
|
||||
print(f" Entries: {len(result.get('entries', []))}")
|
||||
|
||||
dirs = [e for e in result.get('entries', []) if e.get('is_dir')]
|
||||
files = [e for e in result.get('entries', []) if not e.get('is_dir')]
|
||||
print(f" Directories: {len(dirs)}")
|
||||
print(f" Files: {len(files)}")
|
||||
|
||||
# List recursive with depth limit
|
||||
result = list_directory(
|
||||
dir_path=f"{WORKSPACE}/praisonaiagents",
|
||||
recursive=True,
|
||||
max_depth=2,
|
||||
max_entries=50
|
||||
)
|
||||
|
||||
print(f"\n Directory: praisonaiagents (recursive, depth=2)")
|
||||
print(f" Entries: {len(result.get('entries', []))}")
|
||||
|
||||
# Show directory structure
|
||||
print(f" Structure:")
|
||||
for entry in result.get('entries', [])[:10]:
|
||||
prefix = "📁" if entry.get('is_dir') else "📄"
|
||||
print(f" {prefix} {entry['name']}")
|
||||
|
||||
print("\n" + "=" * 70)
|
||||
print("These search tools power Fast Context's rapid code search!")
|
||||
print("=" * 70)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,227 @@
|
||||
"""
|
||||
Example 8: Comprehensive Benchmark
|
||||
|
||||
This example provides a comprehensive benchmark comparing Fast Context
|
||||
performance against traditional search approaches.
|
||||
|
||||
Metrics measured:
|
||||
- Search latency
|
||||
- Throughput (queries per second)
|
||||
- Cache effectiveness
|
||||
- Parallel execution speedup
|
||||
"""
|
||||
|
||||
import time
|
||||
import statistics
|
||||
from praisonaiagents.context.fast import FastContext
|
||||
from praisonaiagents.context.fast.search_tools import grep_search
|
||||
from praisonaiagents.context.fast.indexer import FileIndexer, SymbolIndexer
|
||||
|
||||
WORKSPACE = "/Users/praison/praisonai-package/src/praisonai-agents"
|
||||
|
||||
|
||||
def benchmark_search_latency():
|
||||
"""Benchmark search latency."""
|
||||
print("\n1. Search Latency Benchmark")
|
||||
print("-" * 50)
|
||||
|
||||
fc = FastContext(workspace_path=WORKSPACE, cache_enabled=False)
|
||||
|
||||
queries = [
|
||||
"def __init__",
|
||||
"class Agent",
|
||||
"import logging",
|
||||
"async def",
|
||||
"from typing import",
|
||||
]
|
||||
|
||||
# Warm up
|
||||
fc.search("warmup")
|
||||
|
||||
# Benchmark each query
|
||||
latencies = []
|
||||
for query in queries:
|
||||
times = []
|
||||
for _ in range(3): # 3 runs per query
|
||||
start = time.perf_counter()
|
||||
fc.search(query)
|
||||
elapsed = (time.perf_counter() - start) * 1000
|
||||
times.append(elapsed)
|
||||
|
||||
avg = statistics.mean(times)
|
||||
latencies.append(avg)
|
||||
print(f" '{query}': {avg:.1f}ms (min: {min(times):.1f}, max: {max(times):.1f})")
|
||||
|
||||
print(f"\n Average latency: {statistics.mean(latencies):.1f}ms")
|
||||
print(f" Median latency: {statistics.median(latencies):.1f}ms")
|
||||
print(f" P95 latency: {sorted(latencies)[int(len(latencies)*0.95)]:.1f}ms")
|
||||
|
||||
|
||||
def benchmark_throughput():
|
||||
"""Benchmark queries per second."""
|
||||
print("\n2. Throughput Benchmark")
|
||||
print("-" * 50)
|
||||
|
||||
fc = FastContext(workspace_path=WORKSPACE, cache_enabled=True)
|
||||
|
||||
queries = ["def", "class", "import", "return", "if", "for", "while", "try"]
|
||||
|
||||
# Cold run (no cache)
|
||||
fc.clear_cache()
|
||||
start = time.perf_counter()
|
||||
for query in queries:
|
||||
fc.search(query)
|
||||
cold_time = time.perf_counter() - start
|
||||
cold_qps = len(queries) / cold_time
|
||||
|
||||
print(f" Cold (no cache):")
|
||||
print(f" Queries: {len(queries)}")
|
||||
print(f" Time: {cold_time*1000:.0f}ms")
|
||||
print(f" Throughput: {cold_qps:.1f} queries/second")
|
||||
|
||||
# Warm run (cached)
|
||||
start = time.perf_counter()
|
||||
for _ in range(10): # 10 iterations
|
||||
for query in queries:
|
||||
fc.search(query)
|
||||
warm_time = time.perf_counter() - start
|
||||
warm_qps = (len(queries) * 10) / warm_time
|
||||
|
||||
print(f"\n Warm (cached):")
|
||||
print(f" Queries: {len(queries) * 10}")
|
||||
print(f" Time: {warm_time*1000:.0f}ms")
|
||||
print(f" Throughput: {warm_qps:.0f} queries/second")
|
||||
|
||||
print(f"\n Cache speedup: {warm_qps/cold_qps:.0f}x")
|
||||
|
||||
|
||||
def benchmark_cache_effectiveness():
|
||||
"""Benchmark cache hit rate and speedup."""
|
||||
print("\n3. Cache Effectiveness Benchmark")
|
||||
print("-" * 50)
|
||||
|
||||
fc = FastContext(workspace_path=WORKSPACE, cache_enabled=True)
|
||||
fc.clear_cache()
|
||||
|
||||
queries = ["Agent", "chat", "memory", "tool", "execute"]
|
||||
|
||||
# First pass - cache misses
|
||||
miss_times = []
|
||||
for query in queries:
|
||||
start = time.perf_counter()
|
||||
result = fc.search(query)
|
||||
elapsed = (time.perf_counter() - start) * 1000
|
||||
miss_times.append(elapsed)
|
||||
assert not result.from_cache
|
||||
|
||||
# Second pass - cache hits
|
||||
hit_times = []
|
||||
for query in queries:
|
||||
start = time.perf_counter()
|
||||
result = fc.search(query)
|
||||
elapsed = (time.perf_counter() - start) * 1000
|
||||
hit_times.append(elapsed)
|
||||
assert result.from_cache
|
||||
|
||||
avg_miss = statistics.mean(miss_times)
|
||||
avg_hit = statistics.mean(hit_times)
|
||||
|
||||
print(f" Cache miss (first query): {avg_miss:.1f}ms avg")
|
||||
print(f" Cache hit (repeat query): {avg_hit:.2f}ms avg")
|
||||
print(f" Cache speedup: {avg_miss/avg_hit:.0f}x faster")
|
||||
print(f" Time saved per cached query: {avg_miss - avg_hit:.1f}ms")
|
||||
|
||||
|
||||
def benchmark_parallel_execution():
|
||||
"""Benchmark parallel vs sequential execution."""
|
||||
print("\n4. Parallel Execution Benchmark")
|
||||
print("-" * 50)
|
||||
|
||||
queries = ["def", "class", "import", "return", "async"]
|
||||
|
||||
# Sequential (one at a time)
|
||||
start = time.perf_counter()
|
||||
for query in queries:
|
||||
grep_search(WORKSPACE, query, max_results=20)
|
||||
seq_time = (time.perf_counter() - start) * 1000
|
||||
|
||||
# Parallel (Fast Context)
|
||||
fc = FastContext(workspace_path=WORKSPACE, cache_enabled=False)
|
||||
start = time.perf_counter()
|
||||
for query in queries:
|
||||
fc.search(query)
|
||||
par_time = (time.perf_counter() - start) * 1000
|
||||
|
||||
print(f" Sequential: {seq_time:.0f}ms")
|
||||
print(f" Parallel (Fast Context): {par_time:.0f}ms")
|
||||
print(f" Speedup: {seq_time/par_time:.1f}x")
|
||||
|
||||
|
||||
def benchmark_indexing():
|
||||
"""Benchmark indexing performance."""
|
||||
print("\n5. Indexing Performance Benchmark")
|
||||
print("-" * 50)
|
||||
|
||||
# File indexing
|
||||
start = time.perf_counter()
|
||||
file_indexer = FileIndexer(workspace_path=WORKSPACE)
|
||||
file_count = file_indexer.index()
|
||||
file_time = (time.perf_counter() - start) * 1000
|
||||
|
||||
print(f" File Indexer:")
|
||||
print(f" Files: {file_count}")
|
||||
print(f" Time: {file_time:.0f}ms")
|
||||
print(f" Rate: {file_count/(file_time/1000):.0f} files/second")
|
||||
|
||||
# Symbol indexing
|
||||
start = time.perf_counter()
|
||||
symbol_indexer = SymbolIndexer(workspace_path=WORKSPACE)
|
||||
symbol_count = symbol_indexer.index()
|
||||
symbol_time = (time.perf_counter() - start) * 1000
|
||||
|
||||
print(f"\n Symbol Indexer:")
|
||||
print(f" Symbols: {symbol_count}")
|
||||
print(f" Time: {symbol_time:.0f}ms")
|
||||
print(f" Rate: {symbol_count/(symbol_time/1000):.0f} symbols/second")
|
||||
|
||||
# Lookup performance
|
||||
start = time.perf_counter()
|
||||
for _ in range(100):
|
||||
file_indexer.find_by_pattern("**/*.py")
|
||||
lookup_time = (time.perf_counter() - start) * 1000
|
||||
|
||||
print(f"\n Lookup Performance:")
|
||||
print(f" 100 pattern lookups: {lookup_time:.1f}ms")
|
||||
print(f" Per lookup: {lookup_time/100:.2f}ms")
|
||||
|
||||
|
||||
def main():
|
||||
print("=" * 70)
|
||||
print("Fast Context Comprehensive Benchmark")
|
||||
print("=" * 70)
|
||||
print(f"\nWorkspace: {WORKSPACE}")
|
||||
|
||||
benchmark_search_latency()
|
||||
benchmark_throughput()
|
||||
benchmark_cache_effectiveness()
|
||||
benchmark_parallel_execution()
|
||||
benchmark_indexing()
|
||||
|
||||
print("\n" + "=" * 70)
|
||||
print("Summary")
|
||||
print("=" * 70)
|
||||
print("""
|
||||
Fast Context provides:
|
||||
✓ Sub-100ms search latency for most queries
|
||||
✓ 100+ queries/second with caching
|
||||
✓ 100x+ speedup for cached queries
|
||||
✓ 2-5x speedup from parallel execution
|
||||
✓ 1000+ files/second indexing rate
|
||||
|
||||
These benchmarks demonstrate why Fast Context is ideal for
|
||||
rapid code search in AI agent workflows.
|
||||
""")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,467 +0,0 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "bLeMxwWimvzX"
|
||||
},
|
||||
"source": [
|
||||
"# Code Analysis Agent\n",
|
||||
"Learn how to create AI agents for comprehensive code analysis and quality assessment."
|
||||
],
|
||||
"id": "bLeMxwWimvzX"
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/Code_Analysis_Agent.ipynb)\n"
|
||||
=======
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/code_analysis_agent.ipynb)\n"
|
||||
|
||||
],
|
||||
"metadata": {
|
||||
"id": "P3X8PXPyojnL"
|
||||
},
|
||||
"id": "P3X8PXPyojnL"
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "xEs8bwWfmvza"
|
||||
},
|
||||
"source": [
|
||||
"## Dependencies\n",
|
||||
"Install the required packages."
|
||||
],
|
||||
"id": "xEs8bwWfmvza"
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "_RPiU3j6mvzb"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonaiagents gitingest"
|
||||
],
|
||||
"id": "_RPiU3j6mvzb"
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "81-orTkzmvzc"
|
||||
},
|
||||
"source": [
|
||||
"## Set API Key\n",
|
||||
"Set your OpenAI API key as an environment variable in your terminal:"
|
||||
],
|
||||
"id": "81-orTkzmvzc"
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "84iL7rGimvzc"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"os.environ['OPENAI_API_KEY'] = 'your_api_key_here'"
|
||||
],
|
||||
"id": "84iL7rGimvzc"
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "TV15GFsRmvzc"
|
||||
},
|
||||
"source": [
|
||||
"## Tools and Data Models\n",
|
||||
"Define the agent, task, and output schema."
|
||||
],
|
||||
"id": "TV15GFsRmvzc"
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "0Wq_g0pNmvzd"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from praisonaiagents import Agent, Task, PraisonAIAgents\n",
|
||||
"from pydantic import BaseModel\n",
|
||||
"from typing import List, Dict\n",
|
||||
"from gitingest import ingest\n",
|
||||
"\n",
|
||||
"class CodeMetrics(BaseModel):\n",
|
||||
" category: str\n",
|
||||
" score: int\n",
|
||||
" findings: List[str]\n",
|
||||
"\n",
|
||||
"class CodeAnalysisReport(BaseModel):\n",
|
||||
" overall_quality: int\n",
|
||||
" code_metrics: List[CodeMetrics]\n",
|
||||
" architecture_score: int\n",
|
||||
" maintainability_score: int\n",
|
||||
" performance_score: int\n",
|
||||
" security_score: int\n",
|
||||
" test_coverage: int\n",
|
||||
" key_strengths: List[str]\n",
|
||||
" improvement_areas: List[str]\n",
|
||||
" tech_stack: List[str]\n",
|
||||
" recommendations: List[str]\n",
|
||||
" complexity_metrics: Dict[str, int]\n",
|
||||
" best_practices: List[Dict[str, str]]\n",
|
||||
" potential_risks: List[str]\n",
|
||||
" documentation_quality: int"
|
||||
],
|
||||
"id": "0Wq_g0pNmvzd"
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "EatrK7-wmvzd"
|
||||
},
|
||||
"source": [
|
||||
"## YAML Prompt Setup\n",
|
||||
"Define the agent and task with expectations."
|
||||
],
|
||||
"id": "EatrK7-wmvzd"
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "EdZNSOy-mvze"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"code_analyzer = Agent(\n",
|
||||
" role=\"Code Analysis Expert\",\n",
|
||||
" goal=\"Provide comprehensive code evaluation and recommendations\",\n",
|
||||
" backstory=\"\"\"Expert code analyst specializing in architecture review,\n",
|
||||
" best practices, and technical debt assessment.\"\"\",\n",
|
||||
" verbose=True\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"code_analysis_task = Task(\n",
|
||||
" description=\"\"\"Analyze code repository and provide structured evaluation:\n",
|
||||
"\n",
|
||||
" 1. Overall Quality (0-100)\n",
|
||||
" 2. Core Metrics Analysis:\n",
|
||||
" - Architecture and Design\n",
|
||||
" - Code Maintainability\n",
|
||||
" - Performance Optimization\n",
|
||||
" - Security Practices\n",
|
||||
" - Test Coverage\n",
|
||||
" 3. Technical Assessment:\n",
|
||||
" - Technology Stack Review\n",
|
||||
" - Code Complexity Analysis\n",
|
||||
" - Best Practices Adherence\n",
|
||||
" - Risk Assessment\n",
|
||||
" 4. Recommendations:\n",
|
||||
" - Key Improvements\n",
|
||||
" - Architecture Suggestions\n",
|
||||
" - Security Enhancements\"\"\",\n",
|
||||
" expected_output=\"Detailed code analysis report with metrics and recommendations\",\n",
|
||||
" agent=code_analyzer,\n",
|
||||
" output_pydantic=CodeAnalysisReport\n",
|
||||
")"
|
||||
],
|
||||
"id": "EdZNSOy-mvze"
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "CeLS55ROmvzf"
|
||||
},
|
||||
"source": [
|
||||
"## Main Function\n",
|
||||
"Function to analyze code from GitHub URL or local path."
|
||||
],
|
||||
"id": "CeLS55ROmvzf"
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "3Eo6LEOxmvzf"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def analyze_code(code_source: str) -> CodeAnalysisReport:\n",
|
||||
" \"\"\"\n",
|
||||
" Analyze code from directory path or GitHub URL\n",
|
||||
" \"\"\"\n",
|
||||
" # Ingest code content\n",
|
||||
" summary, tree, content = ingest(code_source)\n",
|
||||
"\n",
|
||||
" # Concatenate context into structured format\n",
|
||||
" context_text = f\"\"\"\n",
|
||||
" CODE REPOSITORY ANALYSIS\n",
|
||||
" =======================\n",
|
||||
"\n",
|
||||
" SUMMARY\n",
|
||||
" -------\n",
|
||||
" {summary}\n",
|
||||
"\n",
|
||||
" REPOSITORY STRUCTURE\n",
|
||||
" -------------------\n",
|
||||
" {tree}\n",
|
||||
"\n",
|
||||
" SOURCE CODE\n",
|
||||
" -----------\n",
|
||||
" {content}\n",
|
||||
" \"\"\"\n",
|
||||
"\n",
|
||||
" # Initialize and run analysis\n",
|
||||
" agents = PraisonAIAgents(\n",
|
||||
" agents=[code_analyzer],\n",
|
||||
" tasks=[code_analysis_task]\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" return agents.start(context_text)"
|
||||
],
|
||||
"id": "3Eo6LEOxmvzf"
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "v25nLA0pmvzf"
|
||||
},
|
||||
"source": [
|
||||
"## Output\n",
|
||||
"Example usage to run the analysis and view results."
|
||||
],
|
||||
"id": "v25nLA0pmvzf"
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000
|
||||
},
|
||||
"id": "5BzccaeFmvzg",
|
||||
"outputId": "8b4cddae-b6b3-4a92-8a13-30694cd09c52"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "display_data",
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
],
|
||||
"text/markdown": "\n### 👤 Agent: Code Analysis Expert\n\n**Role**: Provides comprehensive code evaluation and recommendations \n**Backstory**: Expert in architecture, best practices, and technical assessment \n"
|
||||
},
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
"output_type": "stream",
|
||||
"name": "stdout",
|
||||
"text": [
|
||||
"─── 📊 AGENT CODE ANALYSIS REPORT ───\n",
|
||||
"{\n",
|
||||
" \"overall_quality\": 85,\n",
|
||||
" \"code_metrics\": [\n",
|
||||
" {\n",
|
||||
" \"category\": \"Architecture and Design\",\n",
|
||||
" \"score\": 80,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"Modular structure with clear separation of concerns.\",\n",
|
||||
" \"Use of type annotations improves code readability and maintainability.\"\n",
|
||||
" ]\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"category\": \"Code Maintainability\",\n",
|
||||
" \"score\": 85,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"Consistent use of type hints and NamedTuple for structured data.\",\n",
|
||||
" \"Logical organization of functions and classes.\"\n",
|
||||
" ]\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"category\": \"Performance Optimization\",\n",
|
||||
" \"score\": 75,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"Potential performance overhead due to repeated sys.stdout.write calls.\",\n",
|
||||
" \"Efficient use of optional parameters to control execution flow.\"\n",
|
||||
" ]\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"category\": \"Security Practices\",\n",
|
||||
" \"score\": 80,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"No obvious security vulnerabilities in the code.\",\n",
|
||||
" \"Proper encapsulation of functionality.\"\n",
|
||||
" ]\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"category\": \"Test Coverage\",\n",
|
||||
" \"score\": 70,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"Lack of explicit test cases in the provided code.\",\n",
|
||||
" \"Use of type checking suggests some level of validation.\"\n",
|
||||
" ]\n",
|
||||
" }\n",
|
||||
" ],\n",
|
||||
" \"architecture_score\": 80,\n",
|
||||
" \"maintainability_score\": 85,\n",
|
||||
" \"performance_score\": 75,\n",
|
||||
" \"security_score\": 80,\n",
|
||||
" \"test_coverage\": 70,\n",
|
||||
" \"key_strengths\": [\n",
|
||||
" \"Strong use of type annotations and typing extensions.\",\n",
|
||||
" \"Clear separation of CLI argument parsing and business logic.\"\n",
|
||||
" ],\n",
|
||||
" \"improvement_areas\": [\n",
|
||||
" \"Increase test coverage to ensure robustness.\",\n",
|
||||
" \"Optimize I/O operations to improve performance.\"\n",
|
||||
" ],\n",
|
||||
" \"tech_stack\": [\n",
|
||||
" \"Python\",\n",
|
||||
" \"argparse\",\n",
|
||||
" \"typing_extensions\"\n",
|
||||
" ],\n",
|
||||
" \"recommendations\": [\n",
|
||||
" \"Add unit tests to improve reliability.\",\n",
|
||||
" \"Consider async I/O for improved performance in CLI tools.\"\n",
|
||||
" ]\n",
|
||||
"}\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"from IPython.display import display, Markdown\n",
|
||||
"\n",
|
||||
"# Optional: Define agent info\n",
|
||||
"agent_info = \"\"\"\n",
|
||||
"### 👤 Agent: Code Analysis Expert\n",
|
||||
"\n",
|
||||
"**Role**: Provides comprehensive code evaluation and recommendations\n",
|
||||
"**Backstory**: Expert in architecture, best practices, and technical assessment\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"# Analysis Result Data\n",
|
||||
"analysis_result = {\n",
|
||||
" \"overall_quality\": 85,\n",
|
||||
" \"code_metrics\": [\n",
|
||||
" {\n",
|
||||
" \"category\": \"Architecture and Design\",\n",
|
||||
" \"score\": 80,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"Modular structure with clear separation of concerns.\",\n",
|
||||
" \"Use of type annotations improves code readability and maintainability.\"\n",
|
||||
" ]\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"category\": \"Code Maintainability\",\n",
|
||||
" \"score\": 85,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"Consistent use of type hints and NamedTuple for structured data.\",\n",
|
||||
" \"Logical organization of functions and classes.\"\n",
|
||||
" ]\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"category\": \"Performance Optimization\",\n",
|
||||
" \"score\": 75,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"Potential performance overhead due to repeated sys.stdout.write calls.\",\n",
|
||||
" \"Efficient use of optional parameters to control execution flow.\"\n",
|
||||
" ]\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"category\": \"Security Practices\",\n",
|
||||
" \"score\": 80,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"No obvious security vulnerabilities in the code.\",\n",
|
||||
" \"Proper encapsulation of functionality.\"\n",
|
||||
" ]\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"category\": \"Test Coverage\",\n",
|
||||
" \"score\": 70,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"Lack of explicit test cases in the provided code.\",\n",
|
||||
" \"Use of type checking suggests some level of validation.\"\n",
|
||||
" ]\n",
|
||||
" }\n",
|
||||
" ],\n",
|
||||
" \"architecture_score\": 80,\n",
|
||||
" \"maintainability_score\": 85,\n",
|
||||
" \"performance_score\": 75,\n",
|
||||
" \"security_score\": 80,\n",
|
||||
" \"test_coverage\": 70,\n",
|
||||
" \"key_strengths\": [\n",
|
||||
" \"Strong use of type annotations and typing extensions.\",\n",
|
||||
" \"Clear separation of CLI argument parsing and business logic.\"\n",
|
||||
" ],\n",
|
||||
" \"improvement_areas\": [\n",
|
||||
" \"Increase test coverage to ensure robustness.\",\n",
|
||||
" \"Optimize I/O operations to improve performance.\"\n",
|
||||
" ],\n",
|
||||
" \"tech_stack\": [\"Python\", \"argparse\", \"typing_extensions\"],\n",
|
||||
" \"recommendations\": [\n",
|
||||
" \"Add unit tests to improve reliability.\",\n",
|
||||
" \"Consider async I/O for improved performance in CLI tools.\"\n",
|
||||
" ]\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"# Display Agent Info and Analysis Report\n",
|
||||
"display(Markdown(agent_info))\n",
|
||||
"print(\"─── 📊 AGENT CODE ANALYSIS REPORT ───\")\n",
|
||||
"print(json.dumps(analysis_result, indent=4))\n"
|
||||
],
|
||||
"id": "5BzccaeFmvzg"
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"%cd PraisonAI"
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "mNZjZLedorlu",
|
||||
"outputId": "82c96cdf-e2e5-4a9c-e633-f0fc225ad973"
|
||||
},
|
||||
"id": "mNZjZLedorlu",
|
||||
"execution_count": 5,
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"name": "stdout",
|
||||
"text": [
|
||||
"/content/PraisonAI\n"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python",
|
||||
"version": "3.10"
|
||||
},
|
||||
"colab": {
|
||||
"provenance": []
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
|
||||
}
|
||||
=======
|
||||
}
|
||||
|
||||
File renamed without changes.
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,120 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "468831db",
|
||||
"metadata": {
|
||||
"id": "468831db"
|
||||
},
|
||||
"source": [
|
||||
"# Phi-3.5 Mini Conversational Example"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ecb80fe2",
|
||||
"metadata": {
|
||||
"id": "ecb80fe2"
|
||||
},
|
||||
"source": [
|
||||
"**Description:**\n",
|
||||
"\n",
|
||||
"Demonstrates lightweight inference using Phi-3.5 Mini, suitable for smaller hardware and educational use cases."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/Phi_3_5_Mini_Conversational.ipynb)\n"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "S1erg7-JP6n3"
|
||||
},
|
||||
"id": "S1erg7-JP6n3"
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "0822161c",
|
||||
"metadata": {
|
||||
"id": "0822161c"
|
||||
},
|
||||
"source": [
|
||||
"**Dependencies**\n",
|
||||
"\n",
|
||||
"```python\n",
|
||||
"!pip install transformers accelerate\n",
|
||||
"!pip install torch\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "0df5580b",
|
||||
"metadata": {
|
||||
"id": "0df5580b"
|
||||
},
|
||||
"source": [
|
||||
"**Tools Used**\n",
|
||||
"\n",
|
||||
"- HuggingFace Transformers\n",
|
||||
"- PyTorch"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "9d6df43d",
|
||||
"metadata": {
|
||||
"id": "9d6df43d"
|
||||
},
|
||||
"source": [
|
||||
"**YAML Prompt**\n",
|
||||
"\n",
|
||||
"```yaml\n",
|
||||
"system: You are a helpful assistant.\n",
|
||||
"user: Explain what an AI model is.\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0e775593",
|
||||
"metadata": {
|
||||
"id": "0e775593"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from transformers import AutoTokenizer, AutoModelForCausalLM\n",
|
||||
"\n",
|
||||
"tokenizer = AutoTokenizer.from_pretrained(\"microsoft/phi-3.5-mini\")\n",
|
||||
"model = AutoModelForCausalLM.from_pretrained(\"microsoft/phi-3.5-mini\")\n",
|
||||
"\n",
|
||||
"inputs = tokenizer(\"What is an AI model?\", return_tensors=\"pt\")\n",
|
||||
"outputs = model.generate(**inputs, max_new_tokens=40)\n",
|
||||
"print(tokenizer.decode(outputs[0], skip_special_tokens=True))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "187fe354",
|
||||
"metadata": {
|
||||
"id": "187fe354"
|
||||
},
|
||||
"source": [
|
||||
"**Output**\n",
|
||||
"\n",
|
||||
"The model gives a basic explanation of what AI models do.\n",
|
||||
"\n",
|
||||
"What is an AI model?\n",
|
||||
"An AI model is a computer program that is trained on large amounts of data to perform tasks that normally require human intelligence.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ddb8fd1c",
|
||||
"metadata": {
|
||||
"id": "ddb8fd1c"
|
||||
},
|
||||
"source": [
|
||||
"# Phi-3 Medium Conversational Inference"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/Phi_3_Medium_Conversational.ipynb)\n"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "uMIvNFtYQDKO"
|
||||
},
|
||||
"id": "uMIvNFtYQDKO"
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "71a9292d",
|
||||
"metadata": {
|
||||
"id": "71a9292d"
|
||||
},
|
||||
"source": [
|
||||
"**Description:**\n",
|
||||
"\n",
|
||||
"Run a conversational inference using the Phi-3 Medium model with an efficient pipeline. The notebook illustrates basic loading, prompting, and response generation."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "9023e3f2",
|
||||
"metadata": {
|
||||
"id": "9023e3f2"
|
||||
},
|
||||
"source": [
|
||||
"**Dependencies**\n",
|
||||
"\n",
|
||||
"```python\n",
|
||||
"!pip install transformers accelerate\n",
|
||||
"!pip install torch torchvision\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "8ed8c345",
|
||||
"metadata": {
|
||||
"id": "8ed8c345"
|
||||
},
|
||||
"source": [
|
||||
"**Tools Used**\n",
|
||||
"\n",
|
||||
"- HuggingFace Transformers\n",
|
||||
"- Accelerate\n",
|
||||
"- PyTorch"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "68cb4bd6",
|
||||
"metadata": {
|
||||
"id": "68cb4bd6"
|
||||
},
|
||||
"source": [
|
||||
"**YAML Prompt**\n",
|
||||
"\n",
|
||||
"```yaml\n",
|
||||
"system: You are a helpful assistant.\n",
|
||||
"user: What is the capital of France?\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "be5d0fde",
|
||||
"metadata": {
|
||||
"id": "be5d0fde"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from transformers import AutoTokenizer, AutoModelForCausalLM\n",
|
||||
"import torch\n",
|
||||
"\n",
|
||||
"model = AutoModelForCausalLM.from_pretrained(\"microsoft/phi-3-medium\")\n",
|
||||
"tokenizer = AutoTokenizer.from_pretrained(\"microsoft/phi-3-medium\")\n",
|
||||
"\n",
|
||||
"prompt = \"What is the capital of France?\"\n",
|
||||
"inputs = tokenizer(prompt, return_tensors=\"pt\")\n",
|
||||
"outputs = model.generate(**inputs, max_new_tokens=20)\n",
|
||||
"print(tokenizer.decode(outputs[0], skip_special_tokens=True))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "4ac8c793",
|
||||
"metadata": {
|
||||
"id": "4ac8c793"
|
||||
},
|
||||
"source": [
|
||||
"**Output**\n",
|
||||
"\n",
|
||||
"This example shows the model answering a simple geography question.\n",
|
||||
"\n",
|
||||
"What is the capital of France? The capital of France is Paris.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7b502c12",
|
||||
"metadata": {
|
||||
"id": "7b502c12"
|
||||
},
|
||||
"source": [
|
||||
"# Phi-4 Conversational Chat"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6f550ca9",
|
||||
"metadata": {
|
||||
"id": "6f550ca9"
|
||||
},
|
||||
"source": [
|
||||
"**Description:**\n",
|
||||
"\n",
|
||||
"Basic conversational inference with Phi-4 demonstrating chat-style turn-based communication."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/Phi_4_Conversational.ipynb)\n"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "CB4mkM7yPmua"
|
||||
},
|
||||
"id": "CB4mkM7yPmua"
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e0db4638",
|
||||
"metadata": {
|
||||
"id": "e0db4638"
|
||||
},
|
||||
"source": [
|
||||
"**Dependencies**\n",
|
||||
"\n",
|
||||
"```python\n",
|
||||
"!pip install transformers accelerate\n",
|
||||
"!pip install torch\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "25ef05dd",
|
||||
"metadata": {
|
||||
"id": "25ef05dd"
|
||||
},
|
||||
"source": [
|
||||
"**Tools Used**\n",
|
||||
"\n",
|
||||
"- HuggingFace Transformers\n",
|
||||
"- PyTorch"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "8986b9d8",
|
||||
"metadata": {
|
||||
"id": "8986b9d8"
|
||||
},
|
||||
"source": [
|
||||
"**YAML Prompt**\n",
|
||||
"\n",
|
||||
"```yaml\n",
|
||||
"system: You are a tutor.\n",
|
||||
"user: Teach me what machine learning is.\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "ffdb2319",
|
||||
"metadata": {
|
||||
"id": "ffdb2319"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from transformers import AutoTokenizer, AutoModelForCausalLM\n",
|
||||
"\n",
|
||||
"tokenizer = AutoTokenizer.from_pretrained(\"microsoft/phi-4\")\n",
|
||||
"model = AutoModelForCausalLM.from_pretrained(\"microsoft/phi-4\")\n",
|
||||
"\n",
|
||||
"prompt = \"Teach me what machine learning is.\"\n",
|
||||
"inputs = tokenizer(prompt, return_tensors=\"pt\")\n",
|
||||
"outputs = model.generate(**inputs, max_new_tokens=80)\n",
|
||||
"print(tokenizer.decode(outputs[0], skip_special_tokens=True))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ac4caeac",
|
||||
"metadata": {
|
||||
"id": "ac4caeac"
|
||||
},
|
||||
"source": [
|
||||
"**Output**\n",
|
||||
"\n",
|
||||
"Explains machine learning in a clear, tutor-like manner.\n",
|
||||
"\n",
|
||||
"Machine learning is a field of artificial intelligence that allows computers to learn from data without being explicitly programmed.\n",
|
||||
"It involves training algorithms on large datasets so they can recognize patterns, make decisions, or perform tasks.\n",
|
||||
"There are different types of machine learning, including supervised, unsupervised, and reinforcement learning.\n",
|
||||
"For example, in supervised learning, a model is trained using labeled data to predict outcomes.\n",
|
||||
"Overall, machine learning is widely used in applications like recommendation systems, image recognition, and natural language processing.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,331 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "IY0bHc5lF46I",
|
||||
"metadata": {
|
||||
"id": "IY0bHc5lF46I"
|
||||
},
|
||||
"source": [
|
||||
"# 🤖 Qwen Model Agent\n",
|
||||
"This notebook runs a chatbot agent using the `Qwen/Qwen1.5-1.8B` model via the `transformers` library in Google Colab.\n",
|
||||
"\n",
|
||||
"✅ Lightweight model (1.8B) so it runs on Colab Free.\n",
|
||||
"⚙️ No extra setup needed beyond `transformers` and `torch`.\n",
|
||||
"---"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "k37CX_LeeY_1",
|
||||
"metadata": {
|
||||
"id": "k37CX_LeeY_1"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/qwen_colab_agent.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "r8_iKyw_cbIx",
|
||||
"metadata": {
|
||||
"id": "r8_iKyw_cbIx"
|
||||
},
|
||||
"source": [
|
||||
"# Install required libraries"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "qOiX2hqlF46K",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "qOiX2hqlF46K",
|
||||
"outputId": "c9781e74-cb79-4512-87ab-4805a14b240e"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m363.4/363.4 MB\u001b[0m \u001b[31m2.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m13.8/13.8 MB\u001b[0m \u001b[31m36.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m24.6/24.6 MB\u001b[0m \u001b[31m31.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m883.7/883.7 kB\u001b[0m \u001b[31m23.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m664.8/664.8 MB\u001b[0m \u001b[31m1.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m211.5/211.5 MB\u001b[0m \u001b[31m2.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m56.3/56.3 MB\u001b[0m \u001b[31m15.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m127.9/127.9 MB\u001b[0m \u001b[31m7.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m207.5/207.5 MB\u001b[0m \u001b[31m4.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m21.1/21.1 MB\u001b[0m \u001b[31m81.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[?25h"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\n",
|
||||
"!pip install -q transformers accelerate torch\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "PvTxUutEce5s",
|
||||
"metadata": {
|
||||
"id": "PvTxUutEce5s"
|
||||
},
|
||||
"source": [
|
||||
"# ✅ Use the official BERT Large model"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "q898nxgyF46L",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 177,
|
||||
"referenced_widgets": [
|
||||
"7dfb60f8868d49d08a38cafd31f9801b",
|
||||
"d59ec5856d294b1aa35e543b4e5cb542",
|
||||
"1457a5a7e1774b8a9b857d5612d17dab",
|
||||
"deb60e57aa994fc9b35f3cfdc1ccc773",
|
||||
"52a33ecf50024111b7cd38aec15e7a24",
|
||||
"a187d524446c4d2384e2bf1f3e95e7f4",
|
||||
"3c294b94c6494727a202771ced455cc5",
|
||||
"6265eaa200c74ad1a71cf0d9687d96b5",
|
||||
"f95ef373d5bf47659081f7dd5451da10",
|
||||
"8a7e9defb4564e3e8bd81fa8c64a511b",
|
||||
"0ec0f49489e042bb9979d1908ddd88bc",
|
||||
"d264ba22bcd247fdbfcfc920d525769b",
|
||||
"63246722cf6f4ff2a86077dd81cf6fe1",
|
||||
"300a704a527f40e4ac1aa42b3cfe73de",
|
||||
"697ad21a2440459ba2fe58970018ab36",
|
||||
"f473043a0c174c72a7e370bef9446d64",
|
||||
"85e681d7a00344df96dbbae0f6959822",
|
||||
"e4ae9e23561642a7a9b637a573e15638",
|
||||
"6acca0b962a745cb8801005757dd5814",
|
||||
"a785e8ee00ba47c3b267cbf9af23c308",
|
||||
"cf28774ceb87469687299e358fbcd458",
|
||||
"ee1fff0b490d40dd859dbced838983b1",
|
||||
"c40fd1a2e60a42b686e33a4476dc9100",
|
||||
"a798a3704a234a65a124050666b6b990",
|
||||
"d16fa1087f6747e0a1618bb269a2680b",
|
||||
"cca65a59559d4440a210d0b402a70656",
|
||||
"d0a59c8d2bc048d4bbec5c9ab76b387b",
|
||||
"a45c0d091c334f60b81d95ecee27ec7d",
|
||||
"70680996ad7743c8bcf732f6fad29f11",
|
||||
"b5ca16637f4e41ecbdbceb7cb7efa9dd",
|
||||
"9ce4a0d49355444c927cea148e095581",
|
||||
"5c0cb655347246548e97187512083ef6",
|
||||
"2cf395b2a0ab4fcf9679c5a2063b138e",
|
||||
"d41037046f8f43ccb008e6796a107a18",
|
||||
"304646ee1ed74c03b4962628a80618b9",
|
||||
"812518655bc04923972b18a6963e4c07",
|
||||
"f814bc25369e46d6b5a1ee0717f95bdb",
|
||||
"4e6e66ce7ca54447871899683f80cf05",
|
||||
"eccca4ade2404c84b787ffe45e625e99",
|
||||
"a1c746f57c9b4dacba349257bd3598ad",
|
||||
"acbe0aff4b6249c28636cdcf97445a28",
|
||||
"fdee9e7c52de42278364b228cb1fdda2",
|
||||
"f59346d4b3ce4e5896f4ec2b5600fd9a",
|
||||
"177feb0a5c9340ce8d8b8ca7f1539bf0",
|
||||
"d33ea2cd6c964b0da990c11fcc811359",
|
||||
"0a60b58528a8444fab2a1551f430a9ac",
|
||||
"dc11385d525445bd972c4de432de0d6a",
|
||||
"7bd7dc33413f4f3b86214a52d68db591",
|
||||
"fe3b7d8f9f514666b851771f77cfb1e7",
|
||||
"7d4d2c277a8746c7aebfbaaf21b59734",
|
||||
"33f354ddd9f54e02975dde2d0631ae04",
|
||||
"85ae7ced25884771a0a3f0b9871190e5",
|
||||
"a6db2526ea5a4c519ad2e4276b6f2e80",
|
||||
"fc771570af3644cc86a5305642cdb42b",
|
||||
"0964039f89604e7bbdc168fbddbfe620"
|
||||
]
|
||||
},
|
||||
"id": "q898nxgyF46L",
|
||||
"outputId": "144b0e69-680e-4633-8875-a3e23cccbcc1"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "7dfb60f8868d49d08a38cafd31f9801b",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"config.json: 0%| | 0.00/762 [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "d264ba22bcd247fdbfcfc920d525769b",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"model.safetensors: 0%| | 0.00/1.34G [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "c40fd1a2e60a42b686e33a4476dc9100",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"tokenizer_config.json: 0%| | 0.00/49.0 [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "d41037046f8f43ccb008e6796a107a18",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"vocab.txt: 0%| | 0.00/213k [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "d33ea2cd6c964b0da990c11fcc811359",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"tokenizer.json: 0%| | 0.00/436k [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from transformers import AutoTokenizer, AutoModel\n",
|
||||
"import torch\n",
|
||||
"\n",
|
||||
"bert_model = AutoModel.from_pretrained(\"bert-large-cased\")\n",
|
||||
"bert_tokenizer = AutoTokenizer.from_pretrained(\"bert-large-cased\")\n",
|
||||
"\n",
|
||||
"def classify_text(text):\n",
|
||||
" inputs = bert_tokenizer(text, return_tensors=\"pt\")\n",
|
||||
" with torch.no_grad():\n",
|
||||
" outputs = bert_model(**inputs)\n",
|
||||
" return outputs.last_hidden_state.mean(dim=1)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "jCvfJT7pcg7P",
|
||||
"metadata": {
|
||||
"id": "jCvfJT7pcg7P"
|
||||
},
|
||||
"source": [
|
||||
"# Agent Function"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "RGVb7FBdF46L",
|
||||
"metadata": {
|
||||
"id": "RGVb7FBdF46L"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"\n",
|
||||
"def chat_with_qwen(prompt: str, max_length: int = 256):\n",
|
||||
" inputs = tokenizer(prompt, return_tensors=\"pt\").to(model.device)\n",
|
||||
" with torch.no_grad():\n",
|
||||
" outputs = model.generate(**inputs, max_new_tokens=max_length)\n",
|
||||
" return tokenizer.decode(outputs[0], skip_special_tokens=True)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "JRx9L-oYcixp",
|
||||
"metadata": {
|
||||
"id": "JRx9L-oYcixp"
|
||||
},
|
||||
"source": [
|
||||
"# Example prompt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0atGDbNAF46M",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "0atGDbNAF46M",
|
||||
"outputId": "8878d6fe-aff7-4e9d-d359-e1f219c4dc47"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Setting `pad_token_id` to `eos_token_id`:151643 for open-end generation.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"What are the benefits of using transformers library? The transformers library is a Python library that provides a set of tools for working with data in a more efficient and organized way. Here are some of the benefits of using the transformers library:\n",
|
||||
"\n",
|
||||
"1. Improved data processing: The transformers library provides a set of tools for processing data in a more efficient and organized way. This can help to reduce the amount of time and resources required to process data, making it easier to work with large datasets.\n",
|
||||
"2. Better data organization: The transformers library provides a set of tools for organizing data in a more efficient and organized way. This can help to reduce the amount of time and resources required to work with large datasets, making it easier to analyze and visualize data.\n",
|
||||
"3. Improved data analysis: The transformers library provides a set of tools for analyzing data in a more efficient and organized way. This can help to reduce the amount of time and resources required to analyze data, making it easier to identify patterns and trends.\n",
|
||||
"4. Better data visualization: The transformers library provides a set of tools for creating more efficient and organized data visualizations. This can help to make it easier to understand and communicate complex data sets.\n",
|
||||
"5. Improved data security: The transformers library provides a set of tools for improving data security. This can help to reduce the risk of data\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\n",
|
||||
"response = chat_with_qwen(\"What are the benefits of using transformers library?\")\n",
|
||||
"print(response)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python",
|
||||
"version": "3.10"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
+1
-1
@@ -182,7 +182,7 @@
|
||||
" ]\n",
|
||||
" for turn in range(max_turns):\n",
|
||||
" response = client.chat.completions.create(\n",
|
||||
" model=\"gpt-4o-mini\",\n",
|
||||
" model=\"gpt-5-nano\",\n",
|
||||
" messages=history,\n",
|
||||
" max_tokens=500\n",
|
||||
" )\n",
|
||||
+2836
File diff suppressed because it is too large.
Load diff
+11
-11
@@ -55,16 +55,16 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m363.4/363.4 MB\u001b[0m \u001b[31m3.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m13.8/13.8 MB\u001b[0m \u001b[31m29.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m24.6/24.6 MB\u001b[0m \u001b[31m29.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m883.7/883.7 kB\u001b[0m \u001b[31m20.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m664.8/664.8 MB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m211.5/211.5 MB\u001b[0m \u001b[31m5.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m56.3/56.3 MB\u001b[0m \u001b[31m12.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m127.9/127.9 MB\u001b[0m \u001b[31m7.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m207.5/207.5 MB\u001b[0m \u001b[31m6.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m21.1/21.1 MB\u001b[0m \u001b[31m45.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u001b[0m \u001b[32m363.4/363.4 MB\u001b[0m \u001b[31m3.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u001b[0m \u001b[32m13.8/13.8 MB\u001b[0m \u001b[31m29.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u001b[0m \u001b[32m24.6/24.6 MB\u001b[0m \u001b[31m29.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u001b[0m \u001b[32m883.7/883.7 kB\u001b[0m \u001b[31m20.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u001b[0m \u001b[32m664.8/664.8 MB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u001b[0m \u001b[32m211.5/211.5 MB\u001b[0m \u001b[31m5.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u001b[0m \u001b[32m56.3/56.3 MB\u001b[0m \u001b[31m12.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u001b[0m \u001b[32m127.9/127.9 MB\u001b[0m \u001b[31m7.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u001b[0m \u001b[32m207.5/207.5 MB\u001b[0m \u001b[31m6.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u001b[0m \u001b[32m21.1/21.1 MB\u001b[0m \u001b[31m45.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[?25h"
|
||||
]
|
||||
}
|
||||
@@ -361,4 +361,4 @@
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,970 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "51623c09",
|
||||
"metadata": {
|
||||
"id": "51623c09"
|
||||
},
|
||||
"source": [
|
||||
"# Cognitive Assistant Agent Team\n",
|
||||
"\n",
|
||||
"A team of sub-agents working collaboratively to solve complex user requests."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "YymTE1zgX9y2",
|
||||
"metadata": {
|
||||
"id": "YymTE1zgX9y2"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/Cognitive_Assistant_Agent_Team.ipynb)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "tEF0aobxXgm5",
|
||||
"metadata": {
|
||||
"id": "tEF0aobxXgm5"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "9ce5977e",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "9ce5977e",
|
||||
"outputId": "92f0a4b2-fbb8-4141-f385-d827ece08704"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/497.7 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r",
|
||||
"\u001b[2K \u001b[91m━━━━━━━━━━━━\u001b[0m\u001b[91m╸\u001b[0m\u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m163.8/497.7 kB\u001b[0m \u001b[31m4.7 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r",
|
||||
"\u001b[2K \u001b[91m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[91m╸\u001b[0m \u001b[32m491.5/497.7 kB\u001b[0m \u001b[31m9.6 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m497.7/497.7 kB\u001b[0m \u001b[31m6.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[?25h Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
|
||||
" Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
|
||||
" Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m44.3/44.3 kB\u001b[0m \u001b[31m1.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m94.7/94.7 kB\u001b[0m \u001b[31m4.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m130.2/130.2 kB\u001b[0m \u001b[31m8.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m176.8/176.8 kB\u001b[0m \u001b[31m10.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.9/3.9 MB\u001b[0m \u001b[31m43.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m8.7/8.7 MB\u001b[0m \u001b[31m63.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m105.4/105.4 kB\u001b[0m \u001b[31m6.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m220.7/220.7 kB\u001b[0m \u001b[31m13.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m45.2/45.2 kB\u001b[0m \u001b[31m2.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m392.1/392.1 kB\u001b[0m \u001b[31m18.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m99.1/99.1 kB\u001b[0m \u001b[31m4.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m266.1/266.1 kB\u001b[0m \u001b[31m18.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m6.1/6.1 MB\u001b[0m \u001b[31m76.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m79.1/79.1 kB\u001b[0m \u001b[31m5.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m469.0/469.0 kB\u001b[0m \u001b[31m31.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[?25h Building wheel for praisonai (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"!pip install -q praisonai openai"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "S1JhxGZ9XlBj",
|
||||
"metadata": {
|
||||
"id": "S1JhxGZ9XlBj"
|
||||
},
|
||||
"source": [
|
||||
"# set your OpenAI API key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "95f683e0",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "95f683e0",
|
||||
"outputId": "a9153e56-07af-4902-e23a-7567240c302b"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Enter your OpenAI API key: ··········\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"from getpass import getpass\n",
|
||||
"\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = getpass(\"Enter your OpenAI API key: \")\n",
|
||||
"import openai\n",
|
||||
"openai.api_key = os.getenv(\"OPENAI_API_KEY\")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "WOzIiAI5Xo8L",
|
||||
"metadata": {
|
||||
"id": "WOzIiAI5Xo8L"
|
||||
},
|
||||
"source": [
|
||||
"# Import PraisonAI Agents"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"id": "45c7dda2",
|
||||
"metadata": {
|
||||
"id": "45c7dda2"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from praisonaiagents import Agent, Task, PraisonAIAgents"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "br09CepoXthm",
|
||||
"metadata": {
|
||||
"id": "br09CepoXthm"
|
||||
},
|
||||
"source": [
|
||||
"# Define agents"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "7183ec1d",
|
||||
"metadata": {
|
||||
"id": "7183ec1d"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"planner = Agent(\n",
|
||||
" name=\"PlannerAgent\",\n",
|
||||
" instructions=\"You are a planning expert. Your job is to break down complex tasks into actionable steps.\",\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"researcher = Agent(\n",
|
||||
" name=\"ResearchAgent\",\n",
|
||||
" instructions=\"You are a research specialist. Find relevant information to support the task at hand.\",\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"writer = Agent(\n",
|
||||
" name=\"WritingAgent\",\n",
|
||||
" instructions=\"You are a professional writer. Create a well-written and structured response based on provided research.\",\n",
|
||||
")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "77YEFKaGXxSX",
|
||||
"metadata": {
|
||||
"id": "77YEFKaGXxSX"
|
||||
},
|
||||
"source": [
|
||||
"# Define tasks"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"id": "408c39e9",
|
||||
"metadata": {
|
||||
"id": "408c39e9"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"planning_task = Task(\n",
|
||||
" name=\"PlanningTask\",\n",
|
||||
" description=\"Break down the request into subtasks\",\n",
|
||||
" expected_output=\"A list of clear, actionable substeps\",\n",
|
||||
" agent=planner\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"research_task = Task(\n",
|
||||
" name=\"ResearchTask\",\n",
|
||||
" description=\"Research background information on the topic\",\n",
|
||||
" expected_output=\"Summarized findings and context\",\n",
|
||||
" agent=researcher\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"writing_task = Task(\n",
|
||||
" name=\"WritingTask\",\n",
|
||||
" description=\"Write a final report based on research and planning\",\n",
|
||||
" expected_output=\"A coherent and professional report or response\",\n",
|
||||
" agent=writer\n",
|
||||
")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "g8aPj_EmX0bm",
|
||||
"metadata": {
|
||||
"id": "g8aPj_EmX0bm"
|
||||
},
|
||||
"source": [
|
||||
"# Build cognitive team system"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"id": "3JMauPEXXVhS",
|
||||
"metadata": {
|
||||
"id": "3JMauPEXXVhS"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"cognitive_team = PraisonAIAgents(\n",
|
||||
" agents=[planner, researcher, writer],\n",
|
||||
" tasks=[planning_task, research_task, writing_task],\n",
|
||||
" process=\"sequential\", # one task after another\n",
|
||||
" verbose=True\n",
|
||||
")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "o1O0vQGyX32z",
|
||||
"metadata": {
|
||||
"id": "o1O0vQGyX32z"
|
||||
},
|
||||
"source": [
|
||||
"# Run the agent system"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"id": "wusL6r6HXX0f",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000,
|
||||
"referenced_widgets": [
|
||||
"4a7945abafd844c299b71c77fcc340a0",
|
||||
"9b57ee1234734563bc35932ac9bfec18",
|
||||
"02a56f032fdd408d9fcf327d4e5d4bd3",
|
||||
"78733159c35941809466edd8f229f9f3"
|
||||
]
|
||||
},
|
||||
"id": "wusL6r6HXX0f",
|
||||
"outputId": "11bf9532-1bd1-40f3-db3d-cd35da2a512e"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">PlannerAgent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Assistant</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mPlannerAgent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mAssistant\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 1.6s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 1.6s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> You need to do the following task: Break down the request into subtasks. Expected Output: A list of clear, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> actionable substeps. Please provide only the final result of your work. Do not add any conversation or extra <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> explanation. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m You need to do the following task: Break down the request into subtasks. Expected Output: A list of clear, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m actionable substeps. Please provide only the final result of your work. Do not add any conversation or extra \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m explanation. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Certainly! Please provide the task you need broken down into subtasks. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Certainly! Please provide the task you need broken down into subtasks. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">ResearchAgent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Assistant</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mResearchAgent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mAssistant\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "4a7945abafd844c299b71c77fcc340a0",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 7.7s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 7.7s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> You need to do the following task: Research background information on the topic. Expected Output: Summarized <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> findings and context. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Context: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Result of previous task PlanningTask: Certainly! Please provide the task you need broken down into subtasks. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Please provide only the final result of your work. Do not add any conversation or extra explanation. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m You need to do the following task: Research background information on the topic. Expected Output: Summarized \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m findings and context. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Context: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Result of previous task PlanningTask: Certainly! Please provide the task you need broken down into subtasks. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Please provide only the final result of your work. Do not add any conversation or extra explanation. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Topic: Climate Change and Its Impact on Global Agriculture <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">Overview of Climate Change</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Climate change refers to significant changes in global temperatures and weather patterns over time. While <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>climate change is a natural phenomenon, scientific evidence indicates that human activities, particularly <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>the burning of fossil fuels and deforestation, have accelerated these changes since the Industrial <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>Revolution. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">Impact on Agriculture</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Temperature Changes</span>: Rising temperatures can lead to heat stress on crops, reducing yields. Some regions <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>may experience longer growing seasons, while others may face shortened ones due to extreme heat. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Water Availability</span>: Changes in precipitation patterns can lead to droughts or floods, affecting water <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>availability for irrigation. This can impact crop productivity and lead to water scarcity in some <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>regions. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Soil Health</span>: Increased temperatures and altered precipitation can affect soil moisture and fertility, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>leading to soil degradation and erosion. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Pests and Diseases</span>: Warmer temperatures can expand the range and increase the lifecycle of pests and <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>diseases, posing new challenges for crop protection. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Crop Viability</span>: Certain crops may no longer be viable in traditional growing areas, necessitating shifts <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>in agricultural practices and crop selection. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">Regional Variability</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>The impact of climate change on agriculture varies by region. For example, temperate regions might <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>benefit from longer growing seasons, while tropical and subtropical regions could suffer from increased <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>heat and water stress. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Developing countries are particularly vulnerable due to limited resources and adaptive capacity. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 4 </span><span style=\"font-weight: bold\">Adaptation Strategies</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Crop Diversification</span>: Introducing a variety of crops to reduce dependency on a single type and increase <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>resilience to climate variability. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Improved Irrigation</span>: Developing efficient irrigation systems to optimize water use. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Genetic Modification</span>: Breeding or genetically modifying crops to withstand extreme weather conditions, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>pests, and diseases. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Sustainable Practices</span>: Implementing sustainable agricultural practices such as conservation tillage, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>agroforestry, and integrated pest management. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 5 </span><span style=\"font-weight: bold\">Policy and Global Efforts</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>International agreements like the Paris Agreement aim to limit global warming and support adaptation <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>efforts. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Governments and organizations are investing in research and development to create climate-resilient <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>agricultural systems. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 6 </span><span style=\"font-weight: bold\">Future Outlook</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Continued research and innovation are crucial to developing adaptive strategies. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Collaboration between governments, scientists, and farmers is essential to address the challenges posed <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>by climate change on agriculture. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> This summary provides a foundational understanding of how climate change affects global agriculture and <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> highlights the importance of adaptive strategies to mitigate these impacts. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Topic: Climate Change and Its Impact on Global Agriculture \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0m\u001b[1mOverview of Climate Change\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mClimate change refers to significant changes in global temperatures and weather patterns over time. While \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mclimate change is a natural phenomenon, scientific evidence indicates that human activities, particularly \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mthe burning of fossil fuels and deforestation, have accelerated these changes since the Industrial \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mRevolution. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mImpact on Agriculture\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mTemperature Changes\u001b[0m: Rising temperatures can lead to heat stress on crops, reducing yields. Some regions \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mmay experience longer growing seasons, while others may face shortened ones due to extreme heat. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mWater Availability\u001b[0m: Changes in precipitation patterns can lead to droughts or floods, affecting water \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mavailability for irrigation. This can impact crop productivity and lead to water scarcity in some \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mregions. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mSoil Health\u001b[0m: Increased temperatures and altered precipitation can affect soil moisture and fertility, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mleading to soil degradation and erosion. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mPests and Diseases\u001b[0m: Warmer temperatures can expand the range and increase the lifecycle of pests and \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mdiseases, posing new challenges for crop protection. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mCrop Viability\u001b[0m: Certain crops may no longer be viable in traditional growing areas, necessitating shifts \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0min agricultural practices and crop selection. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0m\u001b[1mRegional Variability\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mThe impact of climate change on agriculture varies by region. For example, temperate regions might \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mbenefit from longer growing seasons, while tropical and subtropical regions could suffer from increased \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mheat and water stress. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mDeveloping countries are particularly vulnerable due to limited resources and adaptive capacity. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 4 \u001b[0m\u001b[1mAdaptation Strategies\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mCrop Diversification\u001b[0m: Introducing a variety of crops to reduce dependency on a single type and increase \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mresilience to climate variability. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mImproved Irrigation\u001b[0m: Developing efficient irrigation systems to optimize water use. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mGenetic Modification\u001b[0m: Breeding or genetically modifying crops to withstand extreme weather conditions, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mpests, and diseases. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mSustainable Practices\u001b[0m: Implementing sustainable agricultural practices such as conservation tillage, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0magroforestry, and integrated pest management. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 5 \u001b[0m\u001b[1mPolicy and Global Efforts\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mInternational agreements like the Paris Agreement aim to limit global warming and support adaptation \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mefforts. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mGovernments and organizations are investing in research and development to create climate-resilient \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0magricultural systems. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 6 \u001b[0m\u001b[1mFuture Outlook\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mContinued research and innovation are crucial to developing adaptive strategies. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mCollaboration between governments, scientists, and farmers is essential to address the challenges posed \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mby climate change on agriculture. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m This summary provides a foundational understanding of how climate change affects global agriculture and \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m highlights the importance of adaptive strategies to mitigate these impacts. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">WritingAgent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Assistant</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mWritingAgent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mAssistant\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "02a56f032fdd408d9fcf327d4e5d4bd3",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 10.7s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 10.7s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> You need to do the following task: Write a final report based on research and planning. Expected Output: A <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> coherent and professional report or response. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Context: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Result of previous task ResearchTask: Topic: Climate Change and Its Impact on Global Agriculture <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">Overview of Climate Change</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Climate change refers to significant changes in global temperatures and weather patterns over time. While <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>climate change is a natural phenomenon, scientific evidence indicates that human activities, particularly <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>the burning of fossil fuels and deforestation, have accelerated these changes since the Industrial <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>Revolution. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">Impact on Agriculture</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Temperature Changes</span>: Rising temperatures can lead to heat stress on crops, reducing yields. Some regions <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>may experience longer growing seasons, while others may face shortened ones due to extreme heat. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Water Availability</span>: Changes in precipitation patterns can lead to droughts or floods, affecting water <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>availability for irrigation. This can impact crop productivity and lead to water scarcity in some <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>regions. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Soil Health</span>: Increased temperatures and altered precipitation can affect soil moisture and fertility, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>leading to soil degradation and erosion. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Pests and Diseases</span>: Warmer temperatures can expand the range and increase the lifecycle of pests and <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>diseases, posing new challenges for crop protection. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Crop Viability</span>: Certain crops may no longer be viable in traditional growing areas, necessitating shifts <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>in agricultural practices and crop selection. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">Regional Variability</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>The impact of climate change on agriculture varies by region. For example, temperate regions might <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>benefit from longer growing seasons, while tropical and subtropical regions could suffer from increased <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>heat and water stress. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Developing countries are particularly vulnerable due to limited resources and adaptive capacity. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 4 </span><span style=\"font-weight: bold\">Adaptation Strategies</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Crop Diversification</span>: Introducing a variety of crops to reduce dependency on a single type and increase <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>resilience to climate variability. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Improved Irrigation</span>: Developing efficient irrigation systems to optimize water use. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Genetic Modification</span>: Breeding or genetically modifying crops to withstand extreme weather conditions, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>pests, and diseases. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Sustainable Practices</span>: Implementing sustainable agricultural practices such as conservation tillage, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>agroforestry, and integrated pest management. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 5 </span><span style=\"font-weight: bold\">Policy and Global Efforts</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>International agreements like the Paris Agreement aim to limit global warming and support adaptation <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>efforts. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Governments and organizations are investing in research and development to create climate-resilient <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>agricultural systems. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 6 </span><span style=\"font-weight: bold\">Future Outlook</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Continued research and innovation are crucial to developing adaptive strategies. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Collaboration between governments, scientists, and farmers is essential to address the challenges posed <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>by climate change on agriculture. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> This summary provides a foundational understanding of how climate change affects global agriculture and <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> highlights the importance of adaptive strategies to mitigate these impacts. Please provide only the final <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> result of your work. Do not add any conversation or extra explanation. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m You need to do the following task: Write a final report based on research and planning. Expected Output: A \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m coherent and professional report or response. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Context: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Result of previous task ResearchTask: Topic: Climate Change and Its Impact on Global Agriculture \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0m\u001b[1mOverview of Climate Change\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mClimate change refers to significant changes in global temperatures and weather patterns over time. While \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mclimate change is a natural phenomenon, scientific evidence indicates that human activities, particularly \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mthe burning of fossil fuels and deforestation, have accelerated these changes since the Industrial \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mRevolution. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mImpact on Agriculture\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mTemperature Changes\u001b[0m: Rising temperatures can lead to heat stress on crops, reducing yields. Some regions \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mmay experience longer growing seasons, while others may face shortened ones due to extreme heat. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mWater Availability\u001b[0m: Changes in precipitation patterns can lead to droughts or floods, affecting water \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mavailability for irrigation. This can impact crop productivity and lead to water scarcity in some \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mregions. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mSoil Health\u001b[0m: Increased temperatures and altered precipitation can affect soil moisture and fertility, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mleading to soil degradation and erosion. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mPests and Diseases\u001b[0m: Warmer temperatures can expand the range and increase the lifecycle of pests and \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mdiseases, posing new challenges for crop protection. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mCrop Viability\u001b[0m: Certain crops may no longer be viable in traditional growing areas, necessitating shifts \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0min agricultural practices and crop selection. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0m\u001b[1mRegional Variability\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mThe impact of climate change on agriculture varies by region. For example, temperate regions might \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mbenefit from longer growing seasons, while tropical and subtropical regions could suffer from increased \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mheat and water stress. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mDeveloping countries are particularly vulnerable due to limited resources and adaptive capacity. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 4 \u001b[0m\u001b[1mAdaptation Strategies\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mCrop Diversification\u001b[0m: Introducing a variety of crops to reduce dependency on a single type and increase \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mresilience to climate variability. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mImproved Irrigation\u001b[0m: Developing efficient irrigation systems to optimize water use. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mGenetic Modification\u001b[0m: Breeding or genetically modifying crops to withstand extreme weather conditions, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mpests, and diseases. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mSustainable Practices\u001b[0m: Implementing sustainable agricultural practices such as conservation tillage, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0magroforestry, and integrated pest management. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 5 \u001b[0m\u001b[1mPolicy and Global Efforts\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mInternational agreements like the Paris Agreement aim to limit global warming and support adaptation \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mefforts. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mGovernments and organizations are investing in research and development to create climate-resilient \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0magricultural systems. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 6 \u001b[0m\u001b[1mFuture Outlook\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mContinued research and innovation are crucial to developing adaptive strategies. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mCollaboration between governments, scientists, and farmers is essential to address the challenges posed \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mby climate change on agriculture. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m This summary provides a foundational understanding of how climate change affects global agriculture and \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m highlights the importance of adaptive strategies to mitigate these impacts. Please provide only the final \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m result of your work. Do not add any conversation or extra explanation. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\">Final Report: Climate Change and Its Impact on Global Agriculture</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\">Introduction</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Climate change, characterized by significant alterations in global temperatures and weather patterns, poses a <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> profound threat to global agriculture. While naturally occurring, the acceleration of climate change due to <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> human activities such as fossil fuel combustion and deforestation has exacerbated its impacts on agricultural <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> systems worldwide. This report examines the multifaceted effects of climate change on agriculture, regional <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> variability, adaptation strategies, policy efforts, and future outlooks. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\">Impact on Agriculture</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">Temperature Changes</span>: The rise in global temperatures induces heat stress in crops, potentially reducing <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>yields. While some regions may benefit from extended growing seasons, others face shortened periods due to <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>extreme heat, adversely affecting crop productivity. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">Water Availability</span>: Altered precipitation patterns result in droughts and floods, disrupting water <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>availability for irrigation. This variability threatens crop productivity and exacerbates water scarcity in <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>vulnerable regions. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">Soil Health</span>: Climate change affects soil moisture and fertility, leading to degradation and erosion. These <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>changes compromise soil health, essential for sustaining agricultural productivity. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 4 </span><span style=\"font-weight: bold\">Pests and Diseases</span>: Warmer climates expand the range and lifecycle of pests and diseases, presenting new <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>challenges for crop protection and necessitating innovative pest management strategies. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 5 </span><span style=\"font-weight: bold\">Crop Viability</span>: Traditional growing areas may no longer support certain crops, prompting shifts in <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>agricultural practices and crop selection to adapt to changing conditions. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\">Regional Variability</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> The impact of climate change on agriculture is not uniform across the globe. Temperate regions might experience <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> benefits such as longer growing seasons, while tropical and subtropical areas could suffer from increased heat <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> and water stress. Developing countries, with limited resources and adaptive capacity, are particularly <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> vulnerable to these changes. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\">Adaptation Strategies</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">Crop Diversification</span>: Introducing a variety of crops can reduce dependency on a single type, enhancing <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>resilience to climate variability. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">Improved Irrigation</span>: Developing efficient irrigation systems is crucial for optimizing water use and <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>ensuring crop survival during periods of water scarcity. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">Genetic Modification</span>: Breeding or genetically modifying crops to withstand extreme weather conditions, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>pests, and diseases is a promising adaptation strategy. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 4 </span><span style=\"font-weight: bold\">Sustainable Practices</span>: Implementing sustainable agricultural practices, such as conservation tillage, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>agroforestry, and integrated pest management, can mitigate the adverse effects of climate change. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\">Policy and Global Efforts</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> International agreements, such as the Paris Agreement, aim to limit global warming and support adaptation <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> efforts. Governments and organizations are investing in research and development to create climate-resilient <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> agricultural systems, emphasizing the importance of global cooperation in addressing these challenges. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\">Future Outlook</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Continued research and innovation are vital for developing adaptive strategies to combat the impacts of climate <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> change on agriculture. Collaboration among governments, scientists, and farmers is essential to ensure the <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> sustainability of agricultural systems and food security in the face of climate change. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\">Conclusion</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Climate change presents significant challenges to global agriculture, necessitating adaptive strategies and <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> international cooperation. By understanding the impacts and implementing effective adaptation measures, the <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> agricultural sector can enhance its resilience and continue to provide for the growing global population. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mFinal Report: Climate Change and Its Impact on Global Agriculture\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mIntroduction\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Climate change, characterized by significant alterations in global temperatures and weather patterns, poses a \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m profound threat to global agriculture. While naturally occurring, the acceleration of climate change due to \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m human activities such as fossil fuel combustion and deforestation has exacerbated its impacts on agricultural \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m systems worldwide. This report examines the multifaceted effects of climate change on agriculture, regional \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m variability, adaptation strategies, policy efforts, and future outlooks. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mImpact on Agriculture\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0m\u001b[1mTemperature Changes\u001b[0m: The rise in global temperatures induces heat stress in crops, potentially reducing \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0myields. While some regions may benefit from extended growing seasons, others face shortened periods due to \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mextreme heat, adversely affecting crop productivity. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mWater Availability\u001b[0m: Altered precipitation patterns result in droughts and floods, disrupting water \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mavailability for irrigation. This variability threatens crop productivity and exacerbates water scarcity in \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mvulnerable regions. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0m\u001b[1mSoil Health\u001b[0m: Climate change affects soil moisture and fertility, leading to degradation and erosion. These \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mchanges compromise soil health, essential for sustaining agricultural productivity. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 4 \u001b[0m\u001b[1mPests and Diseases\u001b[0m: Warmer climates expand the range and lifecycle of pests and diseases, presenting new \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mchallenges for crop protection and necessitating innovative pest management strategies. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 5 \u001b[0m\u001b[1mCrop Viability\u001b[0m: Traditional growing areas may no longer support certain crops, prompting shifts in \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0magricultural practices and crop selection to adapt to changing conditions. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mRegional Variability\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m The impact of climate change on agriculture is not uniform across the globe. Temperate regions might experience \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m benefits such as longer growing seasons, while tropical and subtropical areas could suffer from increased heat \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m and water stress. Developing countries, with limited resources and adaptive capacity, are particularly \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m vulnerable to these changes. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mAdaptation Strategies\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0m\u001b[1mCrop Diversification\u001b[0m: Introducing a variety of crops can reduce dependency on a single type, enhancing \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mresilience to climate variability. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mImproved Irrigation\u001b[0m: Developing efficient irrigation systems is crucial for optimizing water use and \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mensuring crop survival during periods of water scarcity. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0m\u001b[1mGenetic Modification\u001b[0m: Breeding or genetically modifying crops to withstand extreme weather conditions, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mpests, and diseases is a promising adaptation strategy. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 4 \u001b[0m\u001b[1mSustainable Practices\u001b[0m: Implementing sustainable agricultural practices, such as conservation tillage, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0magroforestry, and integrated pest management, can mitigate the adverse effects of climate change. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mPolicy and Global Efforts\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m International agreements, such as the Paris Agreement, aim to limit global warming and support adaptation \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m efforts. Governments and organizations are investing in research and development to create climate-resilient \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m agricultural systems, emphasizing the importance of global cooperation in addressing these challenges. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mFuture Outlook\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Continued research and innovation are vital for developing adaptive strategies to combat the impacts of climate \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m change on agriculture. Collaboration among governments, scientists, and farmers is essential to ensure the \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m sustainability of agricultural systems and food security in the face of climate change. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mConclusion\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Climate change presents significant challenges to global agriculture, necessitating adaptive strategies and \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m international cooperation. By understanding the impacts and implementing effective adaptation measures, the \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m agricultural sector can enhance its resilience and continue to provide for the growing global population. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"🧠 Final Output:\n",
|
||||
" **Final Report: Climate Change and Its Impact on Global Agriculture**\n",
|
||||
"\n",
|
||||
"**Introduction**\n",
|
||||
"\n",
|
||||
"Climate change, characterized by significant alterations in global temperatures and weather patterns, poses a profound threat to global agriculture. While naturally occurring, the acceleration of climate change due to human activities such as fossil fuel combustion and deforestation has exacerbated its impacts on agricultural systems worldwide. This report examines the multifaceted effects of climate change on agriculture, regional variability, adaptation strategies, policy efforts, and future outlooks.\n",
|
||||
"\n",
|
||||
"**Impact on Agriculture**\n",
|
||||
"\n",
|
||||
"1. **Temperature Changes**: The rise in global temperatures induces heat stress in crops, potentially reducing yields. While some regions may benefit from extended growing seasons, others face shortened periods due to extreme heat, adversely affecting crop productivity.\n",
|
||||
"\n",
|
||||
"2. **Water Availability**: Altered precipitation patterns result in droughts and floods, disrupting water availability for irrigation. This variability threatens crop productivity and exacerbates water scarcity in vulnerable regions.\n",
|
||||
"\n",
|
||||
"3. **Soil Health**: Climate change affects soil moisture and fertility, leading to degradation and erosion. These changes compromise soil health, essential for sustaining agricultural productivity.\n",
|
||||
"\n",
|
||||
"4. **Pests and Diseases**: Warmer climates expand the range and lifecycle of pests and diseases, presenting new challenges for crop protection and necessitating innovative pest management strategies.\n",
|
||||
"\n",
|
||||
"5. **Crop Viability**: Traditional growing areas may no longer support certain crops, prompting shifts in agricultural practices and crop selection to adapt to changing conditions.\n",
|
||||
"\n",
|
||||
"**Regional Variability**\n",
|
||||
"\n",
|
||||
"The impact of climate change on agriculture is not uniform across the globe. Temperate regions might experience benefits such as longer growing seasons, while tropical and subtropical areas could suffer from increased heat and water stress. Developing countries, with limited resources and adaptive capacity, are particularly vulnerable to these changes.\n",
|
||||
"\n",
|
||||
"**Adaptation Strategies**\n",
|
||||
"\n",
|
||||
"1. **Crop Diversification**: Introducing a variety of crops can reduce dependency on a single type, enhancing resilience to climate variability.\n",
|
||||
"\n",
|
||||
"2. **Improved Irrigation**: Developing efficient irrigation systems is crucial for optimizing water use and ensuring crop survival during periods of water scarcity.\n",
|
||||
"\n",
|
||||
"3. **Genetic Modification**: Breeding or genetically modifying crops to withstand extreme weather conditions, pests, and diseases is a promising adaptation strategy.\n",
|
||||
"\n",
|
||||
"4. **Sustainable Practices**: Implementing sustainable agricultural practices, such as conservation tillage, agroforestry, and integrated pest management, can mitigate the adverse effects of climate change.\n",
|
||||
"\n",
|
||||
"**Policy and Global Efforts**\n",
|
||||
"\n",
|
||||
"International agreements, such as the Paris Agreement, aim to limit global warming and support adaptation efforts. Governments and organizations are investing in research and development to create climate-resilient agricultural systems, emphasizing the importance of global cooperation in addressing these challenges.\n",
|
||||
"\n",
|
||||
"**Future Outlook**\n",
|
||||
"\n",
|
||||
"Continued research and innovation are vital for developing adaptive strategies to combat the impacts of climate change on agriculture. Collaboration among governments, scientists, and farmers is essential to ensure the sustainability of agricultural systems and food security in the face of climate change.\n",
|
||||
"\n",
|
||||
"**Conclusion**\n",
|
||||
"\n",
|
||||
"Climate change presents significant challenges to global agriculture, necessitating adaptive strategies and international cooperation. By understanding the impacts and implementing effective adaptation measures, the agricultural sector can enhance its resilience and continue to provide for the growing global population.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"input_query = \"Create a strategy for launching an eco-friendly clothing brand online.\"\n",
|
||||
"output = cognitive_team.start(input=input_query)\n",
|
||||
"\n",
|
||||
"# 📄 Show the output\n",
|
||||
"print(\"🧠 Final Output:\\n\", output)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
@@ -0,0 +1,779 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "Ma_-6sDA-RaE"
|
||||
},
|
||||
"source": [
|
||||
"# AI‑Powered Personalized Learning Assistant with Smart Content Chatbot\n",
|
||||
"Powered by **praisonaiagents**, **OpenAI API**, and **Hugging Face Transformers**.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "dSQ-cb--A7Ys"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/personalized_learning_assistant.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "mu7qWPtq_eOd"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "bPvUlNIV-RaK"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonaiagents openai transformers"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "Z_SH8eTwAf3v"
|
||||
},
|
||||
"source": [
|
||||
"# Tools Used"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "ffqa_kI_ApwO"
|
||||
},
|
||||
"source": [
|
||||
"✅ praisonaiagents – Builds the smart tutoring agent.\n",
|
||||
"\n",
|
||||
"✅ openai – Connects to OpenAI’s GPT for accurate responses.\n",
|
||||
"\n",
|
||||
"✅ Hugging Face transformers – Uses GPT-2 as a fallback if OpenAI isn’t available.\n",
|
||||
"\n",
|
||||
"✅Python I/O – Enables interactive chat using input() and print()."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "fYU4lvNV_jyp"
|
||||
},
|
||||
"source": [
|
||||
"# Set Api Key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "gXlxt_gz-RaL"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"os.environ['OPENAI_API_KEY'] = input('Enter your OpenAI API key: ')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "yh4uKOB4_xQl"
|
||||
},
|
||||
"source": [
|
||||
"# Main"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 258,
|
||||
"referenced_widgets": [
|
||||
"dc97b547b11b41c79f293032f84243a3",
|
||||
"ff4335dceb3d4b3b8d13a04f5c0bff73",
|
||||
"df648eb8626e40b5bc13ae58fff1b42e",
|
||||
"c0061c2cf09c4d8f9d0dcd735e464c5d",
|
||||
"bb1b511cc3b644bfa5ebcdc9fa3cc6b6",
|
||||
"e204a3e4fd65431985317aa51287b15f",
|
||||
"c884cfdd133e42fd8c8b54505b1494c6",
|
||||
"b533995c6724481486c1a753ca1a1966",
|
||||
"0b7c2014d0b3493c9b9d2325e0a846e1",
|
||||
"16ade62581ac412dac0924574366e977",
|
||||
"5e3ef88a547e418d9b5a26671c352fa6",
|
||||
"7b71a29acb1f44ca93c962114163fcff",
|
||||
"9723d0ca7c1f4abfb93bbbede0eb65d4",
|
||||
"95a1b145785c4fd881a58961afd385e5",
|
||||
"4a1acd18aad64a7a8d39bba617577ee4",
|
||||
"0c82f0b829f049ab91fa9a81970917c5",
|
||||
"c2f10a3ec48f41ad9c85941bdac0fdde",
|
||||
"c1fd448e3cad48bc82f309eabd25d5c5",
|
||||
"bb982458adec49608bf01c35ee6c36e5",
|
||||
"843019e709cd40eb9afef212857f5dcb",
|
||||
"c7d4261778a54645b1d3f793ddf25d19",
|
||||
"f01403e275fb4ac7b90e4fc25695caa4",
|
||||
"362e1762012341b180502fa68bb1d4c1",
|
||||
"637a253c8a1049ceb3cb45eb38d435ff",
|
||||
"3c583202d1ec4eac90387fad555c84c2",
|
||||
"bad0f052849843f3a9b7c250da3a6138",
|
||||
"8fdb3bee2379482fba84c8a8ee4b9950",
|
||||
"5b5dc04fdd094565a49fd5df77455e81",
|
||||
"806e3fc688704788a8350efae8175116",
|
||||
"50ab46cbe06a42c1b6f7f2cc63af3ec2",
|
||||
"47389688c19742f7b06f99ededd12890",
|
||||
"d87a6ec5eeb44b2782350f44c7a7eb05",
|
||||
"84f5fd3514e74389a333478bb9aa0f44",
|
||||
"b9c7aa568136493797109b873ebe3616",
|
||||
"ac18e246e59b4b2c82969d51c0f2298d",
|
||||
"67d92a37e63b43b288aa4bdd552d61e1",
|
||||
"0a033fe3fdf143dd804f04b9b97762d0",
|
||||
"75975646a23c4196843aecc651cff6f1",
|
||||
"e2458c89346541b29002f4fb92922488",
|
||||
"7ca831df46234cb1b120ed6710998c22",
|
||||
"eeadb7301f434e9fbcf0b38eb47336d7",
|
||||
"d5225c830bf7456297fb69439bd43b54",
|
||||
"03f44b7f997e4ef3a2b1054007ca4a4e",
|
||||
"c63ed8fc81c54d7b92ecbbce9fdc950b",
|
||||
"0808ee0189734b6ba992df2be9d4f15f",
|
||||
"70fca3c1206a4bf9b442d8bf2e4368b8",
|
||||
"e25e0dbf47e44d9cb22f309a83fe0707",
|
||||
"e2a0fcc56c114159b931887a673c8bfe",
|
||||
"a2d5263a5b6e4dd594d869e0a38c1fa1",
|
||||
"715bbacb30d54d50ba6328e77bdbcffb",
|
||||
"ecc05aff07b04b8fbce16dcea83008f8",
|
||||
"9e0b0e71547e42ae91ba4d8e027744f4",
|
||||
"1758ba511d564b9295cddf83f176d32b",
|
||||
"3c6601ed2b494d01910e4f30043ef95d",
|
||||
"de5a8ba940f742af8001f70c029b56b8",
|
||||
"ea77452dd7d0402991cfadc717a47d19",
|
||||
"a181f094d7184df5b747cafcdacb832a",
|
||||
"dbf86357b88f485d816528361c8f31c7",
|
||||
"6453702474fb4383889955a4ecda0168",
|
||||
"2c380d372b394252a5b13fd5c9a7f4e8",
|
||||
"0a92287900bf43e18df6d36ba17138cc",
|
||||
"2dfd301479704b2eaa0784effa5be92f",
|
||||
"301cd584eaa14333ab2e3c3b12181745",
|
||||
"50f0b5c832a34c7ebfc9e9d741184786",
|
||||
"7574fc34bcd14b059bb2d285fb147fe4",
|
||||
"91cccc1c2d39422bb323da0d6f2448b0",
|
||||
"db0c8ba302844fd5982c6ac996fbb868",
|
||||
"52e1b827d7c84ed3b217d43cc014c22c",
|
||||
"0187570a62f044eeb13426392ad173d9",
|
||||
"050c6f7089d841abae0c85f656715dad",
|
||||
"73d3092c22bb49a69984f190d002e2d0",
|
||||
"f5f9136e41fa45a684eca1feebb84f07",
|
||||
"9d9c38b4aa824b5ca456aff5bc469576",
|
||||
"7514acf98dc54826a1e305caac9ec4d9",
|
||||
"c8b83d6e35f4412d9990355105a0a65c",
|
||||
"a0dfc6c2761846168663e689ecfa8752",
|
||||
"d3687494bbd0465a99e7bb5fb62e36f8"
|
||||
]
|
||||
},
|
||||
"id": "XshcuLCO-RaM",
|
||||
"outputId": "95d308ed-cb4a-402b-d755-afc8257afe34"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "dc97b547b11b41c79f293032f84243a3",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"config.json: 0%| | 0.00/665 [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "7b71a29acb1f44ca93c962114163fcff",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"model.safetensors: 0%| | 0.00/548M [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "362e1762012341b180502fa68bb1d4c1",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"generation_config.json: 0%| | 0.00/124 [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "b9c7aa568136493797109b873ebe3616",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"tokenizer_config.json: 0%| | 0.00/26.0 [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "0808ee0189734b6ba992df2be9d4f15f",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"vocab.json: 0%| | 0.00/1.04M [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "ea77452dd7d0402991cfadc717a47d19",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"merges.txt: 0%| | 0.00/456k [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "db0c8ba302844fd5982c6ac996fbb868",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"tokenizer.json: 0%| | 0.00/1.36M [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Device set to use cpu\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from praisonaiagents import Agent\n",
|
||||
"from transformers import pipeline as hf_pipeline\n",
|
||||
"import openai\n",
|
||||
"\n",
|
||||
"openai.api_key = os.getenv('OPENAI_API_KEY')\n",
|
||||
"\n",
|
||||
"# Fallback NLP tool\n",
|
||||
"hf_chatbot = hf_pipeline('text-generation', model='gpt2')\n",
|
||||
"\n",
|
||||
"# Create smart Agent with praisonaiagents\n",
|
||||
"agent = Agent(instructions='You are a friendly tutor. Answer learner questions clearly and helpfully.')\n",
|
||||
"\n",
|
||||
"def chat_with_ai(user_input):\n",
|
||||
" try:\n",
|
||||
" return agent.start(user_input)\n",
|
||||
" except Exception as e:\n",
|
||||
" print('[Fallback GPT-2] ', e)\n",
|
||||
" return hf_chatbot(user_input, max_length=100)[0]['generated_text']"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000,
|
||||
"referenced_widgets": [
|
||||
"be1777343939486c941c1959f7632104",
|
||||
"1e3a02318cb642cb9304dece111a70cc",
|
||||
"7dca42e3bc724c6e9f63fd049a4539ea",
|
||||
"5b4ade0a459e42d38bc3cf84f01f6538"
|
||||
]
|
||||
},
|
||||
"id": "vELE_tDT-RaN",
|
||||
"outputId": "8ac6cf86-7894-47a0-b47b-cbc1cb474b41"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"You: What is the Pythagorean theorem?\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Agent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Assistant</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mAgent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mAssistant\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "be1777343939486c941c1959f7632104",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 6.8s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 6.8s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> What is the Pythagorean theorem? <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m What is the Pythagorean theorem? \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> The Pythagorean theorem is a fundamental principle in geometry that relates to right-angled triangles. It <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> states that in a right-angled triangle, the square of the length of the hypotenuse (the side opposite the right <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> angle) is equal to the sum of the squares of the lengths of the other two sides. This can be expressed with the <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> formula: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> [ a^2 + b^2 = c^2 ] <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Here, ( c ) represents the length of the hypotenuse, while ( a ) and ( b ) represent the lengths of the other <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> two sides. This theorem is useful for calculating the length of one side of a right triangle if the lengths of <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> the other two sides are known. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m The Pythagorean theorem is a fundamental principle in geometry that relates to right-angled triangles. It \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m states that in a right-angled triangle, the square of the length of the hypotenuse (the side opposite the right \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m angle) is equal to the sum of the squares of the lengths of the other two sides. This can be expressed with the \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m formula: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m [ a^2 + b^2 = c^2 ] \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Here, ( c ) represents the length of the hypotenuse, while ( a ) and ( b ) represent the lengths of the other \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m two sides. This theorem is useful for calculating the length of one side of a right triangle if the lengths of \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m the other two sides are known. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"🤖 Tutor: The Pythagorean theorem is a fundamental principle in geometry that relates to right-angled triangles. It states that in a right-angled triangle, the square of the length of the hypotenuse (the side opposite the right angle) is equal to the sum of the squares of the lengths of the other two sides. This can be expressed with the formula:\n",
|
||||
"\n",
|
||||
"\\[ a^2 + b^2 = c^2 \\]\n",
|
||||
"\n",
|
||||
"Here, \\( c \\) represents the length of the hypotenuse, while \\( a \\) and \\( b \\) represent the lengths of the other two sides. This theorem is useful for calculating the length of one side of a right triangle if the lengths of the other two sides are known.\n",
|
||||
"You: How does photosynthesis work?\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Agent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Assistant</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mAgent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mAssistant\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "7dca42e3bc724c6e9f63fd049a4539ea",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 7.2s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 7.2s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> How does photosynthesis work? <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m How does photosynthesis work? \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Photosynthesis is the process by which green plants, algae, and some bacteria convert light energy, usually <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> from the sun, into chemical energy stored in glucose. This process is essential for life on Earth as it <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> provides the oxygen we breathe and forms the base of the food chain. Here's how it works: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">Light Absorption</span>: Photosynthesis begins when chlorophyll, the green pigment in plant cells, absorbs <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>sunlight. This primarily occurs in the chloroplasts of plant cells. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">Water Splitting (Photolysis)</span>: The absorbed light energy is used to split water molecules (H₂O) into oxygen, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>protons, and electrons. This reaction releases oxygen as a byproduct, which is expelled into the atmosphere. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">Energy Conversion (Light Reactions)</span>: The electrons and protons generated from water splitting are used in <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>the light-dependent reactions. These reactions occur in the thylakoid membranes of the chloroplasts and <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>result in the production of ATP (adenosine triphosphate) and NADPH, which are energy carriers. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 4 </span><span style=\"font-weight: bold\">Carbon Fixation (Calvin Cycle)</span>: In the light-independent reactions, also known as the Calvin Cycle, ATP and <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>NADPH produced in the light reactions are used to convert carbon dioxide (CO₂) from the atmosphere into <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>glucose (C₆H₁₂O₆). This process occurs in the stroma of the chloroplasts. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 5 </span><span style=\"font-weight: bold\">Glucose Formation</span>: The glucose produced can be used immediately by the plant for energy or can be converted <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>into other carbohydrates, such as starch, for storage. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Overall, the simplified equation for photosynthesis is: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> [ 6CO₂ + 6H₂O + light \\ energy \\rightarrow C₆H₁₂O₆ + 6O₂ ] <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> This equation shows that carbon dioxide and water, in the presence of light energy, are transformed into <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> glucose and oxygen. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Photosynthesis is the process by which green plants, algae, and some bacteria convert light energy, usually \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m from the sun, into chemical energy stored in glucose. This process is essential for life on Earth as it \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m provides the oxygen we breathe and forms the base of the food chain. Here's how it works: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0m\u001b[1mLight Absorption\u001b[0m: Photosynthesis begins when chlorophyll, the green pigment in plant cells, absorbs \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0msunlight. This primarily occurs in the chloroplasts of plant cells. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mWater Splitting (Photolysis)\u001b[0m: The absorbed light energy is used to split water molecules (H₂O) into oxygen, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mprotons, and electrons. This reaction releases oxygen as a byproduct, which is expelled into the atmosphere. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0m\u001b[1mEnergy Conversion (Light Reactions)\u001b[0m: The electrons and protons generated from water splitting are used in \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mthe light-dependent reactions. These reactions occur in the thylakoid membranes of the chloroplasts and \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mresult in the production of ATP (adenosine triphosphate) and NADPH, which are energy carriers. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 4 \u001b[0m\u001b[1mCarbon Fixation (Calvin Cycle)\u001b[0m: In the light-independent reactions, also known as the Calvin Cycle, ATP and \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mNADPH produced in the light reactions are used to convert carbon dioxide (CO₂) from the atmosphere into \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mglucose (C₆H₁₂O₆). This process occurs in the stroma of the chloroplasts. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 5 \u001b[0m\u001b[1mGlucose Formation\u001b[0m: The glucose produced can be used immediately by the plant for energy or can be converted \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0minto other carbohydrates, such as starch, for storage. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Overall, the simplified equation for photosynthesis is: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m [ 6CO₂ + 6H₂O + light \\ energy \\rightarrow C₆H₁₂O₆ + 6O₂ ] \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m This equation shows that carbon dioxide and water, in the presence of light energy, are transformed into \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m glucose and oxygen. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"🤖 Tutor: Photosynthesis is the process by which green plants, algae, and some bacteria convert light energy, usually from the sun, into chemical energy stored in glucose. This process is essential for life on Earth as it provides the oxygen we breathe and forms the base of the food chain. Here's how it works:\n",
|
||||
"\n",
|
||||
"1. **Light Absorption**: Photosynthesis begins when chlorophyll, the green pigment in plant cells, absorbs sunlight. This primarily occurs in the chloroplasts of plant cells.\n",
|
||||
"\n",
|
||||
"2. **Water Splitting (Photolysis)**: The absorbed light energy is used to split water molecules (H₂O) into oxygen, protons, and electrons. This reaction releases oxygen as a byproduct, which is expelled into the atmosphere.\n",
|
||||
"\n",
|
||||
"3. **Energy Conversion (Light Reactions)**: The electrons and protons generated from water splitting are used in the light-dependent reactions. These reactions occur in the thylakoid membranes of the chloroplasts and result in the production of ATP (adenosine triphosphate) and NADPH, which are energy carriers.\n",
|
||||
"\n",
|
||||
"4. **Carbon Fixation (Calvin Cycle)**: In the light-independent reactions, also known as the Calvin Cycle, ATP and NADPH produced in the light reactions are used to convert carbon dioxide (CO₂) from the atmosphere into glucose (C₆H₁₂O₆). This process occurs in the stroma of the chloroplasts.\n",
|
||||
"\n",
|
||||
"5. **Glucose Formation**: The glucose produced can be used immediately by the plant for energy or can be converted into other carbohydrates, such as starch, for storage.\n",
|
||||
"\n",
|
||||
"Overall, the simplified equation for photosynthesis is:\n",
|
||||
"\n",
|
||||
"\\[ 6CO₂ + 6H₂O + light \\ energy \\rightarrow C₆H₁₂O₆ + 6O₂ \\]\n",
|
||||
"\n",
|
||||
"This equation shows that carbon dioxide and water, in the presence of light energy, are transformed into glucose and oxygen.\n",
|
||||
"You: stop\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Agent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Assistant</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mAgent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mAssistant\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 0.5s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 0.5s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> stop <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m stop \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> If you have any more questions or need further assistance, feel free to ask! <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m If you have any more questions or need further assistance, feel free to ask! \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"🤖 Tutor: If you have any more questions or need further assistance, feel free to ask!\n",
|
||||
"You: exit\n",
|
||||
"Goodbye! Happy learning!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"while True:\n",
|
||||
" user_input = input('You: ')\n",
|
||||
" if user_input.lower() in ['exit','quit']:\n",
|
||||
" print('Goodbye! Happy learning!')\n",
|
||||
" break\n",
|
||||
" response = chat_with_ai(user_input)\n",
|
||||
" print('🤖 Tutor:', response)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,402 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "Fi_y0ooAzjjy"
|
||||
},
|
||||
"source": [
|
||||
"# AI Market & Startup Trend Agent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "M18iBcPYzl9d"
|
||||
},
|
||||
"source": [
|
||||
"* An AI-powered agent that analyzes current market and startup trends using real-time news, web search, and multi-agent collaboration.\n",
|
||||
"* The agent collects recent articles, summarizes key insights, and identifies emerging opportunities for entrepreneurs and investors.\n",
|
||||
"* Features include automated news gathering, trend summarization, and actionable reports on startup opportunities in any area of interest."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "SfsvzoD_3JtE"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/ai_market_startup_trend_agent.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "6par7OlW0KVF"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "oJA89ujM0OSd"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonai streamlit duckduckgo-search \"newspaper3k[lxml]\" anthropic lxml_html_clean"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "bK4r7sQ_0hz0"
|
||||
},
|
||||
"source": [
|
||||
"# Setup Key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "9UViB-oJ0izp",
|
||||
"outputId": "f1db522f-5e30-4f14-8fc1-5c5b814a10c7"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"✅ Anthropic API key configured!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Setup Key\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"# Set your Anthropic API key\n",
|
||||
"anthropic_key = \"your_anthropic_key_here\" # Get from https://console.anthropic.com\n",
|
||||
"\n",
|
||||
"# Set environment variable\n",
|
||||
"os.environ[\"ANTHROPIC_API_KEY\"] = anthropic_key\n",
|
||||
"\n",
|
||||
"print(\"✅ Anthropic API key configured!\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "TX6AKmiE0sK3"
|
||||
},
|
||||
"source": [
|
||||
"# Tools"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {
|
||||
"id": "afU4kjcz0tCk"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Custom News & Trend Analysis Tools\n",
|
||||
"\n",
|
||||
"from duckduckgo_search import DDGS\n",
|
||||
"from newspaper import Article\n",
|
||||
"from typing import List, Dict, Any\n",
|
||||
"\n",
|
||||
"class NewsSearchTool:\n",
|
||||
" def __init__(self, max_results: int = 5):\n",
|
||||
" self.max_results = max_results\n",
|
||||
"\n",
|
||||
" def search_news(self, topic: str) -> List[Dict[str, Any]]:\n",
|
||||
" \"\"\"Search for recent news articles on a topic using DuckDuckGo.\"\"\"\n",
|
||||
" results = []\n",
|
||||
" with DDGS() as ddgs:\n",
|
||||
" for r in ddgs.news(topic, max_results=self.max_results):\n",
|
||||
" results.append({\n",
|
||||
" \"title\": r.get(\"title\"),\n",
|
||||
" \"url\": r.get(\"url\"),\n",
|
||||
" \"date\": r.get(\"date\"),\n",
|
||||
" \"body\": r.get(\"body\")\n",
|
||||
" })\n",
|
||||
" return results\n",
|
||||
"\n",
|
||||
"class ArticleSummaryTool:\n",
|
||||
" def summarize_articles(self, articles: List[Dict[str, Any]]) -> List[Dict[str, Any]]:\n",
|
||||
" \"\"\"Summarize the content of news articles using Newspaper3k.\"\"\"\n",
|
||||
" summaries = []\n",
|
||||
" for article in articles:\n",
|
||||
" try:\n",
|
||||
" a = Article(article[\"url\"])\n",
|
||||
" a.download()\n",
|
||||
" a.parse()\n",
|
||||
" a.nlp()\n",
|
||||
" summaries.append({\n",
|
||||
" \"title\": article[\"title\"],\n",
|
||||
" \"summary\": a.summary,\n",
|
||||
" \"url\": article[\"url\"]\n",
|
||||
" })\n",
|
||||
" except Exception as e:\n",
|
||||
" summaries.append({\n",
|
||||
" \"title\": article[\"title\"],\n",
|
||||
" \"summary\": f\"Error summarizing article: {str(e)}\",\n",
|
||||
" \"url\": article[\"url\"]\n",
|
||||
" })\n",
|
||||
" return summaries\n",
|
||||
"\n",
|
||||
"class TrendInsightTool:\n",
|
||||
" def extract_trends(self, summaries: List[Dict[str, Any]]) -> Dict[str, Any]:\n",
|
||||
" \"\"\"Extract and aggregate trend insights from article summaries.\"\"\"\n",
|
||||
" all_text = \" \".join([s[\"summary\"] for s in summaries if \"summary\" in s])\n",
|
||||
" # For demo: just return the combined summaries\n",
|
||||
" # In production: use LLM to extract trends and opportunities\n",
|
||||
" return {\n",
|
||||
" \"trend_report\": all_text[:2000] + (\"...\" if len(all_text) > 2000 else \"\")\n",
|
||||
" }"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "CVCoaGTO0-Ue"
|
||||
},
|
||||
"source": [
|
||||
"# YAML Prompt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "6xu0NeHy0_ZV",
|
||||
"outputId": "2d85f20a-8af4-49a4-ec76-9db4102e0d51"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"✅ YAML Prompt configured!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# YAML Prompt\n",
|
||||
"yaml_prompt = \"\"\"\n",
|
||||
"name: \"AI Market & Startup Trend Agent\"\n",
|
||||
"description: \"Expert market analyst that gathers, summarizes, and analyzes startup and market trends from real-time news sources\"\n",
|
||||
"instructions:\n",
|
||||
" - \"You are an expert market and startup trend analyst\"\n",
|
||||
" - \"Search for the latest news and articles on the user's topic of interest\"\n",
|
||||
" - \"Summarize the key points and insights from each article\"\n",
|
||||
" - \"Aggregate the summaries to identify emerging trends and startup opportunities\"\n",
|
||||
" - \"Present findings in a clear, actionable report for entrepreneurs and investors\"\n",
|
||||
" - \"Cite sources and provide links to original articles\"\n",
|
||||
" - \"Highlight any patterns, risks, or opportunities you discover\"\n",
|
||||
" - \"Use bullet points and markdown formatting for clarity\"\n",
|
||||
"\n",
|
||||
"tools:\n",
|
||||
" - name: \"NewsSearchTool\"\n",
|
||||
" description: \"Searches for recent news articles on a given topic using DuckDuckGo\"\n",
|
||||
" - name: \"ArticleSummaryTool\"\n",
|
||||
" description: \"Summarizes the content of news articles using Newspaper3k\"\n",
|
||||
" - name: \"TrendInsightTool\"\n",
|
||||
" description: \"Extracts and aggregates trend insights from article summaries\"\n",
|
||||
"\n",
|
||||
"output_format:\n",
|
||||
" - \"Provide a trend analysis report with actionable insights\"\n",
|
||||
" - \"Include a list of summarized articles with links\"\n",
|
||||
" - \"Highlight key opportunities and risks\"\n",
|
||||
" - \"Use clear, structured formatting with sections for news, summaries, and trends\"\n",
|
||||
"\n",
|
||||
"temperature: 0.4\n",
|
||||
"max_tokens: 3500\n",
|
||||
"model: \"claude-3-5-sonnet\"\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"print(\"✅ YAML Prompt configured!\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "MaX_eyRB1jtF"
|
||||
},
|
||||
"source": [
|
||||
"# Main"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"collapsed": true,
|
||||
"id": "fmMkG5hR1lS7",
|
||||
"outputId": "0833615c-c919-406e-9646-9cd8d74f78ed"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[nltk_data] Error loading tokenizers/punkt: Package 'tokenizers/punkt'\n",
|
||||
"[nltk_data] not found in index\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"📈 AI Market & Startup Trend Agent\n",
|
||||
"Analyze current market and startup trends using real-time news and AI summarization!\n",
|
||||
"\n",
|
||||
"Enter the area of interest for your Startup or Market Trend Analysis: Chennai\n",
|
||||
"\n",
|
||||
"🔍 Searching for recent news on: Chennai\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/tmp/ipython-input-6-1293765785.py:14: RuntimeWarning: This package (`duckduckgo_search`) has been renamed to `ddgs`! Use `pip install ddgs` instead.\n",
|
||||
" with DDGS() as ddgs:\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"✅ Found 5 articles. Summarizing...\n",
|
||||
"\n",
|
||||
"📰 Article Summaries:\n",
|
||||
"1. Chennai woman breaks down in front of traffic cop, shares the reason in viral post\n",
|
||||
" \n",
|
||||
" [Read more](https://www.msn.com/en-in/news/other/chennai-woman-breaks-down-in-front-of-traffic-cop-shares-the-reason-in-viral-post/ar-AA1IalYh)\n",
|
||||
"\n",
|
||||
"2. Chennai founder breaks down in front of traffic police after his unexpected question: 'And that's when the tears came'\n",
|
||||
" \n",
|
||||
" [Read more](https://www.msn.com/en-in/news/India/chennai-founder-breaks-down-in-front-of-traffic-police-after-his-unexpected-question-and-that-s-when-the-tears-came/ar-AA1Ia579)\n",
|
||||
"\n",
|
||||
"3. Explore India's coastal flavours at this Chennai food fest\n",
|
||||
" \n",
|
||||
" [Read more](https://www.msn.com/en-in/foodanddrink/other/explore-indias-coastal-flavours-at-this-chennai-food-fest/ar-AA1Iax3e)\n",
|
||||
"\n",
|
||||
"4. Chennai weather update: Expect patchy rain and a warm summer day\n",
|
||||
" \n",
|
||||
" [Read more](https://www.msn.com/en-in/news/india/chennai-weather-update-expect-patchy-rain-and-a-warm-summer-day/ar-AA1I9ECV)\n",
|
||||
"\n",
|
||||
"5. Chennai Power Outage Alert: Check Areas That Will Face Supply Disruption On July 8 For Maintenance Work\n",
|
||||
" \n",
|
||||
" [Read more](https://www.msn.com/en-in/autos/photos/chennai-power-outage-alert-check-areas-that-will-face-supply-disruption-on-july-8-for-maintenance-work/ar-AA1I9KIg)\n",
|
||||
"\n",
|
||||
"📊 Analyzing trends and opportunities...\n",
|
||||
"\n",
|
||||
"=== Trend Analysis Report ===\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"🧪 Sample Topics for Testing\n",
|
||||
"1. AI in healthcare\n",
|
||||
"2. Sustainable energy startups\n",
|
||||
"3. Fintech innovation\n",
|
||||
"4. Remote work technology\n",
|
||||
"5. Climate tech investments\n",
|
||||
"\n",
|
||||
"==================================================\n",
|
||||
"📈 Powered by AI Market & Startup Trend Agent | Built with PraisonAI\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Main Application (Google Colab Version)\n",
|
||||
"import os\n",
|
||||
"import warnings\n",
|
||||
"warnings.filterwarnings(\"ignore\", category=ImportWarning)\n",
|
||||
"\n",
|
||||
"# Download all necessary NLTK data for newspaper3k\n",
|
||||
"import nltk\n",
|
||||
"nltk.download('tokenizers/punkt')\n",
|
||||
"nltk.download('averaged_perceptron_tagger', quiet=True)\n",
|
||||
"nltk.download('maxent_ne_chunker', quiet=True)\n",
|
||||
"nltk.download('words', quiet=True)\n",
|
||||
"\n",
|
||||
"# Initialize tools\n",
|
||||
"news_tool = NewsSearchTool()\n",
|
||||
"summary_tool = ArticleSummaryTool()\n",
|
||||
"trend_tool = TrendInsightTool()\n",
|
||||
"\n",
|
||||
"print(\"📈 AI Market & Startup Trend Agent\")\n",
|
||||
"print(\"Analyze current market and startup trends using real-time news and AI summarization!\")\n",
|
||||
"\n",
|
||||
"# User input\n",
|
||||
"topic = input(\"\\nEnter the area of interest for your Startup or Market Trend Analysis: \").strip()\n",
|
||||
"\n",
|
||||
"if topic:\n",
|
||||
" print(f\"\\n🔍 Searching for recent news on: {topic}\")\n",
|
||||
" articles = news_tool.search_news(topic)\n",
|
||||
" if articles:\n",
|
||||
" print(f\"✅ Found {len(articles)} articles. Summarizing...\")\n",
|
||||
" summaries = summary_tool.summarize_articles(articles)\n",
|
||||
" print(\"\\n📰 Article Summaries:\")\n",
|
||||
" for i, s in enumerate(summaries, 1):\n",
|
||||
" print(f\"{i}. {s['title']}\")\n",
|
||||
" print(f\" {s['summary']}\")\n",
|
||||
" print(f\" [Read more]({s['url']})\\n\")\n",
|
||||
"\n",
|
||||
" print(\"📊 Analyzing trends and opportunities...\")\n",
|
||||
" trend_report = trend_tool.extract_trends(summaries)\n",
|
||||
" print(\"\\n=== Trend Analysis Report ===\")\n",
|
||||
" print(trend_report[\"trend_report\"])\n",
|
||||
" else:\n",
|
||||
" print(\"❌ No news articles found for this topic.\")\n",
|
||||
"else:\n",
|
||||
" print(\"❌ No topic entered. Please provide a topic to analyze.\")\n",
|
||||
"\n",
|
||||
"# Sample topics for testing\n",
|
||||
"print(\"\\n🧪 Sample Topics for Testing\")\n",
|
||||
"sample_topics = [\n",
|
||||
" \"AI in healthcare\",\n",
|
||||
" \"Sustainable energy startups\",\n",
|
||||
" \"Fintech innovation\",\n",
|
||||
" \"Remote work technology\",\n",
|
||||
" \"Climate tech investments\"\n",
|
||||
"]\n",
|
||||
"for i, t in enumerate(sample_topics, 1):\n",
|
||||
" print(f\"{i}. {t}\")\n",
|
||||
"\n",
|
||||
"# Footer\n",
|
||||
"print(\"\\n\" + \"=\"*50)\n",
|
||||
"print(\"📈 Powered by AI Market & Startup Trend Agent | Built with PraisonAI\")"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
@@ -0,0 +1,482 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "y8L9VFhhdjhL"
|
||||
},
|
||||
"source": [
|
||||
"# Financial Coaching Agent using PraisonAIAgents"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "6UxqTg7pdkm-"
|
||||
},
|
||||
"source": [
|
||||
"This notebook demonstrates how to build a Financial Coaching Agent using the `praisonaiagents` library.\n",
|
||||
"The agent analyzes user financial data and provides actionable recommendations for budgeting, savings, and debt management.\n",
|
||||
"The notebook is CI-friendly: it uses dummy data if API keys are not set, so all tests/checks will pass."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "CNqB5dPffV3m"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/Finance_Market_Job_Agents/Financial_Coaching_Agent.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "3cdm72N2doNq"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "Pl85wGWzdpTK"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonaiagents pandas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "YOlEEkk4ePqy"
|
||||
},
|
||||
"source": [
|
||||
"# Set up key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"id": "T9zKRkv_eRsc"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"# Try to get keys from environment variables, or use placeholders\n",
|
||||
"OPENAI_API_KEY = os.environ.get(\"OPENAI_API_KEY\", \"sk-..\")\n",
|
||||
"\n",
|
||||
"# Set them in the environment for downstream code\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = OPENAI_API_KEY\n",
|
||||
"\n",
|
||||
"def is_valid_key(key, prefix):\n",
|
||||
" return key and key != f\"{prefix}-..\" and key.startswith(prefix)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "FGYJpB9eeaSY"
|
||||
},
|
||||
"source": [
|
||||
"# Tool: Financial Summary"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"id": "asLRt9gAecJ2"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"\n",
|
||||
"class FinancialSummaryTool:\n",
|
||||
" \"\"\"\n",
|
||||
" Custom tool to summarize financial data and calculate basic stats.\n",
|
||||
" \"\"\"\n",
|
||||
" def __init__(self, income, expenses, debts):\n",
|
||||
" self.income = income\n",
|
||||
" self.expenses = expenses\n",
|
||||
" self.debts = debts\n",
|
||||
"\n",
|
||||
" def summary(self):\n",
|
||||
" total_expenses = sum(self.expenses.values())\n",
|
||||
" surplus = self.income - total_expenses\n",
|
||||
" total_debt = sum(d['amount'] for d in self.debts)\n",
|
||||
" return {\n",
|
||||
" \"total_expenses\": total_expenses,\n",
|
||||
" \"surplus\": surplus,\n",
|
||||
" \"total_debt\": total_debt,\n",
|
||||
" \"expense_breakdown\": self.expenses,\n",
|
||||
" \"debts\": self.debts\n",
|
||||
" }"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "lIysLOOdef3b"
|
||||
},
|
||||
"source": [
|
||||
"# YAML prompt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "GDbWRmp2egsz",
|
||||
"outputId": "cf4e4d15-7446-4613-9a20-298674f0b4d3"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{'agent': {'name': 'Financial Coaching Agent', 'description': 'An agent that analyzes user financial data and provides actionable recommendations for budgeting, savings, and debt management.\\n', 'tools': [{'name': 'FinancialSummaryTool', 'description': 'Summarizes income, expenses, and debts for the agent.'}], 'workflow': [{'step': 'Summarize financial data using FinancialSummaryTool'}, {'step': 'Analyze summary and provide recommendations'}]}, 'inputs': ['monthly_income', 'expenses', 'debts'], 'outputs': ['recommendations']}\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import yaml\n",
|
||||
"\n",
|
||||
"yaml_prompt = \"\"\"\n",
|
||||
"agent:\n",
|
||||
" name: Financial Coaching Agent\n",
|
||||
" description: |\n",
|
||||
" An agent that analyzes user financial data and provides actionable recommendations for budgeting, savings, and debt management.\n",
|
||||
" tools:\n",
|
||||
" - name: FinancialSummaryTool\n",
|
||||
" description: Summarizes income, expenses, and debts for the agent.\n",
|
||||
" workflow:\n",
|
||||
" - step: Summarize financial data using FinancialSummaryTool\n",
|
||||
" - step: Analyze summary and provide recommendations\n",
|
||||
"inputs:\n",
|
||||
" - monthly_income\n",
|
||||
" - expenses\n",
|
||||
" - debts\n",
|
||||
"outputs:\n",
|
||||
" - recommendations\n",
|
||||
"\"\"\"\n",
|
||||
"print(yaml.safe_load(yaml_prompt))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "C-FE-hTKekHK"
|
||||
},
|
||||
"source": [
|
||||
"# Main"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000,
|
||||
"referenced_widgets": [
|
||||
"b27151e0a1ec47d8a36433ef503eede2",
|
||||
"58e152a95c1d49d68b45aea3b837b6d3"
|
||||
]
|
||||
},
|
||||
"id": "48oIH5LYek-q",
|
||||
"outputId": "b501eae2-63c2-434d-f5c3-abba6b93956e"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Financial Coaching Agent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Assistant</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mFinancial Coaching Agent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mAssistant\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "b27151e0a1ec47d8a36433ef503eede2",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 11.0s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 11.0s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> You are a financial coach. Analyze the following summary and provide actionable recommendations: - Monthly <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> income: $3000 - Total expenses: $2350 - Surplus: $650 - Total debt: $10000 - Expense breakdown: {'Housing': <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> 1200, 'Food': 400, 'Transportation': 200, 'Entertainment': 150, 'Savings': 300, 'Other': 100} - Debts: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> [{'name': 'Credit Card', 'amount': 2000, 'interest_rate': 18.0, 'min_payment': 50}, {'name': 'Student Loan', <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> 'amount': 8000, 'interest_rate': 5.0, 'min_payment': 100}] <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m You are a financial coach. Analyze the following summary and provide actionable recommendations: - Monthly \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m income: $3000 - Total expenses: $2350 - Surplus: $650 - Total debt: $10000 - Expense breakdown: {'Housing': \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m 1200, 'Food': 400, 'Transportation': 200, 'Entertainment': 150, 'Savings': 300, 'Other': 100} - Debts: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m [{'name': 'Credit Card', 'amount': 2000, 'interest_rate': 18.0, 'min_payment': 50}, {'name': 'Student Loan', \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m 'amount': 8000, 'interest_rate': 5.0, 'min_payment': 100}] \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Based on the provided financial summary, here are some actionable recommendations to help manage your finances <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> more effectively and reduce your debt: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">Prioritize Debt Repayment:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Focus on paying off the high-interest debt first, which is the credit card debt with an 18% interest <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>rate. Consider using the debt avalanche method, where you pay extra towards the debt with the highest <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>interest rate while making minimum payments on others. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>With a surplus of $650, allocate a significant portion of this towards the credit card debt. For example, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>you could pay $400 towards the credit card debt (including the $50 minimum payment), which would help <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>reduce the principal faster and save on interest. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">Review and Adjust Expenses:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Housing:</span> At $1200, housing is a significant portion of your expenses. If possible, explore options to <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>reduce this cost, such as negotiating rent, finding a roommate, or moving to a less expensive place. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Food:</span> Consider meal planning, cooking at home, and reducing dining out to lower the $400 food expense. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Entertainment:</span> At $150, see if you can cut back on discretionary spending. Look for free or low-cost <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>entertainment options. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Other Expenses:</span> Review the $100 in 'Other' expenses to identify any non-essential spending that can be <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>reduced or eliminated. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">Increase Savings:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>While you are already saving $300 monthly, consider increasing this amount once the high-interest debt is <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>paid off. Building an emergency fund should be a priority to cover 3-6 months of expenses. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 4 </span><span style=\"font-weight: bold\">Boost Income:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Explore opportunities to increase your income, such as taking on a part-time job, freelancing, or selling <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>unused items. Any additional income can accelerate debt repayment and increase savings. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 5 </span><span style=\"font-weight: bold\">Monitor and Adjust:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Regularly review your budget and expenses to ensure you are on track with your financial goals. Adjust <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>your plan as needed to accommodate changes in income or expenses. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 6 </span><span style=\"font-weight: bold\">Consider Debt Consolidation:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>If you have a good credit score, look into consolidating your credit card debt into a lower-interest <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>personal loan. This could reduce your overall interest payments and simplify your debt repayment process. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> By implementing these recommendations, you can effectively manage your finances, reduce debt, and work towards <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> achieving greater financial stability. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Based on the provided financial summary, here are some actionable recommendations to help manage your finances \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m more effectively and reduce your debt: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0m\u001b[1mPrioritize Debt Repayment:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mFocus on paying off the high-interest debt first, which is the credit card debt with an 18% interest \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mrate. Consider using the debt avalanche method, where you pay extra towards the debt with the highest \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0minterest rate while making minimum payments on others. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mWith a surplus of $650, allocate a significant portion of this towards the credit card debt. For example, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0myou could pay $400 towards the credit card debt (including the $50 minimum payment), which would help \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mreduce the principal faster and save on interest. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mReview and Adjust Expenses:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mHousing:\u001b[0m At $1200, housing is a significant portion of your expenses. If possible, explore options to \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mreduce this cost, such as negotiating rent, finding a roommate, or moving to a less expensive place. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mFood:\u001b[0m Consider meal planning, cooking at home, and reducing dining out to lower the $400 food expense. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mEntertainment:\u001b[0m At $150, see if you can cut back on discretionary spending. Look for free or low-cost \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mentertainment options. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mOther Expenses:\u001b[0m Review the $100 in 'Other' expenses to identify any non-essential spending that can be \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mreduced or eliminated. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0m\u001b[1mIncrease Savings:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mWhile you are already saving $300 monthly, consider increasing this amount once the high-interest debt is \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mpaid off. Building an emergency fund should be a priority to cover 3-6 months of expenses. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 4 \u001b[0m\u001b[1mBoost Income:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mExplore opportunities to increase your income, such as taking on a part-time job, freelancing, or selling \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0munused items. Any additional income can accelerate debt repayment and increase savings. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 5 \u001b[0m\u001b[1mMonitor and Adjust:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mRegularly review your budget and expenses to ensure you are on track with your financial goals. Adjust \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0myour plan as needed to accommodate changes in income or expenses. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 6 \u001b[0m\u001b[1mConsider Debt Consolidation:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mIf you have a good credit score, look into consolidating your credit card debt into a lower-interest \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mpersonal loan. This could reduce your overall interest payments and simplify your debt repayment process. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m By implementing these recommendations, you can effectively manage your finances, reduce debt, and work towards \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m achieving greater financial stability. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"=== Financial Coaching Agent Recommendations ===\n",
|
||||
"Based on the provided financial summary, here are some actionable recommendations to help manage your finances more effectively and reduce your debt:\n",
|
||||
"\n",
|
||||
"1. **Prioritize Debt Repayment:**\n",
|
||||
" - Focus on paying off the high-interest debt first, which is the credit card debt with an 18% interest rate. Consider using the debt avalanche method, where you pay extra towards the debt with the highest interest rate while making minimum payments on others.\n",
|
||||
" - With a surplus of $650, allocate a significant portion of this towards the credit card debt. For example, you could pay $400 towards the credit card debt (including the $50 minimum payment), which would help reduce the principal faster and save on interest.\n",
|
||||
"\n",
|
||||
"2. **Review and Adjust Expenses:**\n",
|
||||
" - **Housing:** At $1200, housing is a significant portion of your expenses. If possible, explore options to reduce this cost, such as negotiating rent, finding a roommate, or moving to a less expensive place.\n",
|
||||
" - **Food:** Consider meal planning, cooking at home, and reducing dining out to lower the $400 food expense.\n",
|
||||
" - **Entertainment:** At $150, see if you can cut back on discretionary spending. Look for free or low-cost entertainment options.\n",
|
||||
" - **Other Expenses:** Review the $100 in 'Other' expenses to identify any non-essential spending that can be reduced or eliminated.\n",
|
||||
"\n",
|
||||
"3. **Increase Savings:**\n",
|
||||
" - While you are already saving $300 monthly, consider increasing this amount once the high-interest debt is paid off. Building an emergency fund should be a priority to cover 3-6 months of expenses.\n",
|
||||
"\n",
|
||||
"4. **Boost Income:**\n",
|
||||
" - Explore opportunities to increase your income, such as taking on a part-time job, freelancing, or selling unused items. Any additional income can accelerate debt repayment and increase savings.\n",
|
||||
"\n",
|
||||
"5. **Monitor and Adjust:**\n",
|
||||
" - Regularly review your budget and expenses to ensure you are on track with your financial goals. Adjust your plan as needed to accommodate changes in income or expenses.\n",
|
||||
"\n",
|
||||
"6. **Consider Debt Consolidation:**\n",
|
||||
" - If you have a good credit score, look into consolidating your credit card debt into a lower-interest personal loan. This could reduce your overall interest payments and simplify your debt repayment process.\n",
|
||||
"\n",
|
||||
"By implementing these recommendations, you can effectively manage your finances, reduce debt, and work towards achieving greater financial stability.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from praisonaiagents import Agent\n",
|
||||
"\n",
|
||||
"# Dummy data for CI/public use\n",
|
||||
"dummy_financial_data = {\n",
|
||||
" \"monthly_income\": 3000,\n",
|
||||
" \"expenses\": {\n",
|
||||
" \"Housing\": 1200,\n",
|
||||
" \"Food\": 400,\n",
|
||||
" \"Transportation\": 200,\n",
|
||||
" \"Entertainment\": 150,\n",
|
||||
" \"Savings\": 300,\n",
|
||||
" \"Other\": 100\n",
|
||||
" },\n",
|
||||
" \"debts\": [\n",
|
||||
" {\"name\": \"Credit Card\", \"amount\": 2000, \"interest_rate\": 18.0, \"min_payment\": 50},\n",
|
||||
" {\"name\": \"Student Loan\", \"amount\": 8000, \"interest_rate\": 5.0, \"min_payment\": 100}\n",
|
||||
" ]\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"income = dummy_financial_data[\"monthly_income\"]\n",
|
||||
"expenses = dummy_financial_data[\"expenses\"]\n",
|
||||
"debts = dummy_financial_data[\"debts\"]\n",
|
||||
"\n",
|
||||
"tool = FinancialSummaryTool(income, expenses, debts)\n",
|
||||
"summary = tool.summary()\n",
|
||||
"\n",
|
||||
"if not is_valid_key(OPENAI_API_KEY, \"sk\"):\n",
|
||||
" print(\"API key not set or is a placeholder. Using dummy recommendations for CI/testing.\")\n",
|
||||
" recommendations = \"\"\"\n",
|
||||
" - Review your monthly expenses and identify areas to cut back.\n",
|
||||
" - Increase your monthly savings by at least 10%.\n",
|
||||
" - Pay off high-interest debts first (e.g., Credit Card).\n",
|
||||
" - Build an emergency fund covering at least 3-6 months of expenses.\n",
|
||||
" \"\"\"\n",
|
||||
"else:\n",
|
||||
" prompt = f\"\"\"\n",
|
||||
" You are a financial coach. Analyze the following summary and provide actionable recommendations:\n",
|
||||
" - Monthly income: ${summary['surplus'] + summary['total_expenses']}\n",
|
||||
" - Total expenses: ${summary['total_expenses']}\n",
|
||||
" - Surplus: ${summary['surplus']}\n",
|
||||
" - Total debt: ${summary['total_debt']}\n",
|
||||
" - Expense breakdown: {summary['expense_breakdown']}\n",
|
||||
" - Debts: {summary['debts']}\n",
|
||||
" \"\"\"\n",
|
||||
" agent = Agent(\n",
|
||||
" name=\"Financial Coaching Agent\",\n",
|
||||
" api_key=OPENAI_API_KEY\n",
|
||||
" )\n",
|
||||
" # Use start(prompt) instead of run()\n",
|
||||
" recommendations = agent.start(prompt)\n",
|
||||
"\n",
|
||||
"print(\"=== Financial Coaching Agent Recommendations ===\")\n",
|
||||
"print(recommendations)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
@@ -0,0 +1,681 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "eb153d79",
|
||||
"metadata": {
|
||||
"id": "eb153d79"
|
||||
},
|
||||
"source": [
|
||||
"# Home Buying Real Estate Agent\n",
|
||||
"\n",
|
||||
"Assists users in evaluating and recommending real estate listings."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "N1N183yMfJ_0",
|
||||
"metadata": {
|
||||
"id": "N1N183yMfJ_0"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/Home_Buying_Real_Estate_Agent.ipynb)\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "bTkerYnid8ao",
|
||||
"metadata": {
|
||||
"id": "bTkerYnid8ao"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "51e87f94",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "51e87f94",
|
||||
"outputId": "df61cc7b-72d1-4b51-c5f0-071a6ecd6b8e"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/176.8 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m176.8/176.8 kB\u001b[0m \u001b[31m5.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[?25h\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/130.2 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m130.2/130.2 kB\u001b[0m \u001b[31m6.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[?25h\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/105.4 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m105.4/105.4 kB\u001b[0m \u001b[31m4.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[?25h\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/45.2 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m45.2/45.2 kB\u001b[0m \u001b[31m2.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[?25h"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"!pip install -q praisonaiagents openai"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "fojF7UVJeaI5",
|
||||
"metadata": {
|
||||
"id": "fojF7UVJeaI5"
|
||||
},
|
||||
"source": [
|
||||
"# Set OpenAI API Key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "be325f31",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "be325f31",
|
||||
"outputId": "489cd22b-bf0a-4984-e54a-a94d379d61e9"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Enter your OpenAI API key: ··········\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"from getpass import getpass\n",
|
||||
"\n",
|
||||
"# 🔑 Enter your API Key securely\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = getpass(\"Enter your OpenAI API key: \")\n",
|
||||
"import openai\n",
|
||||
"openai.api_key = os.getenv(\"OPENAI_API_KEY\")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "R1G-5soreoNI",
|
||||
"metadata": {
|
||||
"id": "R1G-5soreoNI"
|
||||
},
|
||||
"source": [
|
||||
"# Import PraisonAI Agent Framework"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "5e58b964",
|
||||
"metadata": {
|
||||
"id": "5e58b964"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from praisonaiagents import Agent, Task, PraisonAIAgents"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "b57756cb",
|
||||
"metadata": {
|
||||
"id": "b57756cb"
|
||||
},
|
||||
"source": [
|
||||
"# YAML configuration style for the agent behavior"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "0efc056c",
|
||||
"metadata": {
|
||||
"id": "0efc056c"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"yaml_prompt = \"\"\"\n",
|
||||
"name: HomeBuyingAssistant\n",
|
||||
"role: Real Estate Advisor Agent\n",
|
||||
"goal: Assist users in making informed decisions when buying residential property.\n",
|
||||
"backstory: You are a knowledgeable real estate advisor helping people plan home purchases, evaluate properties, and understand costs.\n",
|
||||
"skills:\n",
|
||||
" - Mortgage and loan explanation\n",
|
||||
" - Property comparison\n",
|
||||
" - Cost of living and taxes\n",
|
||||
" - First-time homebuyer guidance\n",
|
||||
"llm: gpt-5-nano\n",
|
||||
"verbosity: true\n",
|
||||
"format: markdown\n",
|
||||
"\"\"\"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "f-IQLlIKe1UF",
|
||||
"metadata": {
|
||||
"id": "f-IQLlIKe1UF"
|
||||
},
|
||||
"source": [
|
||||
"# Create the Real Estate Agent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "a3c2ec29",
|
||||
"metadata": {
|
||||
"id": "a3c2ec29"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"real_estate_agent = Agent(\n",
|
||||
" name=\"HomeBuyingAssistant\",\n",
|
||||
" instructions=\"\"\"\n",
|
||||
"You are a home-buying real estate advisor agent.\n",
|
||||
"Help users evaluate neighborhoods, estimate mortgage payments, compare homes, and understand homeownership costs.\n",
|
||||
"Explain clearly, format in markdown, and be friendly but professional.\n",
|
||||
"\"\"\",\n",
|
||||
" llm=\"gpt-5-nano\",\n",
|
||||
" verbose=True,\n",
|
||||
" markdown=True\n",
|
||||
")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "NxRYnlwge7sA",
|
||||
"metadata": {
|
||||
"id": "NxRYnlwge7sA"
|
||||
},
|
||||
"source": [
|
||||
"# Define the Home Buying Task"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"id": "ucU_MEM7e5Vf",
|
||||
"metadata": {
|
||||
"id": "ucU_MEM7e5Vf"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"real_estate_task = Task(\n",
|
||||
" name=\"HomePurchaseGuidance\",\n",
|
||||
" description=\"Guide a first-time homebuyer looking to purchase a 3-bedroom house in Austin, TX under $500,000.\",\n",
|
||||
" expected_output=\"A markdown report with property criteria, mortgage estimate, pros and cons of neighborhoods, and steps to proceed.\",\n",
|
||||
" agent=real_estate_agent\n",
|
||||
")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "72wNG8q4e_iV",
|
||||
"metadata": {
|
||||
"id": "72wNG8q4e_iV"
|
||||
},
|
||||
"source": [
|
||||
"# Create Agent System"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "fP1Xmk8xe-ea",
|
||||
"metadata": {
|
||||
"id": "fP1Xmk8xe-ea"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"home_buying_system = PraisonAIAgents(\n",
|
||||
" agents=[real_estate_agent],\n",
|
||||
" tasks=[real_estate_task],\n",
|
||||
" process=\"sequential\",\n",
|
||||
" verbose=True\n",
|
||||
")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "W7XhaDskfGTo",
|
||||
"metadata": {
|
||||
"id": "W7XhaDskfGTo"
|
||||
},
|
||||
"source": [
|
||||
"# Run the Agent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"id": "1KEkwZbVfD33",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000,
|
||||
"referenced_widgets": [
|
||||
"44f97685092540e3b962554218f00438",
|
||||
"112e5b9377114efe996da4ddbc181454"
|
||||
]
|
||||
},
|
||||
"id": "1KEkwZbVfD33",
|
||||
"outputId": "71f8a42e-d177-462b-f44c-9f97243180ec"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">HomeBuyingAssistant</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Assistant</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mHomeBuyingAssistant\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mAssistant\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "44f97685092540e3b962554218f00438",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 6.6s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 6.6s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> You need to do the following task: Guide a first-time homebuyer looking to purchase a 3-bedroom house in <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Austin, TX under $500,000.. Expected Output: A markdown report with property criteria, mortgage estimate, pros <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> and cons of neighborhoods, and steps to proceed.. Please provide only the final result of your work. Do not add <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> any conversation or extra explanation. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m You need to do the following task: Guide a first-time homebuyer looking to purchase a 3-bedroom house in \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Austin, TX under $500,000.. Expected Output: A markdown report with property criteria, mortgage estimate, pros \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m and cons of neighborhoods, and steps to proceed.. Please provide only the final result of your work. Do not add \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m any conversation or extra explanation. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> ┃ <span style=\"font-weight: bold\">First-Time Homebuyer Guide: 3-Bedroom House in Austin, TX</span> ┃ <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold; text-decoration: underline\">Property Criteria</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Location:</span> Austin, TX <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Type:</span> 3-bedroom house <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Budget:</span> Under $500,000 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold; text-decoration: underline\">Mortgage Estimate</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Assuming a purchase price of $500,000, a 20% down payment, and a 30-year fixed mortgage with an interest rate <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> of 7%: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Down Payment:</span> $100,000 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Loan Amount:</span> $400,000 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Monthly Mortgage Payment:</span> Approximately $2,661 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #800080; text-decoration-color: #800080\">▌ </span><span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">Note: This estimate includes principal and interest only. Taxes, insurance, and HOA fees (if applicable) </span><span style=\"color: #800080; text-decoration-color: #800080\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #800080; text-decoration-color: #800080\">▌ </span><span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">will add to the monthly cost.</span><span style=\"color: #800080; text-decoration-color: #800080\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold; text-decoration: underline\">Neighborhood Evaluation</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\">1. South Austin</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Pros:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Vibrant community with a mix of cultures. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Close to downtown and entertainment options. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Good schools and parks. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Cons:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Traffic congestion during peak hours. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Higher property taxes in some areas. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\">2. North Austin</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Pros:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>More affordable housing options. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Growing tech industry presence. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Family-friendly neighborhoods. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Cons:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Further from downtown. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Limited public transportation options. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\">3. East Austin</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Pros:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Trendy and rapidly developing area. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Rich cultural history and diversity. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Proximity to downtown. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Cons:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Rising property prices. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Gentrification concerns. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\">4. West Austin</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Pros:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Scenic views and outdoor activities. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>High-rated schools. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Quiet and upscale neighborhoods. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Cons:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Higher cost of living. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Limited affordable housing options. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold; text-decoration: underline\">Steps to Proceed</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">Financial Preparation:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Review your credit score and financial standing. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Get pre-approved for a mortgage to understand your budget. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">Neighborhood Research:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Visit potential neighborhoods at different times of the day. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Consider proximity to work, schools, and amenities. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">Engage a Real Estate Agent:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Choose an agent familiar with Austin's market. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Discuss your needs and preferences. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 4 </span><span style=\"font-weight: bold\">House Hunting:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Attend open houses and schedule private showings. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Compare properties based on criteria and budget. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 5 </span><span style=\"font-weight: bold\">Make an Offer:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Work with your agent to make a competitive offer. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Be prepared for negotiations. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 6 </span><span style=\"font-weight: bold\">Home Inspection and Closing:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Conduct a thorough home inspection. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Finalize mortgage details and close the deal. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #800080; text-decoration-color: #800080\">▌ </span><span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">Remember, buying a home is a significant investment. Take your time to ensure it meets your needs and </span><span style=\"color: #800080; text-decoration-color: #800080\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #800080; text-decoration-color: #800080\">▌ </span><span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">financial situation.</span><span style=\"color: #800080; text-decoration-color: #800080\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m ┃ \u001b[1mFirst-Time Homebuyer Guide: 3-Bedroom House in Austin, TX\u001b[0m ┃ \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;4mProperty Criteria\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mLocation:\u001b[0m Austin, TX \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mType:\u001b[0m 3-bedroom house \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mBudget:\u001b[0m Under $500,000 \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;4mMortgage Estimate\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Assuming a purchase price of $500,000, a 20% down payment, and a 30-year fixed mortgage with an interest rate \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m of 7%: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mDown Payment:\u001b[0m $100,000 \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mLoan Amount:\u001b[0m $400,000 \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mMonthly Mortgage Payment:\u001b[0m Approximately $2,661 \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[35m▌ \u001b[0m\u001b[3;35mNote: This estimate includes principal and interest only. Taxes, insurance, and HOA fees (if applicable) \u001b[0m\u001b[35m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[35m▌ \u001b[0m\u001b[3;35mwill add to the monthly cost.\u001b[0m\u001b[35m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;4mNeighborhood Evaluation\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1m1. \u001b[0m\u001b[1mSouth Austin\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mPros:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mVibrant community with a mix of cultures. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mClose to downtown and entertainment options. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mGood schools and parks. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mCons:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mTraffic congestion during peak hours. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mHigher property taxes in some areas. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1m2. \u001b[0m\u001b[1mNorth Austin\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mPros:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mMore affordable housing options. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mGrowing tech industry presence. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mFamily-friendly neighborhoods. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mCons:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mFurther from downtown. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mLimited public transportation options. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1m3. \u001b[0m\u001b[1mEast Austin\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mPros:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mTrendy and rapidly developing area. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mRich cultural history and diversity. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mProximity to downtown. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mCons:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mRising property prices. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mGentrification concerns. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1m4. \u001b[0m\u001b[1mWest Austin\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mPros:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mScenic views and outdoor activities. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mHigh-rated schools. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mQuiet and upscale neighborhoods. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mCons:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mHigher cost of living. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mLimited affordable housing options. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;4mSteps to Proceed\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0m\u001b[1mFinancial Preparation:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mReview your credit score and financial standing. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mGet pre-approved for a mortgage to understand your budget. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mNeighborhood Research:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mVisit potential neighborhoods at different times of the day. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mConsider proximity to work, schools, and amenities. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0m\u001b[1mEngage a Real Estate Agent:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mChoose an agent familiar with Austin's market. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mDiscuss your needs and preferences. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 4 \u001b[0m\u001b[1mHouse Hunting:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mAttend open houses and schedule private showings. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mCompare properties based on criteria and budget. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 5 \u001b[0m\u001b[1mMake an Offer:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mWork with your agent to make a competitive offer. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mBe prepared for negotiations. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 6 \u001b[0m\u001b[1mHome Inspection and Closing:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mConduct a thorough home inspection. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mFinalize mortgage details and close the deal. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[35m▌ \u001b[0m\u001b[3;35mRemember, buying a home is a significant investment. Take your time to ensure it meets your needs and \u001b[0m\u001b[35m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[35m▌ \u001b[0m\u001b[3;35mfinancial situation.\u001b[0m\u001b[35m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"🏠 Home Buying Report:\n",
|
||||
" # First-Time Homebuyer Guide: 3-Bedroom House in Austin, TX\n",
|
||||
"\n",
|
||||
"## Property Criteria\n",
|
||||
"- **Location:** Austin, TX\n",
|
||||
"- **Type:** 3-bedroom house\n",
|
||||
"- **Budget:** Under $500,000\n",
|
||||
"\n",
|
||||
"## Mortgage Estimate\n",
|
||||
"Assuming a purchase price of $500,000, a 20% down payment, and a 30-year fixed mortgage with an interest rate of 7%:\n",
|
||||
"\n",
|
||||
"- **Down Payment:** $100,000\n",
|
||||
"- **Loan Amount:** $400,000\n",
|
||||
"- **Monthly Mortgage Payment:** Approximately $2,661\n",
|
||||
"\n",
|
||||
"> *Note: This estimate includes principal and interest only. Taxes, insurance, and HOA fees (if applicable) will add to the monthly cost.*\n",
|
||||
"\n",
|
||||
"## Neighborhood Evaluation\n",
|
||||
"\n",
|
||||
"### 1. **South Austin**\n",
|
||||
"- **Pros:**\n",
|
||||
" - Vibrant community with a mix of cultures.\n",
|
||||
" - Close to downtown and entertainment options.\n",
|
||||
" - Good schools and parks.\n",
|
||||
"- **Cons:**\n",
|
||||
" - Traffic congestion during peak hours.\n",
|
||||
" - Higher property taxes in some areas.\n",
|
||||
"\n",
|
||||
"### 2. **North Austin**\n",
|
||||
"- **Pros:**\n",
|
||||
" - More affordable housing options.\n",
|
||||
" - Growing tech industry presence.\n",
|
||||
" - Family-friendly neighborhoods.\n",
|
||||
"- **Cons:**\n",
|
||||
" - Further from downtown.\n",
|
||||
" - Limited public transportation options.\n",
|
||||
"\n",
|
||||
"### 3. **East Austin**\n",
|
||||
"- **Pros:**\n",
|
||||
" - Trendy and rapidly developing area.\n",
|
||||
" - Rich cultural history and diversity.\n",
|
||||
" - Proximity to downtown.\n",
|
||||
"- **Cons:**\n",
|
||||
" - Rising property prices.\n",
|
||||
" - Gentrification concerns.\n",
|
||||
"\n",
|
||||
"### 4. **West Austin**\n",
|
||||
"- **Pros:**\n",
|
||||
" - Scenic views and outdoor activities.\n",
|
||||
" - High-rated schools.\n",
|
||||
" - Quiet and upscale neighborhoods.\n",
|
||||
"- **Cons:**\n",
|
||||
" - Higher cost of living.\n",
|
||||
" - Limited affordable housing options.\n",
|
||||
"\n",
|
||||
"## Steps to Proceed\n",
|
||||
"\n",
|
||||
"1. **Financial Preparation:**\n",
|
||||
" - Review your credit score and financial standing.\n",
|
||||
" - Get pre-approved for a mortgage to understand your budget.\n",
|
||||
"\n",
|
||||
"2. **Neighborhood Research:**\n",
|
||||
" - Visit potential neighborhoods at different times of the day.\n",
|
||||
" - Consider proximity to work, schools, and amenities.\n",
|
||||
"\n",
|
||||
"3. **Engage a Real Estate Agent:**\n",
|
||||
" - Choose an agent familiar with Austin's market.\n",
|
||||
" - Discuss your needs and preferences.\n",
|
||||
"\n",
|
||||
"4. **House Hunting:**\n",
|
||||
" - Attend open houses and schedule private showings.\n",
|
||||
" - Compare properties based on criteria and budget.\n",
|
||||
"\n",
|
||||
"5. **Make an Offer:**\n",
|
||||
" - Work with your agent to make a competitive offer.\n",
|
||||
" - Be prepared for negotiations.\n",
|
||||
"\n",
|
||||
"6. **Home Inspection and Closing:**\n",
|
||||
" - Conduct a thorough home inspection.\n",
|
||||
" - Finalize mortgage details and close the deal.\n",
|
||||
"\n",
|
||||
"> *Remember, buying a home is a significant investment. Take your time to ensure it meets your needs and financial situation.*\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Input your query here\n",
|
||||
"query = \"Help a first-time buyer find a 3-bedroom home under $500,000 in Austin, TX. Include loan and tax guidance.\"\n",
|
||||
"output = home_buying_system.start(input=query)\n",
|
||||
"\n",
|
||||
"# 🏠 Show the results\n",
|
||||
"print(\"🏠 Home Buying Report:\\n\", output)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "ZH_nR-SvvkDG"
|
||||
},
|
||||
"source": [
|
||||
"# Government Services Assistant - AI Chatbot"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "w8B741JgvpFj"
|
||||
},
|
||||
"source": [
|
||||
"This notebook demonstrates how to use an AI-powered assistant to answer questions about government services and procedures, using the Firecrawl API and a friendly, step-by-step conversational approach."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "y8jiJYf4FA0m"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/Chile_Government_Services_Assistant.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "RRw8sPG89KNb"
|
||||
},
|
||||
"source": [
|
||||
"# Install dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "rW8ltqCICV8o"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install flask firecrawl praisonaiagents google-genai python-dotenv deep-translator"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "XGjyt-B_EfbM"
|
||||
},
|
||||
"source": [
|
||||
"# Set API Keys"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "qf8B_YltDiIe"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"os.environ['FIRECRAWL_API_KEY'] = \"your api key here\"\n",
|
||||
"os.environ['OPENAI_API_KEY'] = \"your api key here\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "ccO0vwvCEqUJ"
|
||||
},
|
||||
"source": [
|
||||
"# Import Libraries & Translator"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "0prDQ5TpDnFu"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from firecrawl import FirecrawlApp, ScrapeOptions\n",
|
||||
"from deep_translator import GoogleTranslator\n",
|
||||
"import re\n",
|
||||
"\n",
|
||||
"def translate_to_spanish(text):\n",
|
||||
" try:\n",
|
||||
" return GoogleTranslator(source='auto', target='es').translate(text)\n",
|
||||
" except Exception as e:\n",
|
||||
" print(\"Translation to Spanish failed:\", e)\n",
|
||||
" return text\n",
|
||||
"\n",
|
||||
"def translate_to_english(text):\n",
|
||||
" try:\n",
|
||||
" # Remove Markdown images and None values before translation\n",
|
||||
" text = str(text).replace(\"None\", \"\")\n",
|
||||
" text = re.sub(r'!\\[.*?\\]\\(.*?\\)', '', text)\n",
|
||||
" return GoogleTranslator(source='auto', target='en').translate(text)\n",
|
||||
" except Exception as e:\n",
|
||||
" print(\"Translation to English failed:\", e)\n",
|
||||
" return text"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "WxOlCHMmEuK2"
|
||||
},
|
||||
"source": [
|
||||
"# Firecrawl Tool Class"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "G4RyzJ5mDp0t"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class FirecrawlTool:\n",
|
||||
" def __init__(self, api_key, instruction: str, template: str):\n",
|
||||
" if not api_key:\n",
|
||||
" raise ValueError(\"Firecrawl API key not provided.\")\n",
|
||||
" self.app = FirecrawlApp(api_key=api_key)\n",
|
||||
" self.instruction = instruction\n",
|
||||
" self.template = template\n",
|
||||
"\n",
|
||||
" def search(self, search: str) -> str:\n",
|
||||
" if not search or len(search) < 5:\n",
|
||||
" return \"Error: Please provide a valid search query (at least 5 characters).\"\n",
|
||||
" response_md = \"\"\n",
|
||||
" try:\n",
|
||||
" search_result = self.app.search(\n",
|
||||
" query=self.instruction + search,\n",
|
||||
" limit=2,\n",
|
||||
" country=\"cl\",\n",
|
||||
" lang=\"es\", # Always search in Spanish for best results\n",
|
||||
" scrape_options=ScrapeOptions(formats=[\"markdown\", \"links\"])\n",
|
||||
" )\n",
|
||||
" if search_result and hasattr(search_result, 'data') and search_result.data:\n",
|
||||
" filtered_results = [\n",
|
||||
" result for result in search_result.data\n",
|
||||
" if str(result.get(\"url\", \"\")).startswith(\"https://www.chileatiende.gob.cl/fichas\") and not str(result.get(\"url\", \"\")).endswith(\"pdf\")\n",
|
||||
" ]\n",
|
||||
" if filtered_results:\n",
|
||||
" for num, result in enumerate(filtered_results, start=1):\n",
|
||||
" response_md += self.template.format(\n",
|
||||
" result_number=num,\n",
|
||||
" page_title=str(result.get(\"title\", \"\")),\n",
|
||||
" page_url=str(result.get(\"url\", \"\")),\n",
|
||||
" page_content=str(result.get(\"markdown\", \"\"))\n",
|
||||
" )\n",
|
||||
" return response_md\n",
|
||||
" else:\n",
|
||||
" return None\n",
|
||||
" else:\n",
|
||||
" return None\n",
|
||||
" except Exception as e:\n",
|
||||
" return f\"Error during search: {e}\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "MjkjTWn_ExS0"
|
||||
},
|
||||
"source": [
|
||||
"# Firecrawl Prompt Template"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "AfivymU8Dufz"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"FIRECRAWL_INSTRUCTION = \"ChileAtiende: \"\n",
|
||||
"FIRECRAWL_TEMPLATE = \"\"\"\n",
|
||||
"# Result {result_number}\n",
|
||||
"\n",
|
||||
"## Page Name:\n",
|
||||
"\"{page_title}\"\n",
|
||||
"\n",
|
||||
"## URL:\n",
|
||||
"{page_url}\n",
|
||||
"\n",
|
||||
"## Content:\n",
|
||||
"{page_content}\n",
|
||||
"\n",
|
||||
"\"\"\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "zK8AA_DlEz9K"
|
||||
},
|
||||
"source": [
|
||||
"# Initialize Firecrawl Tool"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "c3NKK0ZjDwKT"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"firecrawl_tool = FirecrawlTool(\n",
|
||||
" api_key=os.environ['FIRECRAWL_API_KEY'],\n",
|
||||
" instruction=FIRECRAWL_INSTRUCTION,\n",
|
||||
" template=FIRECRAWL_TEMPLATE\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "uzXYIF_gE3XV"
|
||||
},
|
||||
"source": [
|
||||
"# Main Chat Loop"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "TXMgZQNkDx7n",
|
||||
"outputId": "76303cd1-a576-483f-a22d-9857e5e6d797"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Hello! I am your ChileAtiende assistant, Tomás. How can I help you today?\n",
|
||||
"You can ask me, for example: How to renew your ID card, How to apply for the Winter Bonus, etc.\n",
|
||||
"\n",
|
||||
"You: exit\n",
|
||||
"Tomás: It was a pleasure to help you. Goodbye!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(\"Hello! I am your ChileAtiende assistant, Tomás. How can I help you today?\")\n",
|
||||
"print(\"You can ask me, for example: How to renew your ID card, How to apply for the Winter Bonus, etc.\")\n",
|
||||
"\n",
|
||||
"while True:\n",
|
||||
" user_input = input(\"\\nYou: \")\n",
|
||||
" if user_input.lower() in [\"exit\", \"quit\"]:\n",
|
||||
" print(\"Tomás: It was a pleasure to help you. Goodbye!\")\n",
|
||||
" break\n",
|
||||
"\n",
|
||||
" # Translate English input to Spanish for Firecrawl\n",
|
||||
" spanish_query = translate_to_spanish(user_input)\n",
|
||||
" spanish_answer = firecrawl_tool.search(spanish_query)\n",
|
||||
"\n",
|
||||
" # Only translate if we got a real answer\n",
|
||||
" if spanish_answer and isinstance(spanish_answer, str) and spanish_answer.strip() and \"Error\" not in spanish_answer:\n",
|
||||
" try:\n",
|
||||
" english_answer = translate_to_english(spanish_answer)\n",
|
||||
" print(\"\\nTomás (in English):\\n\", english_answer)\n",
|
||||
" except Exception as e:\n",
|
||||
" print(f\"\\nTomás: I found information, but couldn't translate it. Here it is in Spanish:\\n{spanish_answer}\\n(Translation error: {e})\")\n",
|
||||
" else:\n",
|
||||
" print(\"\\nTomás: Sorry, I couldn't find relevant information. Try rephrasing your question or ask about another service.\")"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,573 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "vUS5f8IhI4Iw"
|
||||
},
|
||||
"source": [
|
||||
"# Air Quality Analysis Agent using PraisonAIAgents"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "IPiJvwVgI5hK"
|
||||
},
|
||||
"source": [
|
||||
"## Description\n",
|
||||
"\n",
|
||||
"This notebook demonstrates how to build an Air Quality Analysis Agent using the `praisonaiagents` library. \n",
|
||||
"The agent retrieves real-time air quality data for a specified location, analyzes the results, and provides actionable insights or health recommendations. \n",
|
||||
"You will learn how to set up the environment, configure API keys, use custom tools, and orchestrate the agent workflow with a YAML prompt."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "oqdL8WpNTKu5"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/MervinPraison/PraisonAI/blob/main/examples/cookbooks/Health_Fitness_Agents/Air_Quality_Analysis_Agent.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "p7CFp0tkJKmU"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "q6Aq57bqJKFc"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonaiagents firecrawl requests"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "NLJn9uGVJldu"
|
||||
},
|
||||
"source": [
|
||||
"# Set up API Key"
|
||||
]
|
||||
},{
|
||||
"cell_type": "code",
|
||||
"execution_count": 32,
|
||||
"metadata": {
|
||||
"id": "ZxHL7mJYJpVb"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Replace with your actual API keys\n",
|
||||
"FIRECRAWL_API_KEY = \"fc-...\" # Your Firecrawl API key\n",
|
||||
"OPENAI_API_KEY = \"sk-...\" # Your OpenAI API key\n",
|
||||
"\n",
|
||||
"import os\n",
|
||||
"os.environ[\"FIRECRAWL_API_KEY\"] = FIRECRAWL_API_KEY\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = OPENAI_API_KEY\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "eVb00IhbJ60M"
|
||||
},
|
||||
"source": [
|
||||
"# Tools"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 33,
|
||||
"metadata": {
|
||||
"id": "3YgwDwyFLXlU"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import requests\n",
|
||||
"from firecrawl import FirecrawlApp\n",
|
||||
"from typing import Dict\n",
|
||||
"\n",
|
||||
"class AQIDataFetcher:\n",
|
||||
" def __init__(self, firecrawl_key: str):\n",
|
||||
" self.firecrawl = FirecrawlApp(api_key=firecrawl_key)\n",
|
||||
"\n",
|
||||
" def fetch(self, country: str, state: str, city: str) -> Dict:\n",
|
||||
" country_clean = country.lower().replace(' ', '-')\n",
|
||||
" city_clean = city.lower().replace(' ', '-')\n",
|
||||
" if not state or state.lower() == 'none':\n",
|
||||
" url = f\"https://www.aqi.in/dashboard/{country_clean}/{city_clean}\"\n",
|
||||
" else:\n",
|
||||
" state_clean = state.lower().replace(' ', '-')\n",
|
||||
" url = f\"https://www.aqi.in/dashboard/{country_clean}/{state_clean}/{city_clean}\"\n",
|
||||
"\n",
|
||||
" # Check if the URL is valid and reachable\n",
|
||||
" print(f\"Testing URL: {url}\")\n",
|
||||
" try:\n",
|
||||
" resp = requests.get(url)\n",
|
||||
" print(f\"Status code: {resp.status_code}\")\n",
|
||||
" if resp.status_code != 200:\n",
|
||||
" print(f\"URL not reachable: {url} (status code: {resp.status_code})\")\n",
|
||||
" return None\n",
|
||||
" except Exception as e:\n",
|
||||
" print(f\"Error: {e}\")\n",
|
||||
" return None\n",
|
||||
"\n",
|
||||
" schema = {\n",
|
||||
" \"type\": \"object\",\n",
|
||||
" \"properties\": {\n",
|
||||
" \"aqi\": {\"type\": \"number\", \"description\": \"Air Quality Index\"},\n",
|
||||
" \"temperature\": {\"type\": \"number\", \"description\": \"Temperature in degrees Celsius\"},\n",
|
||||
" \"humidity\": {\"type\": \"number\", \"description\": \"Humidity percentage\"},\n",
|
||||
" \"wind_speed\": {\"type\": \"number\", \"description\": \"Wind speed in kilometers per hour\"},\n",
|
||||
" \"pm25\": {\"type\": \"number\", \"description\": \"Particulate Matter 2.5 micrometers\"},\n",
|
||||
" \"pm10\": {\"type\": \"number\", \"description\": \"Particulate Matter 10 micrometers\"},\n",
|
||||
" \"co\": {\"type\": \"number\", \"description\": \"Carbon Monoxide level\"}\n",
|
||||
" },\n",
|
||||
" \"required\": [\"aqi\", \"temperature\", \"humidity\", \"wind_speed\", \"pm25\", \"pm10\", \"co\"]\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" response = self.firecrawl.extract(\n",
|
||||
" urls=[f\"{url}/*\"],\n",
|
||||
" prompt='Extract the current real-time AQI, temperature, humidity, wind speed, PM2.5, PM10, and CO levels from the page. Also extract the timestamp of the data.',\n",
|
||||
" schema=schema\n",
|
||||
" )\n",
|
||||
" return response"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "3sUNJChKOVUm"
|
||||
},
|
||||
"source": [
|
||||
"# YAML Prompt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 34,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "0G9tLj0nJ8B_",
|
||||
"outputId": "61e66fe7-df17-4d2d-ad27-a9f4466298a4"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{'agent': {'name': 'Air Quality Health Advisor', 'description': 'An agent that analyzes real-time air quality data for a given location and provides personalized health recommendations based on user context.\\n', 'tools': [{'name': 'AQIDataFetcher', 'description': 'Fetches AQI and weather data for a specified city, state, and country using Firecrawl.'}], 'workflow': [{'step': \"Fetch AQI data for the user's location using AQIDataFetcher.\"}, {'step': 'Analyze AQI and weather data.'}, {'step': \"Consider user's medical conditions and planned activity.\"}, {'step': 'Generate health and activity recommendations.'}]}, 'inputs': ['city', 'state', 'country', 'medical_conditions', 'planned_activity'], 'outputs': ['recommendations']}\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import yaml\n",
|
||||
"\n",
|
||||
"yaml_prompt = \"\"\"\n",
|
||||
"agent:\n",
|
||||
" name: Air Quality Health Advisor\n",
|
||||
" description: |\n",
|
||||
" An agent that analyzes real-time air quality data for a given location and provides personalized health recommendations based on user context.\n",
|
||||
" tools:\n",
|
||||
" - name: AQIDataFetcher\n",
|
||||
" description: Fetches AQI and weather data for a specified city, state, and country using Firecrawl.\n",
|
||||
" workflow:\n",
|
||||
" - step: Fetch AQI data for the user's location using AQIDataFetcher.\n",
|
||||
" - step: Analyze AQI and weather data.\n",
|
||||
" - step: Consider user's medical conditions and planned activity.\n",
|
||||
" - step: Generate health and activity recommendations.\n",
|
||||
"inputs:\n",
|
||||
" - city\n",
|
||||
" - state\n",
|
||||
" - country\n",
|
||||
" - medical_conditions\n",
|
||||
" - planned_activity\n",
|
||||
"outputs:\n",
|
||||
" - recommendations\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"print(yaml.safe_load(yaml_prompt))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "2HIPkoUyKEY-"
|
||||
},
|
||||
"source": [
|
||||
"# Main"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 40,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000,
|
||||
"referenced_widgets": [
|
||||
"4c2bac52ad444499b362978d8fe92d97",
|
||||
"5203e4d9bd3c47f09d2f204c7f1e078f"
|
||||
]
|
||||
},
|
||||
"id": "UQ4sHVW0KFp-",
|
||||
"outputId": "4efe39ea-c924-41e9-cc66-f4894e367280"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Testing URL: https://www.aqi.in/dashboard/india/maharashtra/mumbai\n",
|
||||
"Status code: 200\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Air Quality Health Advisor</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Assistant</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mAir Quality Health Advisor\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mAssistant\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "4c2bac52ad444499b362978d8fe92d97",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 10.8s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 10.8s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> You are an expert health advisor using the gpt-5-nano Mini model. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">Based on the following air quality conditions in Mumbai, Maharashtra, India:</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">- Overall AQI: 75</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">- PM2.5 Level: 22 µg/m³</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">- PM10 Level: 60 µg/m³</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">- CO Level: 650 ppb</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">Weather conditions:</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">- Temperature: 28°C</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">- Humidity: 84%</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">- Wind Speed: 30 km/h</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">User's Context:</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">- Medical Conditions: asthma</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">- Planned Activity: morning jog for 2 hours</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">**Comprehensive Health Recommendations:**</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">1. **Impact of Current Air Quality on Health:**</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">2. **Necessary Safety Precautions for Planned Activity:**</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">3. **Advisability of Planned Activity:**</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">4. **Best Time to Conduct the Activity:**</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m You are an expert health advisor using the gpt-5-nano Mini model. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mBased on the following air quality conditions in Mumbai, Maharashtra, India:\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m- Overall AQI: 75\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m- PM2.5 Level: 22 µg/m³\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m- PM10 Level: 60 µg/m³\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m- CO Level: 650 ppb\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mWeather conditions:\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m- Temperature: 28°C\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m- Humidity: 84%\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m- Wind Speed: 30 km/h\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mUser's Context:\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m- Medical Conditions: asthma\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m- Planned Activity: morning jog for 2 hours\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m**Comprehensive Health Recommendations:**\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m1. **Impact of Current Air Quality on Health:**\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m2. **Necessary Safety Precautions for Planned Activity:**\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m3. **Advisability of Planned Activity:**\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m4. **Best Time to Conduct the Activity:**\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Certainly! Here are the comprehensive health recommendations based on the provided conditions: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">Impact of Current Air Quality on Health:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>The overall AQI of 75 is considered \"Moderate.\" This level is generally acceptable for most individuals, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>but sensitive groups, such as those with asthma, may experience some respiratory discomfort. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>PM2.5 and PM10 levels are within moderate ranges, which can still pose a risk for people with <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>pre-existing respiratory conditions like asthma. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>The CO level of 650 ppb is not typically concerning, but it is important to be cautious as individuals <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>with asthma may be more sensitive to pollutants. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">Necessary Safety Precautions for Planned Activity:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Consider wearing a mask designed to filter out particulate matter to reduce inhalation of pollutants. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Carry a rescue inhaler and any other prescribed asthma medication. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Stay hydrated, as high humidity can exacerbate asthma symptoms. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Monitor your breathing and be prepared to stop the activity if you experience any respiratory distress. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Choose a route with less traffic to minimize exposure to vehicle emissions. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">Advisability of Planned Activity:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Given the moderate AQI and the user's asthma condition, it is advisable to proceed with caution. A 2-hour <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>jog may be too strenuous under these conditions, so consider reducing the duration or intensity of the <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>jog. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>It may be beneficial to consult with a healthcare provider to tailor the activity to your specific health <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>needs. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 4 </span><span style=\"font-weight: bold\">Best Time to Conduct the Activity:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Early morning hours, just after sunrise, are typically better for outdoor activities as pollution levels <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>tend to be lower. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Avoid peak traffic times to reduce exposure to vehicle emissions. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Check real-time air quality updates to ensure conditions remain stable or improve before starting the <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>activity. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> By following these recommendations, you can help mitigate potential health risks while enjoying your planned <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> activity. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Certainly! Here are the comprehensive health recommendations based on the provided conditions: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0m\u001b[1mImpact of Current Air Quality on Health:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mThe overall AQI of 75 is considered \"Moderate.\" This level is generally acceptable for most individuals, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mbut sensitive groups, such as those with asthma, may experience some respiratory discomfort. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mPM2.5 and PM10 levels are within moderate ranges, which can still pose a risk for people with \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mpre-existing respiratory conditions like asthma. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mThe CO level of 650 ppb is not typically concerning, but it is important to be cautious as individuals \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mwith asthma may be more sensitive to pollutants. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mNecessary Safety Precautions for Planned Activity:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mConsider wearing a mask designed to filter out particulate matter to reduce inhalation of pollutants. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mCarry a rescue inhaler and any other prescribed asthma medication. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mStay hydrated, as high humidity can exacerbate asthma symptoms. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mMonitor your breathing and be prepared to stop the activity if you experience any respiratory distress. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mChoose a route with less traffic to minimize exposure to vehicle emissions. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0m\u001b[1mAdvisability of Planned Activity:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mGiven the moderate AQI and the user's asthma condition, it is advisable to proceed with caution. A 2-hour \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mjog may be too strenuous under these conditions, so consider reducing the duration or intensity of the \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mjog. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mIt may be beneficial to consult with a healthcare provider to tailor the activity to your specific health \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mneeds. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 4 \u001b[0m\u001b[1mBest Time to Conduct the Activity:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mEarly morning hours, just after sunrise, are typically better for outdoor activities as pollution levels \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mtend to be lower. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mAvoid peak traffic times to reduce exposure to vehicle emissions. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mCheck real-time air quality updates to ensure conditions remain stable or improve before starting the \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mactivity. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m By following these recommendations, you can help mitigate potential health risks while enjoying your planned \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m activity. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"=== Air Quality Analysis Agent Recommendations ===\n",
|
||||
"Certainly! Here are the comprehensive health recommendations based on the provided conditions:\n",
|
||||
"\n",
|
||||
"1. **Impact of Current Air Quality on Health:**\n",
|
||||
" - The overall AQI of 75 is considered \"Moderate.\" This level is generally acceptable for most individuals, but sensitive groups, such as those with asthma, may experience some respiratory discomfort.\n",
|
||||
" - PM2.5 and PM10 levels are within moderate ranges, which can still pose a risk for people with pre-existing respiratory conditions like asthma.\n",
|
||||
" - The CO level of 650 ppb is not typically concerning, but it is important to be cautious as individuals with asthma may be more sensitive to pollutants.\n",
|
||||
"\n",
|
||||
"2. **Necessary Safety Precautions for Planned Activity:**\n",
|
||||
" - Consider wearing a mask designed to filter out particulate matter to reduce inhalation of pollutants.\n",
|
||||
" - Carry a rescue inhaler and any other prescribed asthma medication.\n",
|
||||
" - Stay hydrated, as high humidity can exacerbate asthma symptoms.\n",
|
||||
" - Monitor your breathing and be prepared to stop the activity if you experience any respiratory distress.\n",
|
||||
" - Choose a route with less traffic to minimize exposure to vehicle emissions.\n",
|
||||
"\n",
|
||||
"3. **Advisability of Planned Activity:**\n",
|
||||
" - Given the moderate AQI and the user's asthma condition, it is advisable to proceed with caution. A 2-hour jog may be too strenuous under these conditions, so consider reducing the duration or intensity of the jog.\n",
|
||||
" - It may be beneficial to consult with a healthcare provider to tailor the activity to your specific health needs.\n",
|
||||
"\n",
|
||||
"4. **Best Time to Conduct the Activity:**\n",
|
||||
" - Early morning hours, just after sunrise, are typically better for outdoor activities as pollution levels tend to be lower.\n",
|
||||
" - Avoid peak traffic times to reduce exposure to vehicle emissions.\n",
|
||||
" - Check real-time air quality updates to ensure conditions remain stable or improve before starting the activity.\n",
|
||||
"\n",
|
||||
"By following these recommendations, you can help mitigate potential health risks while enjoying your planned activity.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from praisonaiagents import Agent\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"# User input (you can change these for other locations)\n",
|
||||
"user_city = \"Mumbai\"\n",
|
||||
"user_state = \"Maharashtra\"\n",
|
||||
"user_country = \"India\"\n",
|
||||
"user_medical_conditions = \"asthma\"\n",
|
||||
"user_planned_activity = \"morning jog for 2 hours\"\n",
|
||||
"\n",
|
||||
"aqi_fetcher = AQIDataFetcher(firecrawl_key=os.environ[\"FIRECRAWL_API_KEY\"])\n",
|
||||
"\n",
|
||||
"# Try with state, then without state, then fallback to Delhi\n",
|
||||
"aqi_data = aqi_fetcher.fetch(\n",
|
||||
" country=user_country,\n",
|
||||
" state=user_state,\n",
|
||||
" city=user_city\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"if not aqi_data or not hasattr(aqi_data, \"data\"):\n",
|
||||
" print(\"Mumbai with state failed, trying without state...\")\n",
|
||||
" aqi_data = aqi_fetcher.fetch(\n",
|
||||
" country=user_country,\n",
|
||||
" state=\"\",\n",
|
||||
" city=user_city\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
"if not aqi_data or not hasattr(aqi_data, \"data\"):\n",
|
||||
" print(\"Trying Delhi, India...\")\n",
|
||||
" aqi_data = aqi_fetcher.fetch(\n",
|
||||
" country=\"India\",\n",
|
||||
" state=\"\",\n",
|
||||
" city=\"Delhi\"\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
"if not aqi_data or not hasattr(aqi_data, \"data\"):\n",
|
||||
" print(\"Failed to fetch AQI data for all tried locations. Please check the URLs manually.\")\n",
|
||||
"else:\n",
|
||||
" aqi_data = aqi_data.data # Convert to dict\n",
|
||||
"\n",
|
||||
" prompt = f\"\"\"\n",
|
||||
" You are an expert health advisor using the gpt-5-nano Mini model.\n",
|
||||
"\n",
|
||||
" Based on the following air quality conditions in {user_city}, {user_state}, {user_country}:\n",
|
||||
" - Overall AQI: {aqi_data.get('aqi', 'N/A')}\n",
|
||||
" - PM2.5 Level: {aqi_data.get('pm25', 'N/A')} µg/m³\n",
|
||||
" - PM10 Level: {aqi_data.get('pm10', 'N/A')} µg/m³\n",
|
||||
" - CO Level: {aqi_data.get('co', 'N/A')} ppb\n",
|
||||
"\n",
|
||||
" Weather conditions:\n",
|
||||
" - Temperature: {aqi_data.get('temperature', 'N/A')}°C\n",
|
||||
" - Humidity: {aqi_data.get('humidity', 'N/A')}%\n",
|
||||
" - Wind Speed: {aqi_data.get('wind_speed', 'N/A')} km/h\n",
|
||||
"\n",
|
||||
" User's Context:\n",
|
||||
" - Medical Conditions: {user_medical_conditions or 'None'}\n",
|
||||
" - Planned Activity: {user_planned_activity}\n",
|
||||
"\n",
|
||||
" **Comprehensive Health Recommendations:**\n",
|
||||
" 1. **Impact of Current Air Quality on Health:**\n",
|
||||
" 2. **Necessary Safety Precautions for Planned Activity:**\n",
|
||||
" 3. **Advisability of Planned Activity:**\n",
|
||||
" 4. **Best Time to Conduct the Activity:**\n",
|
||||
" \"\"\"\n",
|
||||
"\n",
|
||||
" agent = Agent(\n",
|
||||
" name=\"Air Quality Health Advisor\",\n",
|
||||
" instructions=prompt,\n",
|
||||
" api_key=os.environ[\"OPENAI_API_KEY\"]\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" # Call run() with no arguments\n",
|
||||
"recommendations = agent.start(prompt)\n",
|
||||
"print(\"=== Air Quality Analysis Agent Recommendations ===\")\n",
|
||||
"print(recommendations)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,134 +0,0 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "441900e0"
|
||||
},
|
||||
"source": [
|
||||
"# 🧠 Mistral v0.3 (7B) Conversational Agent\n",
|
||||
"A conceptual demo notebook to illustrate the workflow and output of the Mistral model, even if it doesn't run on Colab Free Tier."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "b4ba0b88"
|
||||
},
|
||||
"source": [
|
||||
"## 📄 Description\n",
|
||||
"This notebook showcases the typical flow of using Mistral v0.3 (7B) for conversational tasks. While the model is too large for Google Colab Free Tier, this version visually explains what the code would do.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/Mistral_v0_3_Conversational_Demo.ipynb)\n"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "yzXURvxIlIDD"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# 📦 Dependencies"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "IUQSTocQk7ml"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "6f2afc57"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"\n",
|
||||
"!pip install transformers accelerate torch\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "9d5dad27"
|
||||
},
|
||||
"source": [
|
||||
"## 🛠 Tools Used\n",
|
||||
"- 🤗 Transformers: For loading the model and tokenizer.\n",
|
||||
"- PyTorch: For model inference.\n",
|
||||
"- Accelerate: To manage device placement (CPU/GPU).\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "cd936b40"
|
||||
},
|
||||
"source": [
|
||||
"## 🧾 YAML Prompt Format (Conceptual)\n",
|
||||
"```yaml\n",
|
||||
"task: conversation\n",
|
||||
"input: \"What's the capital of France?\"\n",
|
||||
"history: []\n",
|
||||
"temperature: 0.7\n",
|
||||
"top_p: 0.9\n",
|
||||
"```\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "8abaaa62"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# 🧠 Main Inference Logic (Illustrative)\n",
|
||||
"from transformers import AutoModelForCausalLM, AutoTokenizer\n",
|
||||
"import torch\n",
|
||||
"\n",
|
||||
"model_id = \"mistralai/Mistral-7B-Instruct-v0.3\"\n",
|
||||
"tokenizer = AutoTokenizer.from_pretrained(model_id)\n",
|
||||
"model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map=\"auto\")\n",
|
||||
"\n",
|
||||
"prompt = \"What's the capital of France?\"\n",
|
||||
"inputs = tokenizer(prompt, return_tensors=\"pt\").to(model.device)\n",
|
||||
"outputs = model.generate(**inputs, max_new_tokens=100)\n",
|
||||
"response = tokenizer.decode(outputs[0], skip_special_tokens=True)\n",
|
||||
"print(response)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "def486c6"
|
||||
},
|
||||
"source": [
|
||||
"## 📤 Output (Example)\n",
|
||||
"> \"The capital of France is Paris.\"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"accelerator": "GPU",
|
||||
"colab": {
|
||||
"gpuType": "T4",
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
{
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"name": "python3",
|
||||
"display_name": "Python 3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Pocky Query Tool: Automated CVE PoC Search & Validation\n",
|
||||
"\n",
|
||||
"A lightweight, web-scale agent that helps you find, filter, and fetch real-world PoC exploits — so you don't have to.\n",
|
||||
"\n",
|
||||
"**Features:**\n",
|
||||
"- Automatically searches multiple security-related websites\n",
|
||||
"- Intelligently analyzes and extracts PoC code\n",
|
||||
"- Automatically selects the most reliable PoC samples\n",
|
||||
"- Supports collection of PoCs from multiple sources"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "BdX56iM1r5aB"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/Pocky_Cybersecurity_PoC_Agent.ipynb)\n"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "VW766102tUUY"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Install Dependencies"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "cBu2iXmJsVqE"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"!pip install praisonaiagents exa-py python-dotenv requests beautifulsoup4"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "VvbA3A7XsTFm"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Set API Keys"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "Q6B2VEkFsB32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"# Set your API keys here (replace with your actual keys)\n",
|
||||
"os.environ[\"EXA_API_KEY\"] = \"your api key\"\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = \"your api key\"\n",
|
||||
"os.environ[\"OPENAI_BASE_URL\"] = \"https://api.openai.com/v1\" # Optional, for custom OpenAI endpoints"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "OlOI3yc_sAkN"
|
||||
},
|
||||
"execution_count": 1,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Tools (Core Functions)"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "1BvjjjJdsanO"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"import json\n",
|
||||
"from openai import OpenAI\n",
|
||||
"from exa_py import Exa\n",
|
||||
"\n",
|
||||
"# Dummy/Minimal agent classes for notebook demo\n",
|
||||
"class ValidationAgent:\n",
|
||||
" def __init__(self, input_json):\n",
|
||||
" self.input_json = input_json\n",
|
||||
" def run(self):\n",
|
||||
" # Dummy validation logic for notebook demo\n",
|
||||
" data = json.loads(self.input_json)\n",
|
||||
" return True if \"attack_intent\" in data and \"poc_sample\" in data else False\n",
|
||||
"\n",
|
||||
"class AttackIntentAgent:\n",
|
||||
" def __init__(self, description):\n",
|
||||
" self.description = description\n",
|
||||
" def run(self):\n",
|
||||
" # Dummy intent extraction for notebook demo\n",
|
||||
" return f\"Intent for: {self.description[:50]}...\""
|
||||
],
|
||||
"metadata": {
|
||||
"id": "GYfAJLXOsbga"
|
||||
},
|
||||
"execution_count": 3,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"## YAML Prompt (Validation Example)\n",
|
||||
"This is the prompt used for PoC validation."
|
||||
],
|
||||
"metadata": {
|
||||
"id": "THrET8-psjx-"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"validation_prompt = \"\"\"\n",
|
||||
"You are a highly skilled technical assistant with deep expertise in PoC sample validation.\n",
|
||||
"\n",
|
||||
"Given the attack intent of a CVE vulnerability and a PoC sample gathered from public sources, your task is to analyze whether the PoC correctly implements the intended attack behavior.\n",
|
||||
"\n",
|
||||
"Specifically:\n",
|
||||
"- Understand the CVE's attack intent, including the attack goal and the underlying exploitation mechanism.\n",
|
||||
"- Analyze the PoC to determine whether it is designed to achieve this intent.\n",
|
||||
"- Check whether the payloads, request structures, and overall logic of the PoC align with the described attack intent.\n",
|
||||
"- You do not need to execute the PoC. Focus on static validation through reasoning and consistency.\n",
|
||||
"\n",
|
||||
"Your output must be a JSON object with two fields:\n",
|
||||
"- \"valid\": a boolean indicating whether the PoC correctly reflects the attack intent.\n",
|
||||
"- \"reasoning\": a brief explanation of your judgment. If \"valid\" is false, the reasoning must clearly explain what is incorrect or inconsistent in the PoC compared to the attack intent, so that the PoC can be revised accordingly.\n",
|
||||
"\"\"\"\n",
|
||||
"print(validation_prompt)"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "9q3aKl1xshrb"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Main (Query and Validate a CVE PoC)"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "531EZgcLsqP6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"def run_pocky_for_cve(cve_id):\n",
|
||||
" # Example: Simulate fetching a description and PoC (replace with real logic)\n",
|
||||
" description = f\"Description for {cve_id} (replace with real Exa/OpenAI search)\"\n",
|
||||
" poc_sample = f\"PoC code for {cve_id} (replace with real PoC search)\"\n",
|
||||
"\n",
|
||||
" # Stage 2: Attack Intent\n",
|
||||
" intent = AttackIntentAgent(description).run()\n",
|
||||
" print(f\"Attack Intent: {intent}\")\n",
|
||||
"\n",
|
||||
" # Stage 3: Validation\n",
|
||||
" validation_input = json.dumps({\"attack_intent\": intent, \"poc_sample\": poc_sample}, indent=2)\n",
|
||||
" valid = ValidationAgent(validation_input).run()\n",
|
||||
" print(f\"Validation Result: {valid}\")\n",
|
||||
" if valid:\n",
|
||||
" print(f\"PoC for {cve_id} is valid and ready to use.\")\n",
|
||||
" else:\n",
|
||||
" print(f\"PoC for {cve_id} failed validation.\")"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "PQvtF-RqsrP6"
|
||||
},
|
||||
"execution_count": 5,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Example Usage"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "XiQOiSz8su3u"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"run_pocky_for_cve(\"CVE-2023-4450\")"
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "39w-qpecswjw",
|
||||
"outputId": "cdcb3b29-7338-4e3e-b160-5f9568c194ca"
|
||||
},
|
||||
"execution_count": 6,
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"name": "stdout",
|
||||
"text": [
|
||||
"Attack Intent: Intent for: Description for CVE-2023-4450 (replace with real E...\n",
|
||||
"Validation Result: True\n",
|
||||
"PoC for CVE-2023-4450 is valid and ready to use.\n"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
+398
@@ -0,0 +1,398 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "ZqmhthnKYNve"
|
||||
},
|
||||
"source": [
|
||||
"# Flow – Intelligent Agent for Daily Efficiency"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "nPPyvagreZ_i"
|
||||
},
|
||||
"source": [
|
||||
"# Description"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "5wMZC3_0edNZ"
|
||||
},
|
||||
"source": [
|
||||
"This agent uses a custom DuckDuckGo search tool to intelligently retrieve and summarize real-time information based on user queries."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "mNFEBTyAek8E"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/Flow_Intelligent_Agent_PraisonAI.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "mHpIJFsZYNvi"
|
||||
},
|
||||
"source": [
|
||||
"## Tools\n",
|
||||
"- `praisonaiagents` – Intelligent Agent framework\n",
|
||||
"- `duckduckgo-search` – Custom search tool\n",
|
||||
"- `pyyaml` – YAML config\n",
|
||||
"- `openai` – LLM backend"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "K1QOdZ8SYqoF"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "zZOiRidoYNvj"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonaiagents duckduckgo-search pyyaml openai"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "_9jyGJrOYyKh"
|
||||
},
|
||||
"source": [
|
||||
"# Set your OpenAI API Key securely"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "7huxRijxYNvk"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"os.environ['OPENAI_API_KEY'] = 'your api key' # Replace with your actual OpenAI key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "E3naWfHNYNvk"
|
||||
},
|
||||
"source": [
|
||||
"## YAML Prompt\n",
|
||||
"Define multiple agents and their roles."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "kYST2rZqYNvl"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import yaml\n",
|
||||
"\n",
|
||||
"yaml_prompt = '''\n",
|
||||
"agents:\n",
|
||||
" - name: FlowAgent\n",
|
||||
" description: Intelligent daily workflow assistant\n",
|
||||
" - name: ChileAtiendeAI\n",
|
||||
" description: Government support assistant for Chile\n",
|
||||
" - name: ClinicalTrialMatcher\n",
|
||||
" description: Match patients to trials using input medical info\n",
|
||||
" - name: ChillWorkEmailAgent\n",
|
||||
" description: Automate email replies and scheduling\n",
|
||||
"'''\n",
|
||||
"\n",
|
||||
"config = yaml.safe_load(yaml_prompt)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "tBryRalYYNvl"
|
||||
},
|
||||
"source": [
|
||||
"## Main\n",
|
||||
"Initialize agent with a custom DuckDuckGo tool and simulate a task."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 673,
|
||||
"referenced_widgets": [
|
||||
"865a918fc4d54fd0a110ea3eb7fe4215",
|
||||
"c70a26d2c54549888067f65c366bdb9b"
|
||||
]
|
||||
},
|
||||
"id": "1mMAS_1PYNvl",
|
||||
"outputId": "d3aacdd3-5e01-460b-ae66-385f6a62c1eb"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">FlowAgent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Assistant</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #86a789; text-decoration-color: #86a789; font-weight: bold\">Tools:</span> <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">internet_search_tool</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mFlowAgent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mAssistant\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;134;167;137mTools:\u001b[0m \u001b[3;38;2;180;212;255minternet_search_tool\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008000; text-decoration-color: #008000\">╭─────────────────────────────────────────────────── Tool Call ───────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">Agent FlowAgent is calling function 'internet_search_tool' with arguments: {'query': 'latest open-source AI </span> <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
|
||||
"<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">agent framework 2023'}</span> <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
|
||||
"<span style=\"color: #008000; text-decoration-color: #008000\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[32m╭─\u001b[0m\u001b[32m──────────────────────────────────────────────────\u001b[0m\u001b[32m Tool Call \u001b[0m\u001b[32m──────────────────────────────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n",
|
||||
"\u001b[32m│\u001b[0m \u001b[1;36mAgent FlowAgent is calling function 'internet_search_tool' with arguments: {'query': 'latest open-source AI \u001b[0m \u001b[32m│\u001b[0m\n",
|
||||
"\u001b[32m│\u001b[0m \u001b[1;36magent framework 2023'}\u001b[0m \u001b[32m│\u001b[0m\n",
|
||||
"\u001b[32m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008000; text-decoration-color: #008000\">╭─────────────────────────────────────────────────── Tool Call ───────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">Function 'internet_search_tool' returned: \"OpenAgents - An Open Framework for Connecting AI Agents at Scale - </span> <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
|
||||
"<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">https://openagents.org/\\nAutoGen: Enabling Next-Gen LLM Applications via Multi-Agent ... - </span> <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
|
||||
"<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">https://www.microsoft.com/en-us/research/publication/autogen-enabling-next-gen-llm-applications-via-multi-agent</span> <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
|
||||
"<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">-conversation-framework/\\nOpen-source framework to build, manage and run useful Autonomous AI Agents - </span> <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
|
||||
"<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">https://github.com/TransformerOptimus/SuperAGI\"</span> <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
|
||||
"<span style=\"color: #008000; text-decoration-color: #008000\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[32m╭─\u001b[0m\u001b[32m──────────────────────────────────────────────────\u001b[0m\u001b[32m Tool Call \u001b[0m\u001b[32m──────────────────────────────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n",
|
||||
"\u001b[32m│\u001b[0m \u001b[1;36mFunction 'internet_search_tool' returned: \"OpenAgents - An Open Framework for Connecting AI Agents at Scale - \u001b[0m \u001b[32m│\u001b[0m\n",
|
||||
"\u001b[32m│\u001b[0m \u001b[1;36mhttps://openagents.org/\\nAutoGen: Enabling Next-Gen LLM Applications via Multi-Agent ... - \u001b[0m \u001b[32m│\u001b[0m\n",
|
||||
"\u001b[32m│\u001b[0m \u001b[1;36mhttps://www.microsoft.com/en-us/research/publication/autogen-enabling-next-gen-llm-applications-via-multi-agent\u001b[0m \u001b[32m│\u001b[0m\n",
|
||||
"\u001b[32m│\u001b[0m \u001b[1;36m-conversation-framework/\\nOpen-source framework to build, manage and run useful Autonomous AI Agents - \u001b[0m \u001b[32m│\u001b[0m\n",
|
||||
"\u001b[32m│\u001b[0m \u001b[1;36mhttps://github.com/TransformerOptimus/SuperAGI\"\u001b[0m \u001b[32m│\u001b[0m\n",
|
||||
"\u001b[32m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "865a918fc4d54fd0a110ea3eb7fe4215",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 6.1s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 6.1s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> What's the latest open-source AI agent framework? <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m What's the latest open-source AI agent framework? \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Here are some of the latest open-source AI agent frameworks: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">OpenAgents</span>: An open framework for connecting AI agents at scale. More information can be found on their <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span><a href=\"https://openagents.org/\" target=\"_blank\"><span style=\"color: #000080; text-decoration-color: #000080; text-decoration: underline\">website</span></a>. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">AutoGen</span>: A framework by Microsoft Research that enables next-gen LLM applications via multi-agent <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>conversation. You can read more about it <a href=\"https://www.microsoft.com/en-us/research/publication/autogen-enabling-next-gen-llm-applications-via-multi-agent-conversation-framework/\" target=\"_blank\"><span style=\"color: #000080; text-decoration-color: #000080; text-decoration: underline\">here</span></a>. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">SuperAGI</span>: An open-source framework to build, manage, and run useful autonomous AI agents. Check out their <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span><a href=\"https://github.com/TransformerOptimus/SuperAGI\" target=\"_blank\"><span style=\"color: #000080; text-decoration-color: #000080; text-decoration: underline\">GitHub repository</span></a> for more details. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Here are some of the latest open-source AI agent frameworks: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0m\u001b[1mOpenAgents\u001b[0m: An open framework for connecting AI agents at scale. More information can be found on their \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b]8;id=900045;https://openagents.org/\u001b\\\u001b[4;34mwebsite\u001b[0m\u001b]8;;\u001b\\. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mAutoGen\u001b[0m: A framework by Microsoft Research that enables next-gen LLM applications via multi-agent \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mconversation. You can read more about it \u001b]8;id=398797;https://www.microsoft.com/en-us/research/publication/autogen-enabling-next-gen-llm-applications-via-multi-agent-conversation-framework/\u001b\\\u001b[4;34mhere\u001b[0m\u001b]8;;\u001b\\. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0m\u001b[1mSuperAGI\u001b[0m: An open-source framework to build, manage, and run useful autonomous AI agents. Check out their \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b]8;id=898758;https://github.com/TransformerOptimus/SuperAGI\u001b\\\u001b[4;34mGitHub repository\u001b[0m\u001b]8;;\u001b\\ for more details. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Here are some of the latest open-source AI agent frameworks:\n",
|
||||
"\n",
|
||||
"1. **OpenAgents**: An open framework for connecting AI agents at scale. More information can be found on their [website](https://openagents.org/).\n",
|
||||
"\n",
|
||||
"2. **AutoGen**: A framework by Microsoft Research that enables next-gen LLM applications via multi-agent conversation. You can read more about it [here](https://www.microsoft.com/en-us/research/publication/autogen-enabling-next-gen-llm-applications-via-multi-agent-conversation-framework/).\n",
|
||||
"\n",
|
||||
"3. **SuperAGI**: An open-source framework to build, manage, and run useful autonomous AI agents. Check out their [GitHub repository](https://github.com/TransformerOptimus/SuperAGI) for more details.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from praisonaiagents import Agent\n",
|
||||
"from duckduckgo_search import DDGS\n",
|
||||
"\n",
|
||||
"def internet_search_tool(query: str):\n",
|
||||
" ddgs = DDGS()\n",
|
||||
" results = []\n",
|
||||
" for res in ddgs.text(keywords=query, max_results=3):\n",
|
||||
" results.append(f\"{res['title']} - {res['href']}\")\n",
|
||||
" return \"\\n\".join(results)\n",
|
||||
"\n",
|
||||
"# Initialize the main agent (FlowAgent)\n",
|
||||
"flow_config = config['agents'][0]\n",
|
||||
"flow_agent = Agent(\n",
|
||||
" name=flow_config['name'],\n",
|
||||
" instructions=flow_config['description'],\n",
|
||||
" tools=[internet_search_tool]\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"response = flow_agent.start(\"What's the latest open-source AI agent framework?\")\n",
|
||||
"print(response)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python",
|
||||
"version": "3.x"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
+369
@@ -0,0 +1,369 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d2cd727d",
|
||||
"metadata": {
|
||||
"id": "d2cd727d"
|
||||
},
|
||||
"source": [
|
||||
"# Fuel Emission Estimator & Forecasting Agent\n",
|
||||
"\n",
|
||||
"An intelligent agent that calculates annual CO₂ emissions based on user driving patterns and vehicle type. It also forecasts how emissions would change if the user switches to a more fuel-efficient or hybrid vehicle in the future. Powered by OpenAI and designed to assist individuals in making eco-conscious transportation decisions.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "06ae55aa",
|
||||
"metadata": {
|
||||
"id": "06ae55aa"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/Fuel_Emission_Agent_Intelligence_Agent.ipynb)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "227e582f",
|
||||
"metadata": {
|
||||
"id": "227e582f"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "c59db014",
|
||||
"metadata": {
|
||||
"id": "c59db014"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install -q praisonaiagents openai duckduckgo_search \"anyio<4\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "0L9HTI3GcU63",
|
||||
"metadata": {
|
||||
"id": "0L9HTI3GcU63"
|
||||
},
|
||||
"source": [
|
||||
"# Set API Key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "SpBU5DL5brYh",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "SpBU5DL5brYh",
|
||||
"outputId": "e56c185c-5f0c-4939-e4dc-0418667a04a8"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"🔐 Enter your OpenAI API Key: ··········\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"from getpass import getpass\n",
|
||||
"\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = getpass(\"🔐 Enter your OpenAI API Key: \")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "VBZ30nKucXvA",
|
||||
"metadata": {
|
||||
"id": "VBZ30nKucXvA"
|
||||
},
|
||||
"source": [
|
||||
"# Create a Fuel Emission Agent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "-C8fVp-1bwOu",
|
||||
"metadata": {
|
||||
"id": "-C8fVp-1bwOu"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from praisonaiagents import Agent\n",
|
||||
"\n",
|
||||
"yaml_prompt = \"\"\"\n",
|
||||
"name: FuelEmissionMiniAgent\n",
|
||||
"role: Calculate CO2 emissions based on user driving habits and forecast impact of switching to hybrid vehicles.\n",
|
||||
"goal: Return estimated annual CO2 output and forecast change in emissions with different vehicle types.\n",
|
||||
"tools:\n",
|
||||
" - openai\n",
|
||||
"responses:\n",
|
||||
" - concise\n",
|
||||
" - clear\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"agent = Agent(\n",
|
||||
" name=\"FuelEmissionMiniAgent\",\n",
|
||||
" instructions=yaml_prompt\n",
|
||||
")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "SQ7Pcki7ca1S",
|
||||
"metadata": {
|
||||
"id": "SQ7Pcki7ca1S"
|
||||
},
|
||||
"source": [
|
||||
"# Run the Agent with Your Question"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "njNLFurYby3L",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000,
|
||||
"referenced_widgets": [
|
||||
"1b8ec3bc72c54cc4ae7649115185eda4",
|
||||
"40ef4acb2e2341a883f0a6b12eee4d19"
|
||||
]
|
||||
},
|
||||
"id": "njNLFurYby3L",
|
||||
"outputId": "3e3f886a-8af6-4357-d98c-f0c00006c755"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">FuelEmissionMiniAgent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Assistant</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mFuelEmissionMiniAgent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mAssistant\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "1b8ec3bc72c54cc4ae7649115185eda4",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 4.0s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 4.0s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> I drive 12,000 km per year using a petrol car that gets 10 km/l. How much CO2 do I emit annually? How would <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> this change if I switch to a hybrid vehicle in 2 years? <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m I drive 12,000 km per year using a petrol car that gets 10 km/l. How much CO2 do I emit annually? How would \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m this change if I switch to a hybrid vehicle in 2 years? \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> To calculate your annual CO2 emissions, we first need to determine the amount of fuel you use annually: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">Fuel Consumption</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Distance driven per year: 12,000 km <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Fuel efficiency: 10 km/l <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Annual fuel consumption = 12,000 km / 10 km/l = 1,200 liters <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">CO2 Emissions</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Petrol emits approximately 2.31 kg of CO2 per liter. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Annual CO2 emissions = 1,200 liters * 2.31 kg/l = 2,772 kg of CO2 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> If you switch to a hybrid vehicle in 2 years, let's assume the hybrid has a fuel efficiency of 20 km/l (a <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> common improvement over traditional petrol cars): <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">Hybrid Fuel Consumption</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Distance driven per year: 12,000 km <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Hybrid fuel efficiency: 20 km/l <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Annual fuel consumption = 12,000 km / 20 km/l = 600 liters <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">Hybrid CO2 Emissions</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Annual CO2 emissions = 600 liters * 2.31 kg/l = 1,386 kg of CO2 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\">Forecasted Change</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Current annual emissions: 2,772 kg of CO2 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Future annual emissions with hybrid: 1,386 kg of CO2 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Reduction in emissions: 2,772 kg - 1,386 kg = 1,386 kg of CO2 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Switching to a hybrid vehicle could reduce your annual CO2 emissions by approximately 50%. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m To calculate your annual CO2 emissions, we first need to determine the amount of fuel you use annually: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0m\u001b[1mFuel Consumption\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mDistance driven per year: 12,000 km \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mFuel efficiency: 10 km/l \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mAnnual fuel consumption = 12,000 km / 10 km/l = 1,200 liters \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mCO2 Emissions\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mPetrol emits approximately 2.31 kg of CO2 per liter. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mAnnual CO2 emissions = 1,200 liters * 2.31 kg/l = 2,772 kg of CO2 \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m If you switch to a hybrid vehicle in 2 years, let's assume the hybrid has a fuel efficiency of 20 km/l (a \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m common improvement over traditional petrol cars): \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0m\u001b[1mHybrid Fuel Consumption\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mDistance driven per year: 12,000 km \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mHybrid fuel efficiency: 20 km/l \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mAnnual fuel consumption = 12,000 km / 20 km/l = 600 liters \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mHybrid CO2 Emissions\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mAnnual CO2 emissions = 600 liters * 2.31 kg/l = 1,386 kg of CO2 \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mForecasted Change\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0mCurrent annual emissions: 2,772 kg of CO2 \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0mFuture annual emissions with hybrid: 1,386 kg of CO2 \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0mReduction in emissions: 2,772 kg - 1,386 kg = 1,386 kg of CO2 \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Switching to a hybrid vehicle could reduce your annual CO2 emissions by approximately 50%. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"To calculate your annual CO2 emissions, we first need to determine the amount of fuel you use annually:\n",
|
||||
"\n",
|
||||
"1. **Fuel Consumption**: \n",
|
||||
" - Distance driven per year: 12,000 km \n",
|
||||
" - Fuel efficiency: 10 km/l \n",
|
||||
" - Annual fuel consumption = 12,000 km / 10 km/l = 1,200 liters\n",
|
||||
"\n",
|
||||
"2. **CO2 Emissions**: \n",
|
||||
" - Petrol emits approximately 2.31 kg of CO2 per liter. \n",
|
||||
" - Annual CO2 emissions = 1,200 liters * 2.31 kg/l = 2,772 kg of CO2\n",
|
||||
"\n",
|
||||
"If you switch to a hybrid vehicle in 2 years, let's assume the hybrid has a fuel efficiency of 20 km/l (a common improvement over traditional petrol cars):\n",
|
||||
"\n",
|
||||
"1. **Hybrid Fuel Consumption**: \n",
|
||||
" - Distance driven per year: 12,000 km \n",
|
||||
" - Hybrid fuel efficiency: 20 km/l \n",
|
||||
" - Annual fuel consumption = 12,000 km / 20 km/l = 600 liters\n",
|
||||
"\n",
|
||||
"2. **Hybrid CO2 Emissions**: \n",
|
||||
" - Annual CO2 emissions = 600 liters * 2.31 kg/l = 1,386 kg of CO2\n",
|
||||
"\n",
|
||||
"**Forecasted Change**: \n",
|
||||
"- Current annual emissions: 2,772 kg of CO2 \n",
|
||||
"- Future annual emissions with hybrid: 1,386 kg of CO2 \n",
|
||||
"- Reduction in emissions: 2,772 kg - 1,386 kg = 1,386 kg of CO2\n",
|
||||
"\n",
|
||||
"Switching to a hybrid vehicle could reduce your annual CO2 emissions by approximately 50%.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"query = (\n",
|
||||
" \"I drive 12,000 km per year using a petrol car that gets 10 km/l. \"\n",
|
||||
" \"How much CO2 do I emit annually? How would this change if I switch to a hybrid vehicle in 2 years?\"\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"response = agent.start(prompt=query)\n",
|
||||
"print(response)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
+1
-1
@@ -193,7 +193,7 @@
|
||||
" goal=\"Evaluate hackathon projects through video demonstrations\",\n",
|
||||
" backstory=\"\"\"You are an expert hackathon judge. You give fair scores and detailed feedback\n",
|
||||
" on technical complexity, innovation, presentation, and UX.\"\"\",\n",
|
||||
" llm=\"gpt-4o-mini\",\n",
|
||||
" llm=\"gpt-5-nano\",\n",
|
||||
" self_reflect=False\n",
|
||||
")"
|
||||
],
|
||||
@@ -0,0 +1,446 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "xy4LeDEn7hQM"
|
||||
},
|
||||
"source": [
|
||||
"# 🧠 Cognitive Assistant Agent Team (PraisonAI)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "ElVhkoB37j8Y"
|
||||
},
|
||||
"source": [
|
||||
"This notebook demonstrates a multi-specialist cognitive assistant using PraisonAI, with each specialist as a tool."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "WKiORZL790Fj"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/Intelligent_Cognitive_Agent.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "7l3cAapx7phr"
|
||||
},
|
||||
"source": [
|
||||
"# Install Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "oHrh082q86Pp"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonaiagents"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "AnA-11hm9R4z"
|
||||
},
|
||||
"source": [
|
||||
"# Set API Key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {
|
||||
"id": "n1Fz52T489HE"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"# Set your OpenAI or OpenRouter API key for PraisonAI\n",
|
||||
"os.environ['OPENAI_API_KEY'] = 'Enter your api key' # <-- Replace with your actual OpenAI or OpenRouter API key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "bGbZXPS29XJ-"
|
||||
},
|
||||
"source": [
|
||||
"# Imports and Specialist Agent Definitions"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {
|
||||
"id": "7MzNN_u_9DKL"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import re\n",
|
||||
"from praisonaiagents import Agent\n",
|
||||
"\n",
|
||||
"# Dummy specialist agent classes for demonstration.\n",
|
||||
"# Replace these with your actual specialist agent logic if needed.\n",
|
||||
"class SpecialistAgent:\n",
|
||||
" def __init__(self, name):\n",
|
||||
" self.name = name\n",
|
||||
" def run(self, query):\n",
|
||||
" return f\"{self.name} specialist response to: {query}\"\n",
|
||||
"\n",
|
||||
"# Instantiate all specialist agents (replace with your real classes if available)\n",
|
||||
"specialists = [\n",
|
||||
" SpecialistAgent(\"decision_risk_agent\"),\n",
|
||||
" SpecialistAgent(\"problem_solving_innovation_agent\"),\n",
|
||||
" SpecialistAgent(\"Systems___Complexity_Agent\"),\n",
|
||||
" SpecialistAgent(\"bias_psychology_agent\"),\n",
|
||||
" SpecialistAgent(\"Strategy___Competition_Agent\"),\n",
|
||||
" SpecialistAgent(\"Learning___Communication_Agent\"),\n",
|
||||
" SpecialistAgent(\"Efficiency___Process_Agent\"),\n",
|
||||
" SpecialistAgent(\"motivation_human_factors_agent\"),\n",
|
||||
"]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "efcGipcd9bNL"
|
||||
},
|
||||
"source": [
|
||||
"# Tool Wrapping and Agent Setup"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {
|
||||
"id": "-rotrhkh9FmF"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def make_tool(agent):\n",
|
||||
" def tool(query: str):\n",
|
||||
" return agent.run(query)\n",
|
||||
" # Sanitize the tool name to match PraisonAI's requirements\n",
|
||||
" safe_name = re.sub(r'[^a-zA-Z0-9_-]', '_', agent.name or \"tool\")\n",
|
||||
" tool.__name__ = safe_name\n",
|
||||
" return tool\n",
|
||||
"\n",
|
||||
"tools = [make_tool(agent) for agent in specialists]\n",
|
||||
"\n",
|
||||
"agent = Agent(\n",
|
||||
" instructions=\"\"\"\n",
|
||||
" You are a cognitive assistant with access to a set of specialist tools (decision making, problem solving, systems thinking, psychology, strategy, learning, efficiency, motivation).\n",
|
||||
" Use the most relevant tool(s) to answer the user's query.\n",
|
||||
" \"\"\",\n",
|
||||
" tools=tools,\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "uZp3cCBs9fMS"
|
||||
},
|
||||
"source": [
|
||||
"# User Query and Agent Response"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 777,
|
||||
"referenced_widgets": [
|
||||
"5112c2c89e944d99a9bfbe35d7186a96",
|
||||
"8dd112d60a6148e3b6cce31d7fb4eb0f"
|
||||
]
|
||||
},
|
||||
"id": "VhcEo-2q9HSv",
|
||||
"outputId": "8bf73c8a-4d0d-47dd-b151-a2a49c79b1f8"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Ask your question (or type 'quit' to exit): hi\n",
|
||||
"\n",
|
||||
"--- Thinking ---\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Agent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Assistant</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #86a789; text-decoration-color: #86a789; font-weight: bold\">Tools:</span> <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">decision_risk_agent</span>, <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">problem_solving_innovation_agent</span>, <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">Systems___Complexity_Agent</span>, <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">bias_psychology_agent</span>, <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">Strategy___Competition_Agent</span>, <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">Learning___Communication_Agent</span>, <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">Efficiency___Process_Agent</span>, <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">motivation_human_factors_agent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mAgent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mAssistant\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;134;167;137mTools:\u001b[0m \u001b[3;38;2;180;212;255mdecision_risk_agent\u001b[0m, \u001b[3;38;2;180;212;255mproblem_solving_innovation_agent\u001b[0m, \u001b[3;38;2;180;212;255mSystems___Complexity_Agent\u001b[0m, \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[3;38;2;180;212;255mbias_psychology_agent\u001b[0m, \u001b[3;38;2;180;212;255mStrategy___Competition_Agent\u001b[0m, \u001b[3;38;2;180;212;255mLearning___Communication_Agent\u001b[0m, \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[3;38;2;180;212;255mEfficiency___Process_Agent\u001b[0m, \u001b[3;38;2;180;212;255mmotivation_human_factors_agent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 1.5s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 1.5s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> hi <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m hi \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Hello! How can I assist you today? <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Hello! How can I assist you today? \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Hello! How can I assist you today?\n",
|
||||
"\n",
|
||||
"---------------\n",
|
||||
"Ask your question (or type 'quit' to exit): exit\n",
|
||||
"\n",
|
||||
"--- Thinking ---\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Agent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Assistant</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #86a789; text-decoration-color: #86a789; font-weight: bold\">Tools:</span> <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">decision_risk_agent</span>, <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">problem_solving_innovation_agent</span>, <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">Systems___Complexity_Agent</span>, <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">bias_psychology_agent</span>, <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">Strategy___Competition_Agent</span>, <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">Learning___Communication_Agent</span>, <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">Efficiency___Process_Agent</span>, <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">motivation_human_factors_agent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mAgent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mAssistant\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;134;167;137mTools:\u001b[0m \u001b[3;38;2;180;212;255mdecision_risk_agent\u001b[0m, \u001b[3;38;2;180;212;255mproblem_solving_innovation_agent\u001b[0m, \u001b[3;38;2;180;212;255mSystems___Complexity_Agent\u001b[0m, \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[3;38;2;180;212;255mbias_psychology_agent\u001b[0m, \u001b[3;38;2;180;212;255mStrategy___Competition_Agent\u001b[0m, \u001b[3;38;2;180;212;255mLearning___Communication_Agent\u001b[0m, \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[3;38;2;180;212;255mEfficiency___Process_Agent\u001b[0m, \u001b[3;38;2;180;212;255mmotivation_human_factors_agent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "5112c2c89e944d99a9bfbe35d7186a96",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 1.2s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 1.2s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> exit <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m exit \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> If you have any more questions in the future, feel free to ask. Have a great day! Goodbye! <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m If you have any more questions in the future, feel free to ask. Have a great day! Goodbye! \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"If you have any more questions in the future, feel free to ask. Have a great day! Goodbye!\n",
|
||||
"\n",
|
||||
"---------------\n",
|
||||
"Ask your question (or type 'quit' to exit): quit\n",
|
||||
"Cognitive Assistant Agent Team - Finished.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"user_query = input(\"Ask your question (or type 'quit' to exit): \")\n",
|
||||
"while user_query.lower() != 'quit':\n",
|
||||
" print(\"\\n--- Thinking ---\")\n",
|
||||
" response = agent.start(user_query)\n",
|
||||
" print(response)\n",
|
||||
" print(\"\\n---------------\")\n",
|
||||
" user_query = input(\"Ask your question (or type 'quit' to exit): \")\n",
|
||||
"print(\"Cognitive Assistant Agent Team - Finished.\")"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,774 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "E5vgaurA6rjL"
|
||||
},
|
||||
"source": [
|
||||
"# 🖥️ Universal Desktop Utility Agents (PraisonAI Agents)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "XlS85r0d6s93"
|
||||
},
|
||||
"source": [
|
||||
"This notebook demonstrates a set of desktop utility agents using PraisonAI Agents. The agents can execute terminal commands, summarize files, and perform general-purpose search and summarization tasks. Custom tools are provided for OS detection, folder location, and running platform-specific commands."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "hrOaiAK_9vtl"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/universal_desktop_agents..ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "V1engZ4W9f0H"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"metadata": {
|
||||
"id": "cLNbcVbD9NKB"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonaiagents openai --quiet"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "dtUWxbdz9izh"
|
||||
},
|
||||
"source": [
|
||||
"# Set Up API Key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"metadata": {
|
||||
"id": "wjTwTRSo9Pir"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = \"Enter your api key\" # <-- Replace with your actual OpenAI API key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "1EAWunl79oF4"
|
||||
},
|
||||
"source": [
|
||||
"# Tools (Imports)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"metadata": {
|
||||
"id": "eWeuVSDg9U8F"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from praisonaiagents import Agent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "qONZuK0A9qj1"
|
||||
},
|
||||
"source": [
|
||||
"# YAML Prompt (Role, Goal, Instructions)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"metadata": {
|
||||
"id": "HNZSMlTp9WjF"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Terminal Agent\n",
|
||||
"TERMINAL_ROLE = (\n",
|
||||
" \"You are a smart and proactive terminal agent designed to execute shell commands based on natural language prompts.\"\n",
|
||||
")\n",
|
||||
"TERMINAL_GOAL = (\n",
|
||||
" \"Explain how to execute user commands, resolve folder paths, and adapt to the user's operating system.\"\n",
|
||||
")\n",
|
||||
"TERMINAL_INSTRUCTIONS = (\n",
|
||||
" \"- If the command involves a known system directory (e.g., Documents, Desktop), explain how to resolve its path.\\n\"\n",
|
||||
" \"- If you do not know the OS, explain how to detect it.\\n\"\n",
|
||||
" \"- On macOS/Linux, explain how to use the terminal. On Windows, explain how to use Command Prompt or PowerShell.\\n\"\n",
|
||||
" \"- Prepend 'yes |' to commands that may prompt for confirmation.\\n\"\n",
|
||||
" \"- Never hardcode OS-specific commands until you know the platform.\"\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"# File Summarize Agent\n",
|
||||
"FILE_ROLE = (\n",
|
||||
" \"You are FileSummarizeAgent, an intelligent assistant that processes and summarizes various types of files.\"\n",
|
||||
")\n",
|
||||
"FILE_GOAL = (\n",
|
||||
" \"Explain how to extract meaningful information and present it in an organized and user-friendly format.\"\n",
|
||||
")\n",
|
||||
"FILE_INSTRUCTIONS = (\n",
|
||||
" \"Describe how to summarize the file's purpose, content, and structure. For code, explain architecture and modules. For documents, highlight structure and key ideas.\"\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"# General Purpose Agent\n",
|
||||
"GENERAL_ROLE = (\n",
|
||||
" \"You are an intelligent assistant embedded in a search interface.\"\n",
|
||||
")\n",
|
||||
"GENERAL_GOAL = (\n",
|
||||
" \"Help with searches, summarize information, define words, and write small code snippets.\"\n",
|
||||
")\n",
|
||||
"GENERAL_INSTRUCTIONS = (\n",
|
||||
" \"Keep all responses brief and focused. For web queries, explain how to search online.\"\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "57397P3b9tzq"
|
||||
},
|
||||
"source": [
|
||||
"# Main (Agent Setup & Example)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000,
|
||||
"referenced_widgets": [
|
||||
"fe56c8b8fbe84f5b948495de5bd9869c",
|
||||
"c245a4d56ce44c8dbe90d87c981f7fe9",
|
||||
"a9a7af0c281c4a8787d6cfe66dca0244",
|
||||
"98c0f7750c3b4eb5af428d16ee6f28c5",
|
||||
"b782f03372b44eab96597bde5522fcd2",
|
||||
"ec3c0a539dfc435787b6ecd7ed9129bf"
|
||||
]
|
||||
},
|
||||
"id": "K4hnUl5l9Yiv",
|
||||
"outputId": "d6355fc8-fafa-4db4-f7f8-9bfe1112bff7"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Agent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">You are a smart and proactive terminal agent designed to execute shell commands based on natural </span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">language prompts.</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mAgent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mYou are a smart and proactive terminal agent designed to execute shell commands based on natural \u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;255;229;229mlanguage prompts.\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "fe56c8b8fbe84f5b948495de5bd9869c",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 3.7s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 3.7s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> How can I list all files in the Documents folder on Windows? <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m How can I list all files in the Documents folder on Windows? \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> To list all files in the Documents folder on Windows, you can use either Command Prompt or PowerShell. Here's <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> how to do it: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">Open Command Prompt:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Press <span style=\"color: #008080; text-decoration-color: #008080; background-color: #000000; font-weight: bold\">Win + R</span>, type <span style=\"color: #008080; text-decoration-color: #008080; background-color: #000000; font-weight: bold\">cmd</span>, and press <span style=\"color: #008080; text-decoration-color: #008080; background-color: #000000; font-weight: bold\">Enter</span>. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">Navigate to the Documents folder:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>The Documents folder is typically located in your user directory. You can navigate to it by entering the <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>following command: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span><span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">cd %USERPROFILE%</span><span style=\"color: #ae81ff; text-decoration-color: #ae81ff; background-color: #272822\">\\D</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">ocuments</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">List all files:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Once you're in the Documents directory, you can list all files by typing: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span><span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">dir</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Alternatively, you can use PowerShell: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">Open PowerShell:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Press <span style=\"color: #008080; text-decoration-color: #008080; background-color: #000000; font-weight: bold\">Win + X</span> and select <span style=\"color: #008080; text-decoration-color: #008080; background-color: #000000; font-weight: bold\">Windows PowerShell</span>. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">List all files in the Documents folder:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>You can directly list all files in the Documents folder with: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span><span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">Get-ChildItem -Path $HOME</span><span style=\"color: #ae81ff; text-decoration-color: #ae81ff; background-color: #272822\">\\D</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">ocuments</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> These commands will display all files and directories within your Documents folder. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m To list all files in the Documents folder on Windows, you can use either Command Prompt or PowerShell. Here's \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m how to do it: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0m\u001b[1mOpen Command Prompt:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mPress \u001b[1;36;40mWin + R\u001b[0m, type \u001b[1;36;40mcmd\u001b[0m, and press \u001b[1;36;40mEnter\u001b[0m. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mNavigate to the Documents folder:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mThe Documents folder is typically located in your user directory. You can navigate to it by entering the \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mfollowing command: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mcd\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m%USERPROFILE%\u001b[0m\u001b[38;2;174;129;255;48;2;39;40;34m\\D\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mocuments\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0m\u001b[1mList all files:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mOnce you're in the Documents directory, you can list all files by typing: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mdir\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Alternatively, you can use PowerShell: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0m\u001b[1mOpen PowerShell:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mPress \u001b[1;36;40mWin + X\u001b[0m and select \u001b[1;36;40mWindows PowerShell\u001b[0m. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mList all files in the Documents folder:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mYou can directly list all files in the Documents folder with: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mGet-ChildItem\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m-Path\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m$HOME\u001b[0m\u001b[38;2;174;129;255;48;2;39;40;34m\\D\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mocuments\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m These commands will display all files and directories within your Documents folder. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"To list all files in the Documents folder on Windows, you can use either Command Prompt or PowerShell. Here's how to do it:\n",
|
||||
"\n",
|
||||
"1. **Open Command Prompt:**\n",
|
||||
" - Press `Win + R`, type `cmd`, and press `Enter`.\n",
|
||||
"\n",
|
||||
"2. **Navigate to the Documents folder:**\n",
|
||||
" - The Documents folder is typically located in your user directory. You can navigate to it by entering the following command:\n",
|
||||
" ```shell\n",
|
||||
" cd %USERPROFILE%\\Documents\n",
|
||||
" ```\n",
|
||||
"\n",
|
||||
"3. **List all files:**\n",
|
||||
" - Once you're in the Documents directory, you can list all files by typing:\n",
|
||||
" ```shell\n",
|
||||
" dir\n",
|
||||
" ```\n",
|
||||
"\n",
|
||||
"Alternatively, you can use PowerShell:\n",
|
||||
"\n",
|
||||
"1. **Open PowerShell:**\n",
|
||||
" - Press `Win + X` and select `Windows PowerShell`.\n",
|
||||
"\n",
|
||||
"2. **List all files in the Documents folder:**\n",
|
||||
" - You can directly list all files in the Documents folder with:\n",
|
||||
" ```shell\n",
|
||||
" Get-ChildItem -Path $HOME\\Documents\n",
|
||||
" ```\n",
|
||||
"\n",
|
||||
"These commands will display all files and directories within your Documents folder.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Agent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">You are FileSummarizeAgent, an intelligent assistant that processes and summarizes various types of </span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">files.</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mAgent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mYou are FileSummarizeAgent, an intelligent assistant that processes and summarizes various types of \u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;255;229;229mfiles.\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "a9a7af0c281c4a8787d6cfe66dca0244",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 6.9s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 6.9s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> How would you summarize the file at: example.txt? <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m How would you summarize the file at: example.txt? \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> To summarize a file like \"example.txt,\" follow these steps: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">Determine the File Type and Purpose</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Identify if the file is a document, code, or data file. This will guide how you approach the summary. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Understand the purpose of the file by looking at its title, metadata, or any introductory sections. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">Content Analysis</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">For Documents</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Look for headings, subheadings, and bullet points to understand the structure. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Identify key ideas, arguments, or themes in each section. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Note any conclusions or summaries provided by the author. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">For Code</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Identify the main modules or functions and their purposes. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Look for comments and documentation within the code that explain its functionality. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Understand the architecture by identifying how different parts of the code interact. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">Structure Identification</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Documents</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Note the introduction, body, and conclusion sections. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Identify any appendices, references, or additional resources. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Code</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Identify the main script or entry point. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Note any libraries or frameworks used. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Understand the flow of execution and data handling. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 4 </span><span style=\"font-weight: bold\">Summarization</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">For Documents</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Create a concise summary that captures the main points and conclusions. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Highlight any unique insights or important data. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">For Code</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Summarize the overall functionality and purpose of the code. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Highlight key modules and their roles within the application. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 5 </span><span style=\"font-weight: bold\">Presentation</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Organize the summary in a logical order, starting with the most important information. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Use bullet points or numbered lists for clarity. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>Ensure the summary is concise and free of jargon, making it accessible to a broad audience. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> By following these steps, you can create a comprehensive and user-friendly summary of the file \"example.txt\" or <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> any similar file. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m To summarize a file like \"example.txt,\" follow these steps: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0m\u001b[1mDetermine the File Type and Purpose\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mIdentify if the file is a document, code, or data file. This will guide how you approach the summary. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mUnderstand the purpose of the file by looking at its title, metadata, or any introductory sections. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mContent Analysis\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mFor Documents\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mLook for headings, subheadings, and bullet points to understand the structure. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mIdentify key ideas, arguments, or themes in each section. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mNote any conclusions or summaries provided by the author. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mFor Code\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mIdentify the main modules or functions and their purposes. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mLook for comments and documentation within the code that explain its functionality. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mUnderstand the architecture by identifying how different parts of the code interact. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0m\u001b[1mStructure Identification\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mDocuments\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mNote the introduction, body, and conclusion sections. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mIdentify any appendices, references, or additional resources. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mCode\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mIdentify the main script or entry point. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mNote any libraries or frameworks used. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mUnderstand the flow of execution and data handling. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 4 \u001b[0m\u001b[1mSummarization\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mFor Documents\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mCreate a concise summary that captures the main points and conclusions. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mHighlight any unique insights or important data. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mFor Code\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mSummarize the overall functionality and purpose of the code. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mHighlight key modules and their roles within the application. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 5 \u001b[0m\u001b[1mPresentation\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mOrganize the summary in a logical order, starting with the most important information. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mUse bullet points or numbered lists for clarity. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mEnsure the summary is concise and free of jargon, making it accessible to a broad audience. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m By following these steps, you can create a comprehensive and user-friendly summary of the file \"example.txt\" or \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m any similar file. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"To summarize a file like \"example.txt,\" follow these steps:\n",
|
||||
"\n",
|
||||
"1. **Determine the File Type and Purpose**: \n",
|
||||
" - Identify if the file is a document, code, or data file. This will guide how you approach the summary.\n",
|
||||
" - Understand the purpose of the file by looking at its title, metadata, or any introductory sections.\n",
|
||||
"\n",
|
||||
"2. **Content Analysis**:\n",
|
||||
" - **For Documents**: \n",
|
||||
" - Look for headings, subheadings, and bullet points to understand the structure.\n",
|
||||
" - Identify key ideas, arguments, or themes in each section.\n",
|
||||
" - Note any conclusions or summaries provided by the author.\n",
|
||||
" - **For Code**:\n",
|
||||
" - Identify the main modules or functions and their purposes.\n",
|
||||
" - Look for comments and documentation within the code that explain its functionality.\n",
|
||||
" - Understand the architecture by identifying how different parts of the code interact.\n",
|
||||
"\n",
|
||||
"3. **Structure Identification**:\n",
|
||||
" - **Documents**: \n",
|
||||
" - Note the introduction, body, and conclusion sections.\n",
|
||||
" - Identify any appendices, references, or additional resources.\n",
|
||||
" - **Code**:\n",
|
||||
" - Identify the main script or entry point.\n",
|
||||
" - Note any libraries or frameworks used.\n",
|
||||
" - Understand the flow of execution and data handling.\n",
|
||||
"\n",
|
||||
"4. **Summarization**:\n",
|
||||
" - **For Documents**: \n",
|
||||
" - Create a concise summary that captures the main points and conclusions.\n",
|
||||
" - Highlight any unique insights or important data.\n",
|
||||
" - **For Code**:\n",
|
||||
" - Summarize the overall functionality and purpose of the code.\n",
|
||||
" - Highlight key modules and their roles within the application.\n",
|
||||
"\n",
|
||||
"5. **Presentation**:\n",
|
||||
" - Organize the summary in a logical order, starting with the most important information.\n",
|
||||
" - Use bullet points or numbered lists for clarity.\n",
|
||||
" - Ensure the summary is concise and free of jargon, making it accessible to a broad audience.\n",
|
||||
"\n",
|
||||
"By following these steps, you can create a comprehensive and user-friendly summary of the file \"example.txt\" or any similar file.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Agent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">You are an intelligent assistant embedded in a search interface.</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mAgent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mYou are an intelligent assistant embedded in a search interface.\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "b782f03372b44eab96597bde5522fcd2",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 1.8s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 1.8s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> How can I search the web for the latest AI news? <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m How can I search the web for the latest AI news? \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> To search for the latest AI news, go to a search engine like Google and enter keywords such as \"latest AI news\" <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> or \"recent developments in AI.\" You can also use news-specific platforms like Google News or set up alerts for <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> AI-related topics. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m To search for the latest AI news, go to a search engine like Google and enter keywords such as \"latest AI news\" \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m or \"recent developments in AI.\" You can also use news-specific platforms like Google News or set up alerts for \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m AI-related topics. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"To search for the latest AI news, go to a search engine like Google and enter keywords such as \"latest AI news\" or \"recent developments in AI.\" You can also use news-specific platforms like Google News or set up alerts for AI-related topics.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Terminal Agent\n",
|
||||
"terminal_agent = Agent(\n",
|
||||
" role=TERMINAL_ROLE,\n",
|
||||
" goal=TERMINAL_GOAL,\n",
|
||||
" instructions=TERMINAL_INSTRUCTIONS\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"# File Summarize Agent\n",
|
||||
"file_summarize_agent = Agent(\n",
|
||||
" role=FILE_ROLE,\n",
|
||||
" goal=FILE_GOAL,\n",
|
||||
" instructions=FILE_INSTRUCTIONS\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"# General Purpose Agent\n",
|
||||
"general_purpose_agent = Agent(\n",
|
||||
" role=GENERAL_ROLE,\n",
|
||||
" goal=GENERAL_GOAL,\n",
|
||||
" instructions=GENERAL_INSTRUCTIONS\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"# Example usage\n",
|
||||
"def run_terminal_agent(query):\n",
|
||||
" return terminal_agent.start(query)\n",
|
||||
"\n",
|
||||
"def run_file_summarize_agent(file_path):\n",
|
||||
" prompt = f\"How would you summarize the file at: {file_path}?\"\n",
|
||||
" return file_summarize_agent.start(prompt)\n",
|
||||
"\n",
|
||||
"def run_general_purpose_agent(query):\n",
|
||||
" return general_purpose_agent.start(query)\n",
|
||||
"\n",
|
||||
"# Try a sample terminal command\n",
|
||||
"print(run_terminal_agent(\"How can I list all files in the Documents folder on Windows?\"))\n",
|
||||
"\n",
|
||||
"# Try a file summary (replace 'example.txt' with a real file path)\n",
|
||||
"print(run_file_summarize_agent(\"example.txt\"))\n",
|
||||
"\n",
|
||||
"# Try a general search\n",
|
||||
"print(run_general_purpose_agent(\"How can I search the web for the latest AI news?\"))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
@@ -0,0 +1,418 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "3XNenYs9vwef"
|
||||
},
|
||||
"source": [
|
||||
"# 📧 Work Email Agent with Custom Tools (PraisonAI Agents)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "TvFpalM6vywF"
|
||||
},
|
||||
"source": [
|
||||
"This notebook demonstrates an AI agent that manages, summarizes, and responds to work emails using PraisonAI Agents. It includes a custom tool for extracting action items from email content."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "dKVYAK_OwmBs"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/work_email_agent.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "HI3poa3Bv05X"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "cxz7rFqTv0X_",
|
||||
"outputId": "0c6e3870-152b-49ac-c344-20f94e0d8c13"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m40.1/40.1 kB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m178.2/178.2 kB\u001b[0m \u001b[31m15.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m150.9/150.9 kB\u001b[0m \u001b[31m12.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m104.9/104.9 kB\u001b[0m \u001b[31m9.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m45.2/45.2 kB\u001b[0m \u001b[31m3.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[?25h"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"!pip install praisonaiagents openai --quiet"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "76GwcX00wVhD"
|
||||
},
|
||||
"source": [
|
||||
"# Set Up API Key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"id": "J9vIRYwRv7IR"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = \"Enter your api key\" # <-- Replace with your actual OpenAI API key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "5VwIXAgjwbaH"
|
||||
},
|
||||
"source": [
|
||||
"# Tools (Imports & Custom Tool)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"id": "7N_trHCYwAfI"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from praisonaiagents import Agent\n",
|
||||
"\n",
|
||||
"# Custom tool: Extract action items from email text\n",
|
||||
"def extract_action_items(email_text: str) -> list:\n",
|
||||
" \"\"\"\n",
|
||||
" Extracts action items from the email content.\n",
|
||||
" Returns a list of sentences that are likely action items.\n",
|
||||
" \"\"\"\n",
|
||||
" import re\n",
|
||||
" action_keywords = [\"please\", \"make sure\", \"need to\", \"must\", \"required\", \"should\"]\n",
|
||||
" sentences = re.split(r'(?<=[.!?]) +', email_text)\n",
|
||||
" actions = [s for s in sentences if any(k in s.lower() for k in action_keywords)]\n",
|
||||
" return actions\n",
|
||||
"\n",
|
||||
"custom_tools = [\n",
|
||||
" {\n",
|
||||
" \"name\": \"extract_action_items\",\n",
|
||||
" \"description\": \"Extracts action items from the email content.\",\n",
|
||||
" \"function\": extract_action_items,\n",
|
||||
" \"args\": [\"email_text\"]\n",
|
||||
" }\n",
|
||||
"]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "lp-U374NweMn"
|
||||
},
|
||||
"source": [
|
||||
"# YAML Prompt (Role, Goal, Instructions)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {
|
||||
"id": "CTgnmMoRwDBJ"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"ROLE = (\n",
|
||||
" \"Chill work email assistant. Expert in summarizing, organizing, and replying to work emails with a calm and professional tone.\"\n",
|
||||
")\n",
|
||||
"GOAL = (\n",
|
||||
" \"Help the user manage their inbox, summarize email threads, extract action items, and draft polite, effective replies.\"\n",
|
||||
")\n",
|
||||
"INSTRUCTIONS = (\n",
|
||||
" \"Given the content of one or more work emails, summarize the main points, extract action items using the provided tool, \"\n",
|
||||
" \"suggest actions, and draft a calm, professional reply if requested. \"\n",
|
||||
" \"Always keep the tone friendly and stress-free.\"\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "PCUnZPwgwhHL"
|
||||
},
|
||||
"source": [
|
||||
"# Main (Agent Setup & Example)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000,
|
||||
"referenced_widgets": [
|
||||
"046932f8510343a5b0d433d38fa73fc9",
|
||||
"399ad0a94d5f4130a86343896a66c655"
|
||||
]
|
||||
},
|
||||
"id": "X0yhFyOTwEt4",
|
||||
"outputId": "245003af-59ed-4f40-a896-dd44b33aad04"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Agent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Chill work email assistant. Expert in summarizing, organizing, and replying to work emails with a calm </span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">and professional tone.</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mAgent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mChill work email assistant. Expert in summarizing, organizing, and replying to work emails with a calm \u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;255;229;229mand professional tone.\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "046932f8510343a5b0d433d38fa73fc9",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 3.0s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 3.0s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> EMAIL: Hi team, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Just a reminder that the project update meeting is scheduled for tomorrow at 10am. Please make sure your slides <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> are ready. Let me know if you have any questions. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Best, Manager <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> REQUEST: summarize, extract action items, and draft reply Summarize the email, list any action items, and draft <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> a calm, professional reply. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m EMAIL: Hi team, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Just a reminder that the project update meeting is scheduled for tomorrow at 10am. Please make sure your slides \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m are ready. Let me know if you have any questions. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Best, Manager \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m REQUEST: summarize, extract action items, and draft reply Summarize the email, list any action items, and draft \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m a calm, professional reply. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\">Summary:</span> The manager is reminding the team about the project update meeting scheduled for tomorrow at 10 am and <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> asks everyone to have their slides ready. The manager is open to questions if there are any. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\">Action Items:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span>Prepare slides for the project update meeting. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span>Attend the meeting tomorrow at 10 am. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span>Reach out to the manager if there are any questions. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\">Draft Reply:</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Subject: Re: Project Update Meeting Reminder <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Hi [Manager's Name], <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Thank you for the reminder about tomorrow's meeting. I will ensure my slides are ready and look forward to our <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> discussion. Please let me know if there's anything specific you would like me to focus on during my update. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Best regards, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> [Your Name] <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mSummary:\u001b[0m The manager is reminding the team about the project update meeting scheduled for tomorrow at 10 am and \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m asks everyone to have their slides ready. The manager is open to questions if there are any. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mAction Items:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0mPrepare slides for the project update meeting. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0mAttend the meeting tomorrow at 10 am. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0mReach out to the manager if there are any questions. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mDraft Reply:\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Subject: Re: Project Update Meeting Reminder \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Hi [Manager's Name], \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Thank you for the reminder about tomorrow's meeting. I will ensure my slides are ready and look forward to our \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m discussion. Please let me know if there's anything specific you would like me to focus on during my update. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Best regards, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m [Your Name] \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"**Summary:**\n",
|
||||
"The manager is reminding the team about the project update meeting scheduled for tomorrow at 10 am and asks everyone to have their slides ready. The manager is open to questions if there are any.\n",
|
||||
"\n",
|
||||
"**Action Items:**\n",
|
||||
"1. Prepare slides for the project update meeting.\n",
|
||||
"2. Attend the meeting tomorrow at 10 am.\n",
|
||||
"3. Reach out to the manager if there are any questions.\n",
|
||||
"\n",
|
||||
"**Draft Reply:**\n",
|
||||
"\n",
|
||||
"Subject: Re: Project Update Meeting Reminder\n",
|
||||
"\n",
|
||||
"Hi [Manager's Name],\n",
|
||||
"\n",
|
||||
"Thank you for the reminder about tomorrow's meeting. I will ensure my slides are ready and look forward to our discussion. Please let me know if there's anything specific you would like me to focus on during my update.\n",
|
||||
"\n",
|
||||
"Best regards,\n",
|
||||
"\n",
|
||||
"[Your Name]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Create the email agent (no custom tools)\n",
|
||||
"email_agent = Agent(\n",
|
||||
" role=ROLE,\n",
|
||||
" goal=GOAL,\n",
|
||||
" instructions=INSTRUCTIONS\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"# Example usage\n",
|
||||
"def chill_email_action(email_content, request=\"summarize, extract action items, and draft reply\"):\n",
|
||||
" prompt = (\n",
|
||||
" f\"EMAIL:\\n{email_content}\\n\\n\"\n",
|
||||
" f\"REQUEST: {request}\\n\"\n",
|
||||
" \"Summarize the email, list any action items, and draft a calm, professional reply.\"\n",
|
||||
" )\n",
|
||||
" return email_agent.start(prompt)\n",
|
||||
"\n",
|
||||
"# Try a sample email\n",
|
||||
"sample_email = (\n",
|
||||
" \"Hi team,\\n\\n\"\n",
|
||||
" \"Just a reminder that the project update meeting is scheduled for tomorrow at 10am. \"\n",
|
||||
" \"Please make sure your slides are ready. Let me know if you have any questions.\\n\\n\"\n",
|
||||
" \"Best,\\nManager\"\n",
|
||||
")\n",
|
||||
"result = chill_email_action(sample_email)\n",
|
||||
"print(result)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
@@ -0,0 +1,441 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "bLeMxwWimvzX",
|
||||
"metadata": {
|
||||
"id": "bLeMxwWimvzX"
|
||||
},
|
||||
"source": [
|
||||
"# Code Analysis Agent\n",
|
||||
"Learn how to create AI agents for comprehensive code analysis and quality assessment."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "P3X8PXPyojnL",
|
||||
"metadata": {
|
||||
"id": "P3X8PXPyojnL"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/code_analysis_agent.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "xEs8bwWfmvza",
|
||||
"metadata": {
|
||||
"id": "xEs8bwWfmvza"
|
||||
},
|
||||
"source": [
|
||||
"## Dependencies\n",
|
||||
"Install the required packages."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "_RPiU3j6mvzb",
|
||||
"metadata": {
|
||||
"id": "_RPiU3j6mvzb"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonaiagents gitingest"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "81-orTkzmvzc",
|
||||
"metadata": {
|
||||
"id": "81-orTkzmvzc"
|
||||
},
|
||||
"source": [
|
||||
"## Set API Key\n",
|
||||
"Set your OpenAI API key as an environment variable in your terminal:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "84iL7rGimvzc",
|
||||
"metadata": {
|
||||
"id": "84iL7rGimvzc"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"os.environ['OPENAI_API_KEY'] = 'your_api_key_here'"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "TV15GFsRmvzc",
|
||||
"metadata": {
|
||||
"id": "TV15GFsRmvzc"
|
||||
},
|
||||
"source": [
|
||||
"## Tools and Data Models\n",
|
||||
"Define the agent, task, and output schema."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0Wq_g0pNmvzd",
|
||||
"metadata": {
|
||||
"id": "0Wq_g0pNmvzd"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from praisonaiagents import Agent, Task, PraisonAIAgents\n",
|
||||
"from pydantic import BaseModel\n",
|
||||
"from typing import List, Dict\n",
|
||||
"from gitingest import ingest\n",
|
||||
"\n",
|
||||
"class CodeMetrics(BaseModel):\n",
|
||||
" category: str\n",
|
||||
" score: int\n",
|
||||
" findings: List[str]\n",
|
||||
"\n",
|
||||
"class CodeAnalysisReport(BaseModel):\n",
|
||||
" overall_quality: int\n",
|
||||
" code_metrics: List[CodeMetrics]\n",
|
||||
" architecture_score: int\n",
|
||||
" maintainability_score: int\n",
|
||||
" performance_score: int\n",
|
||||
" security_score: int\n",
|
||||
" test_coverage: int\n",
|
||||
" key_strengths: List[str]\n",
|
||||
" improvement_areas: List[str]\n",
|
||||
" tech_stack: List[str]\n",
|
||||
" recommendations: List[str]\n",
|
||||
" complexity_metrics: Dict[str, int]\n",
|
||||
" best_practices: List[Dict[str, str]]\n",
|
||||
" potential_risks: List[str]\n",
|
||||
" documentation_quality: int"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "EatrK7-wmvzd",
|
||||
"metadata": {
|
||||
"id": "EatrK7-wmvzd"
|
||||
},
|
||||
"source": [
|
||||
"## YAML Prompt Setup\n",
|
||||
"Define the agent and task with expectations."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "EdZNSOy-mvze",
|
||||
"metadata": {
|
||||
"id": "EdZNSOy-mvze"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"code_analyzer = Agent(\n",
|
||||
" role=\"Code Analysis Expert\",\n",
|
||||
" goal=\"Provide comprehensive code evaluation and recommendations\",\n",
|
||||
" backstory=\"\"\"Expert code analyst specializing in architecture review,\n",
|
||||
" best practices, and technical debt assessment.\"\"\",\n",
|
||||
" verbose=True\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"code_analysis_task = Task(\n",
|
||||
" description=\"\"\"Analyze code repository and provide structured evaluation:\n",
|
||||
"\n",
|
||||
" 1. Overall Quality (0-100)\n",
|
||||
" 2. Core Metrics Analysis:\n",
|
||||
" - Architecture and Design\n",
|
||||
" - Code Maintainability\n",
|
||||
" - Performance Optimization\n",
|
||||
" - Security Practices\n",
|
||||
" - Test Coverage\n",
|
||||
" 3. Technical Assessment:\n",
|
||||
" - Technology Stack Review\n",
|
||||
" - Code Complexity Analysis\n",
|
||||
" - Best Practices Adherence\n",
|
||||
" - Risk Assessment\n",
|
||||
" 4. Recommendations:\n",
|
||||
" - Key Improvements\n",
|
||||
" - Architecture Suggestions\n",
|
||||
" - Security Enhancements\"\"\",\n",
|
||||
" expected_output=\"Detailed code analysis report with metrics and recommendations\",\n",
|
||||
" agent=code_analyzer,\n",
|
||||
" output_pydantic=CodeAnalysisReport\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "CeLS55ROmvzf",
|
||||
"metadata": {
|
||||
"id": "CeLS55ROmvzf"
|
||||
},
|
||||
"source": [
|
||||
"## Main Function\n",
|
||||
"Function to analyze code from GitHub URL or local path."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "3Eo6LEOxmvzf",
|
||||
"metadata": {
|
||||
"id": "3Eo6LEOxmvzf"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def analyze_code(code_source: str) -> CodeAnalysisReport:\n",
|
||||
" \"\"\"\n",
|
||||
" Analyze code from directory path or GitHub URL\n",
|
||||
" \"\"\"\n",
|
||||
" # Ingest code content\n",
|
||||
" summary, tree, content = ingest(code_source)\n",
|
||||
"\n",
|
||||
" # Concatenate context into structured format\n",
|
||||
" context_text = f\"\"\"\n",
|
||||
" CODE REPOSITORY ANALYSIS\n",
|
||||
" =======================\n",
|
||||
"\n",
|
||||
" SUMMARY\n",
|
||||
" -------\n",
|
||||
" {summary}\n",
|
||||
"\n",
|
||||
" REPOSITORY STRUCTURE\n",
|
||||
" -------------------\n",
|
||||
" {tree}\n",
|
||||
"\n",
|
||||
" SOURCE CODE\n",
|
||||
" -----------\n",
|
||||
" {content}\n",
|
||||
" \"\"\"\n",
|
||||
"\n",
|
||||
" # Initialize and run analysis\n",
|
||||
" agents = PraisonAIAgents(\n",
|
||||
" agents=[code_analyzer],\n",
|
||||
" tasks=[code_analysis_task]\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" return agents.start(context_text)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "v25nLA0pmvzf",
|
||||
"metadata": {
|
||||
"id": "v25nLA0pmvzf"
|
||||
},
|
||||
"source": [
|
||||
"## Output\n",
|
||||
"Example usage to run the analysis and view results."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "5BzccaeFmvzg",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000
|
||||
},
|
||||
"id": "5BzccaeFmvzg",
|
||||
"outputId": "8b4cddae-b6b3-4a92-8a13-30694cd09c52"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"\n",
|
||||
"### 👤 Agent: Code Analysis Expert\n",
|
||||
"\n",
|
||||
"**Role**: Provides comprehensive code evaluation and recommendations \n",
|
||||
"**Backstory**: Expert in architecture, best practices, and technical assessment \n"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"─── 📊 AGENT CODE ANALYSIS REPORT ───\n",
|
||||
"{\n",
|
||||
" \"overall_quality\": 85,\n",
|
||||
" \"code_metrics\": [\n",
|
||||
" {\n",
|
||||
" \"category\": \"Architecture and Design\",\n",
|
||||
" \"score\": 80,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"Modular structure with clear separation of concerns.\",\n",
|
||||
" \"Use of type annotations improves code readability and maintainability.\"\n",
|
||||
" ]\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"category\": \"Code Maintainability\",\n",
|
||||
" \"score\": 85,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"Consistent use of type hints and NamedTuple for structured data.\",\n",
|
||||
" \"Logical organization of functions and classes.\"\n",
|
||||
" ]\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"category\": \"Performance Optimization\",\n",
|
||||
" \"score\": 75,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"Potential performance overhead due to repeated sys.stdout.write calls.\",\n",
|
||||
" \"Efficient use of optional parameters to control execution flow.\"\n",
|
||||
" ]\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"category\": \"Security Practices\",\n",
|
||||
" \"score\": 80,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"No obvious security vulnerabilities in the code.\",\n",
|
||||
" \"Proper encapsulation of functionality.\"\n",
|
||||
" ]\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"category\": \"Test Coverage\",\n",
|
||||
" \"score\": 70,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"Lack of explicit test cases in the provided code.\",\n",
|
||||
" \"Use of type checking suggests some level of validation.\"\n",
|
||||
" ]\n",
|
||||
" }\n",
|
||||
" ],\n",
|
||||
" \"architecture_score\": 80,\n",
|
||||
" \"maintainability_score\": 85,\n",
|
||||
" \"performance_score\": 75,\n",
|
||||
" \"security_score\": 80,\n",
|
||||
" \"test_coverage\": 70,\n",
|
||||
" \"key_strengths\": [\n",
|
||||
" \"Strong use of type annotations and typing extensions.\",\n",
|
||||
" \"Clear separation of CLI argument parsing and business logic.\"\n",
|
||||
" ],\n",
|
||||
" \"improvement_areas\": [\n",
|
||||
" \"Increase test coverage to ensure robustness.\",\n",
|
||||
" \"Optimize I/O operations to improve performance.\"\n",
|
||||
" ],\n",
|
||||
" \"tech_stack\": [\n",
|
||||
" \"Python\",\n",
|
||||
" \"argparse\",\n",
|
||||
" \"typing_extensions\"\n",
|
||||
" ],\n",
|
||||
" \"recommendations\": [\n",
|
||||
" \"Add unit tests to improve reliability.\",\n",
|
||||
" \"Consider async I/O for improved performance in CLI tools.\"\n",
|
||||
" ]\n",
|
||||
"}\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"from IPython.display import display, Markdown\n",
|
||||
"\n",
|
||||
"# Optional: Define agent info\n",
|
||||
"agent_info = \"\"\"\n",
|
||||
"### 👤 Agent: Code Analysis Expert\n",
|
||||
"\n",
|
||||
"**Role**: Provides comprehensive code evaluation and recommendations\n",
|
||||
"**Backstory**: Expert in architecture, best practices, and technical assessment\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"# Analysis Result Data\n",
|
||||
"analysis_result = {\n",
|
||||
" \"overall_quality\": 85,\n",
|
||||
" \"code_metrics\": [\n",
|
||||
" {\n",
|
||||
" \"category\": \"Architecture and Design\",\n",
|
||||
" \"score\": 80,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"Modular structure with clear separation of concerns.\",\n",
|
||||
" \"Use of type annotations improves code readability and maintainability.\"\n",
|
||||
" ]\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"category\": \"Code Maintainability\",\n",
|
||||
" \"score\": 85,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"Consistent use of type hints and NamedTuple for structured data.\",\n",
|
||||
" \"Logical organization of functions and classes.\"\n",
|
||||
" ]\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"category\": \"Performance Optimization\",\n",
|
||||
" \"score\": 75,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"Potential performance overhead due to repeated sys.stdout.write calls.\",\n",
|
||||
" \"Efficient use of optional parameters to control execution flow.\"\n",
|
||||
" ]\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"category\": \"Security Practices\",\n",
|
||||
" \"score\": 80,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"No obvious security vulnerabilities in the code.\",\n",
|
||||
" \"Proper encapsulation of functionality.\"\n",
|
||||
" ]\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"category\": \"Test Coverage\",\n",
|
||||
" \"score\": 70,\n",
|
||||
" \"findings\": [\n",
|
||||
" \"Lack of explicit test cases in the provided code.\",\n",
|
||||
" \"Use of type checking suggests some level of validation.\"\n",
|
||||
" ]\n",
|
||||
" }\n",
|
||||
" ],\n",
|
||||
" \"architecture_score\": 80,\n",
|
||||
" \"maintainability_score\": 85,\n",
|
||||
" \"performance_score\": 75,\n",
|
||||
" \"security_score\": 80,\n",
|
||||
" \"test_coverage\": 70,\n",
|
||||
" \"key_strengths\": [\n",
|
||||
" \"Strong use of type annotations and typing extensions.\",\n",
|
||||
" \"Clear separation of CLI argument parsing and business logic.\"\n",
|
||||
" ],\n",
|
||||
" \"improvement_areas\": [\n",
|
||||
" \"Increase test coverage to ensure robustness.\",\n",
|
||||
" \"Optimize I/O operations to improve performance.\"\n",
|
||||
" ],\n",
|
||||
" \"tech_stack\": [\"Python\", \"argparse\", \"typing_extensions\"],\n",
|
||||
" \"recommendations\": [\n",
|
||||
" \"Add unit tests to improve reliability.\",\n",
|
||||
" \"Consider async I/O for improved performance in CLI tools.\"\n",
|
||||
" ]\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"# Display Agent Info and Analysis Report\n",
|
||||
"display(Markdown(agent_info))\n",
|
||||
"print(\"─── 📊 AGENT CODE ANALYSIS REPORT ───\")\n",
|
||||
"print(json.dumps(analysis_result, indent=4))\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python",
|
||||
"version": "3.10"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
+1
-1
@@ -65,7 +65,7 @@
|
||||
"source": [
|
||||
"from llama_index.llms.openai import OpenAI\n",
|
||||
"\n",
|
||||
"llm = OpenAI(model=\"gpt-4o-mini\", api_key=\"Enter your api key here\") # Replace with your OpenAI API key\n"
|
||||
"llm = OpenAI(model=\"gpt-5-nano\", api_key=\"Enter your api key here\") # Replace with your OpenAI API key\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
+1199
File diff suppressed because it is too large.
Load diff
File renamed without changes.
@@ -0,0 +1,466 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "YiPIh4QSYBCW"
|
||||
},
|
||||
"source": [
|
||||
"# 🤖 GitHub Repo Analyzer Agent\n",
|
||||
"AI agent powered by PraisonAI and OpenAI to analyze GitHub repositories using GitHub API."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "2Jkig4AGZG1n"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/github_repo_analyzer_agent.ipynb)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "aAiN-i3UYvsN"
|
||||
},
|
||||
"source": [
|
||||
"# 📦 Install dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "1B_sEv9PYBCZ"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonaiagents openai requests"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "eUViHgGPaObo"
|
||||
},
|
||||
"source": [
|
||||
"# Tools Used"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "ut_APj9xaSQI"
|
||||
},
|
||||
"source": [
|
||||
"🧠 praisonaiagents – Smart AI agent\n",
|
||||
"\n",
|
||||
"🔗 openai – GPT-powered responses\n",
|
||||
"\n",
|
||||
"📂 requests – GitHub repo analysis\n",
|
||||
"\n",
|
||||
"🖥️ Python I/O – Interactive CLI in notebook"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "hDsXrWYpYzuB"
|
||||
},
|
||||
"source": [
|
||||
"# 🔐 Set OpenAI API Key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "aea6TQ4hYBCb"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"if not os.getenv(\"OPENAI_API_KEY\"):\n",
|
||||
" os.environ[\"OPENAI_API_KEY\"] = input(\"🔐 Enter your OpenAI API key: \")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "OvQvZZonY2YI"
|
||||
},
|
||||
"source": [
|
||||
"# 🧠 Imports"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "1XSubvMsYBCc"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import requests\n",
|
||||
"import openai\n",
|
||||
"from praisonaiagents import Agent\n",
|
||||
"\n",
|
||||
"openai.api_key = os.environ[\"OPENAI_API_KEY\"]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "s0o_V2oqY4rJ"
|
||||
},
|
||||
"source": [
|
||||
"# 🤖 Create the Agent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "40KpW78vYBCc"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"agent = Agent(instructions=\"\"\"\n",
|
||||
"You are a GitHub codebase explainer. When given a repo URL, fetch summary of\n",
|
||||
"its files and provide insightful analysis. Be helpful and concise.\n",
|
||||
"\"\"\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "q4b3ts3lY-Fe"
|
||||
},
|
||||
"source": [
|
||||
"# 📂 Fetch GitHub repo file names"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "8fWBzdRxYBCd"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def fetch_repo_files(repo_url):\n",
|
||||
" api_url = repo_url.replace(\"https://github.com\", \"https://api.github.com/repos\") + \"/contents\"\n",
|
||||
" r = requests.get(api_url)\n",
|
||||
" return [f[\"name\"] for f in r.json()] if r.status_code == 200 else []"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "de0Du9OsZAjo"
|
||||
},
|
||||
"source": [
|
||||
"# 💬 Ask Agent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "v85t6c8PYBCd"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def ask_agent(repo_url):\n",
|
||||
" files = fetch_repo_files(repo_url)\n",
|
||||
" if not files:\n",
|
||||
" return \"❌ Cannot fetch repo contents.\"\n",
|
||||
" return agent.start(f\"Repo contains files: {files}. Analyze key components and structure.\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "8HOy15H0ZCsZ"
|
||||
},
|
||||
"source": [
|
||||
"# 🧪 Run the agent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000,
|
||||
"referenced_widgets": [
|
||||
"c536cd3c498244d4b0c2526b00610f29",
|
||||
"f0baa19f760c4a869064e51fde0ea4d0"
|
||||
]
|
||||
},
|
||||
"id": "QNmR8_ZdYBCd",
|
||||
"outputId": "448195d1-28eb-43c1-e86c-5308c4e6d089"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"🔗 Enter GitHub repository URL: https://github.com/DhivyaBharathy-web/agents\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Agent</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Assistant</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mAgent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mAssistant\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "c536cd3c498244d4b0c2526b00610f29",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 10.0s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 10.0s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Repo contains files: ['Fuel_Emission_Agent_Intelligence_Agent.ipynb', <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> 'fixed_Cognitive_Assistant_Agent_Team.ipynb', 'fixed_Crypto_Research_Agent_Intelligence_Agent.ipynb', <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> 'fixed_E_commerce_Shopping_Assistant.ipynb', 'fixed_Home_Buying_Real_Estate_Agent.ipynb', <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> 'fixed_YouTube_Influencer_Intelligence_Agent.ipynb', 'fixed_voiGno_Restaurant_Agent_PraisonAI.ipynb']. Analyze <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> key components and structure. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Repo contains files: ['Fuel_Emission_Agent_Intelligence_Agent.ipynb', \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m 'fixed_Cognitive_Assistant_Agent_Team.ipynb', 'fixed_Crypto_Research_Agent_Intelligence_Agent.ipynb', \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m 'fixed_E_commerce_Shopping_Assistant.ipynb', 'fixed_Home_Buying_Real_Estate_Agent.ipynb', \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m 'fixed_YouTube_Influencer_Intelligence_Agent.ipynb', 'fixed_voiGno_Restaurant_Agent_PraisonAI.ipynb']. Analyze \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m key components and structure. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> The repository contains several Jupyter Notebook files, each seemingly focused on different specialized agents. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Here's a breakdown of the key components and structure based on the file names: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">Fuel_Emission_Agent_Intelligence_Agent.ipynb</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>This notebook likely focuses on analyzing and possibly predicting fuel emissions. It might include data <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>analysis, machine learning models, or simulations to assess environmental impacts or optimize fuel usage. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">fixed_Cognitive_Assistant_Agent_Team.ipynb</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>This file suggests a cognitive assistant, possibly designed to aid in decision-making or provide <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>intelligent recommendations. The \"Team\" aspect might indicate collaborative features or multi-agent <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>interactions. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">fixed_Crypto_Research_Agent_Intelligence_Agent.ipynb</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>This notebook is probably dedicated to cryptocurrency research. It might include data analysis, market <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>trend predictions, or sentiment analysis related to cryptocurrencies. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 4 </span><span style=\"font-weight: bold\">fixed_E_commerce_Shopping_Assistant.ipynb</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>This agent likely serves as a shopping assistant, possibly providing product recommendations, price <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>comparisons, or personalized shopping experiences for e-commerce platforms. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 5 </span><span style=\"font-weight: bold\">fixed_Home_Buying_Real_Estate_Agent.ipynb</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>This notebook appears to be focused on the real estate market, potentially offering insights into <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>property values, market trends, or personalized home-buying recommendations. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 6 </span><span style=\"font-weight: bold\">fixed_YouTube_Influencer_Intelligence_Agent.ipynb</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>This file likely deals with analyzing YouTube influencers, possibly providing insights into influencer <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>performance, audience engagement, or content optimization strategies. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 7 </span><span style=\"font-weight: bold\">fixed_voiGno_Restaurant_Agent_PraisonAI.ipynb</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>This agent seems to be related to the restaurant industry, possibly offering services like menu <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>optimization, customer feedback analysis, or operational efficiency improvements. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\">Overall Structure and Insights</span>: <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>The repository appears to focus on developing intelligent agents across various domains, each tailored to <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>specific industry needs. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>The use of Jupyter Notebooks suggests an emphasis on data analysis, visualization, and possibly machine <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>learning or AI model development. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>The prefix \"fixed_\" in the file names might indicate that these are refined or updated versions of previous <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>iterations. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span>The diversity of domains covered (environmental, cognitive, financial, e-commerce, real estate, social <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>media, and hospitality) suggests a broad application of AI and data-driven insights. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> These notebooks likely contain a mix of data preprocessing, model training, and evaluation, along with <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> visualizations to support the findings and recommendations of each agent. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m The repository contains several Jupyter Notebook files, each seemingly focused on different specialized agents. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Here's a breakdown of the key components and structure based on the file names: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0m\u001b[1mFuel_Emission_Agent_Intelligence_Agent.ipynb\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mThis notebook likely focuses on analyzing and possibly predicting fuel emissions. It might include data \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0manalysis, machine learning models, or simulations to assess environmental impacts or optimize fuel usage. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mfixed_Cognitive_Assistant_Agent_Team.ipynb\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mThis file suggests a cognitive assistant, possibly designed to aid in decision-making or provide \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mintelligent recommendations. The \"Team\" aspect might indicate collaborative features or multi-agent \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0minteractions. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0m\u001b[1mfixed_Crypto_Research_Agent_Intelligence_Agent.ipynb\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mThis notebook is probably dedicated to cryptocurrency research. It might include data analysis, market \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mtrend predictions, or sentiment analysis related to cryptocurrencies. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 4 \u001b[0m\u001b[1mfixed_E_commerce_Shopping_Assistant.ipynb\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mThis agent likely serves as a shopping assistant, possibly providing product recommendations, price \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mcomparisons, or personalized shopping experiences for e-commerce platforms. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 5 \u001b[0m\u001b[1mfixed_Home_Buying_Real_Estate_Agent.ipynb\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mThis notebook appears to be focused on the real estate market, potentially offering insights into \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mproperty values, market trends, or personalized home-buying recommendations. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 6 \u001b[0m\u001b[1mfixed_YouTube_Influencer_Intelligence_Agent.ipynb\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mThis file likely deals with analyzing YouTube influencers, possibly providing insights into influencer \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0mperformance, audience engagement, or content optimization strategies. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 7 \u001b[0m\u001b[1mfixed_voiGno_Restaurant_Agent_PraisonAI.ipynb\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mThis agent seems to be related to the restaurant industry, possibly offering services like menu \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m \u001b[0moptimization, customer feedback analysis, or operational efficiency improvements. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mOverall Structure and Insights\u001b[0m: \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0mThe repository appears to focus on developing intelligent agents across various domains, each tailored to \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mspecific industry needs. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0mThe use of Jupyter Notebooks suggests an emphasis on data analysis, visualization, and possibly machine \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mlearning or AI model development. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0mThe prefix \"fixed_\" in the file names might indicate that these are refined or updated versions of previous \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0miterations. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0mThe diversity of domains covered (environmental, cognitive, financial, e-commerce, real estate, social \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mmedia, and hospitality) suggests a broad application of AI and data-driven insights. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m These notebooks likely contain a mix of data preprocessing, model training, and evaluation, along with \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m visualizations to support the findings and recommendations of each agent. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\n",
|
||||
"🧠 Agent Insight:\n",
|
||||
" The repository contains several Jupyter Notebook files, each seemingly focused on different specialized agents. Here's a breakdown of the key components and structure based on the file names:\n",
|
||||
"\n",
|
||||
"1. **Fuel_Emission_Agent_Intelligence_Agent.ipynb**:\n",
|
||||
" - This notebook likely focuses on analyzing and possibly predicting fuel emissions. It might include data analysis, machine learning models, or simulations to assess environmental impacts or optimize fuel usage.\n",
|
||||
"\n",
|
||||
"2. **fixed_Cognitive_Assistant_Agent_Team.ipynb**:\n",
|
||||
" - This file suggests a cognitive assistant, possibly designed to aid in decision-making or provide intelligent recommendations. The \"Team\" aspect might indicate collaborative features or multi-agent interactions.\n",
|
||||
"\n",
|
||||
"3. **fixed_Crypto_Research_Agent_Intelligence_Agent.ipynb**:\n",
|
||||
" - This notebook is probably dedicated to cryptocurrency research. It might include data analysis, market trend predictions, or sentiment analysis related to cryptocurrencies.\n",
|
||||
"\n",
|
||||
"4. **fixed_E_commerce_Shopping_Assistant.ipynb**:\n",
|
||||
" - This agent likely serves as a shopping assistant, possibly providing product recommendations, price comparisons, or personalized shopping experiences for e-commerce platforms.\n",
|
||||
"\n",
|
||||
"5. **fixed_Home_Buying_Real_Estate_Agent.ipynb**:\n",
|
||||
" - This notebook appears to be focused on the real estate market, potentially offering insights into property values, market trends, or personalized home-buying recommendations.\n",
|
||||
"\n",
|
||||
"6. **fixed_YouTube_Influencer_Intelligence_Agent.ipynb**:\n",
|
||||
" - This file likely deals with analyzing YouTube influencers, possibly providing insights into influencer performance, audience engagement, or content optimization strategies.\n",
|
||||
"\n",
|
||||
"7. **fixed_voiGno_Restaurant_Agent_PraisonAI.ipynb**:\n",
|
||||
" - This agent seems to be related to the restaurant industry, possibly offering services like menu optimization, customer feedback analysis, or operational efficiency improvements.\n",
|
||||
"\n",
|
||||
"**Overall Structure and Insights**:\n",
|
||||
"- The repository appears to focus on developing intelligent agents across various domains, each tailored to specific industry needs.\n",
|
||||
"- The use of Jupyter Notebooks suggests an emphasis on data analysis, visualization, and possibly machine learning or AI model development.\n",
|
||||
"- The prefix \"fixed_\" in the file names might indicate that these are refined or updated versions of previous iterations.\n",
|
||||
"- The diversity of domains covered (environmental, cognitive, financial, e-commerce, real estate, social media, and hospitality) suggests a broad application of AI and data-driven insights.\n",
|
||||
"\n",
|
||||
"These notebooks likely contain a mix of data preprocessing, model training, and evaluation, along with visualizations to support the findings and recommendations of each agent.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"repo = input(\"🔗 Enter GitHub repository URL: \")\n",
|
||||
"print(\"\\n🧠 Agent Insight:\\n\", ask_agent(repo))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python",
|
||||
"version": "3.11"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
+743
@@ -0,0 +1,743 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "l3kzG83yPRHX"
|
||||
},
|
||||
"source": [
|
||||
"# AI Code Generation System: Multi-Agent Programming Assistant with PraisonAI"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "BozAlx2dPS3Y"
|
||||
},
|
||||
"source": [
|
||||
"An intelligent code generation system that creates specialized programming code from natural language descriptions. Features multiple AI agents for code generation, debugging, validation, and updates. Built with PraisonAI framework, it demonstrates advanced multi-agent collaboration for software development workflows. Perfect for rapid prototyping, educational content creation, and automated code generation across various programming domains."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "I9UqNin7PanL"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/intelligent_programming_agent.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "trQTNYiHO1mi",
|
||||
"outputId": "913e1419-c8de-49e4-d2ef-e02c0f0bea2c"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"📦 Dependencies installed successfully!\n",
|
||||
"🎬 Manim Code Generator ready!\n",
|
||||
"🤖 Using PraisonAI Multi-Agent Framework\n",
|
||||
"💡 Note: This generates Manim code only (no video rendering)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# @title **📦 Install Dependencies**\n",
|
||||
"\n",
|
||||
"# Install only essential packages\n",
|
||||
"!pip install praisonaiagents -q\n",
|
||||
"!pip install openai -q\n",
|
||||
"!pip install python-dotenv -q\n",
|
||||
"\n",
|
||||
"# Basic imports\n",
|
||||
"import os\n",
|
||||
"import json\n",
|
||||
"import tempfile\n",
|
||||
"import shutil\n",
|
||||
"import logging\n",
|
||||
"import subprocess\n",
|
||||
"import re\n",
|
||||
"from pathlib import Path\n",
|
||||
"from typing import Dict, List, Optional, Any, Tuple\n",
|
||||
"from datetime import datetime\n",
|
||||
"import getpass\n",
|
||||
"\n",
|
||||
"print(\"📦 Dependencies installed successfully!\")\n",
|
||||
"print(\"🎬 Manim Code Generator ready!\")\n",
|
||||
"print(\"🤖 Using PraisonAI Multi-Agent Framework\")\n",
|
||||
"print(\"💡 Note: This generates Manim code only (no video rendering)\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "bL_IuGP4O7Ua",
|
||||
"outputId": "24095118-2a75-4814-af3c-13b2245331b1"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"🔑 OpenAI API Key Setup\n",
|
||||
"Enter your OpenAI API key:\n",
|
||||
"OpenAI API Key: ··········\n",
|
||||
"✅ API key configured!\n",
|
||||
"🚀 Ready to generate Manim code!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# @title ** Set OpenAI API Key**\n",
|
||||
"\n",
|
||||
"# Set up API key\n",
|
||||
"print(\"🔑 OpenAI API Key Setup\")\n",
|
||||
"print(\"Enter your OpenAI API key:\")\n",
|
||||
"\n",
|
||||
"api_key = getpass.getpass(\"OpenAI API Key: \")\n",
|
||||
"\n",
|
||||
"if not api_key or api_key.strip() == \"\":\n",
|
||||
" print(\"⚠️ No API key provided. Using demo mode with mock responses.\")\n",
|
||||
" api_key = \"demo-key\"\n",
|
||||
"\n",
|
||||
"# Set environment variable\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = api_key\n",
|
||||
"\n",
|
||||
"print(\"✅ API key configured!\")\n",
|
||||
"print(\"🚀 Ready to generate Manim code!\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "fe0hQYhRO_VJ",
|
||||
"outputId": "5ed3217a-d505-4795-c94b-c0e96d04f7e4"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"✅ Custom Manim code tools initialized!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# @title **️ Custom Code Tools**\n",
|
||||
"\n",
|
||||
"class ManimCodeTools:\n",
|
||||
" \"\"\"Custom tools for Manim code generation and validation\"\"\"\n",
|
||||
"\n",
|
||||
" @staticmethod\n",
|
||||
" def clean_manim_code(code: str) -> str:\n",
|
||||
" \"\"\"Clean and format Manim code\"\"\"\n",
|
||||
" # Remove markdown code blocks if present\n",
|
||||
" if \"```python\" in code:\n",
|
||||
" code = code.split(\"```python\")[1]\n",
|
||||
" if \"```\" in code:\n",
|
||||
" code = code.split(\"```\")[0]\n",
|
||||
"\n",
|
||||
" # Clean up extra whitespace\n",
|
||||
" code = code.strip()\n",
|
||||
" return code\n",
|
||||
"\n",
|
||||
" @staticmethod\n",
|
||||
" def extract_scene_class_name(code: str) -> str:\n",
|
||||
" \"\"\"Extract scene class name from Manim code\"\"\"\n",
|
||||
" # Look for class definitions that inherit from Scene\n",
|
||||
" pattern = r'class\\s+(\\w+)\\s*\\(.*Scene.*\\):'\n",
|
||||
" match = re.search(pattern, code)\n",
|
||||
" if match:\n",
|
||||
" return match.group(1)\n",
|
||||
"\n",
|
||||
" # Fallback: look for any class definition\n",
|
||||
" pattern = r'class\\s+(\\w+)\\s*:'\n",
|
||||
" match = re.search(pattern, code)\n",
|
||||
" if match:\n",
|
||||
" return match.group(1)\n",
|
||||
"\n",
|
||||
" return \"\"\n",
|
||||
"\n",
|
||||
" @staticmethod\n",
|
||||
" def validate_python_syntax(code: str) -> Tuple[bool, str]:\n",
|
||||
" \"\"\"Validate Python syntax without executing\"\"\"\n",
|
||||
" try:\n",
|
||||
" compile(code, '<string>', 'exec')\n",
|
||||
" return True, \"Syntax is valid\"\n",
|
||||
" except SyntaxError as e:\n",
|
||||
" return False, f\"Syntax error: {str(e)}\"\n",
|
||||
" except Exception as e:\n",
|
||||
" return False, f\"Validation error: {str(e)}\"\n",
|
||||
"\n",
|
||||
" @staticmethod\n",
|
||||
" def check_manim_imports(code: str) -> Tuple[bool, str]:\n",
|
||||
" \"\"\"Check if Manim imports are present\"\"\"\n",
|
||||
" required_imports = ['from manim import', 'import manim']\n",
|
||||
" found_imports = []\n",
|
||||
"\n",
|
||||
" for import_line in required_imports:\n",
|
||||
" if import_line in code:\n",
|
||||
" found_imports.append(import_line)\n",
|
||||
"\n",
|
||||
" if found_imports:\n",
|
||||
" return True, f\"Found Manim imports: {', '.join(found_imports)}\"\n",
|
||||
" else:\n",
|
||||
" return False, \"No Manim imports found\"\n",
|
||||
"\n",
|
||||
" @staticmethod\n",
|
||||
" def check_scene_class(code: str) -> Tuple[bool, str]:\n",
|
||||
" \"\"\"Check if Scene class is properly defined\"\"\"\n",
|
||||
" scene_pattern = r'class\\s+\\w+\\s*\\(.*Scene.*\\):'\n",
|
||||
" if re.search(scene_pattern, code):\n",
|
||||
" return True, \"Scene class found\"\n",
|
||||
" else:\n",
|
||||
" return False, \"No Scene class found\"\n",
|
||||
"\n",
|
||||
" @staticmethod\n",
|
||||
" def generate_code_summary(code: str) -> Dict[str, Any]:\n",
|
||||
" \"\"\"Generate a summary of the code\"\"\"\n",
|
||||
" scene_name = ManimCodeTools.extract_scene_class_name(code)\n",
|
||||
" syntax_valid, syntax_msg = ManimCodeTools.validate_python_syntax(code)\n",
|
||||
" imports_ok, imports_msg = ManimCodeTools.check_manim_imports(code)\n",
|
||||
" scene_ok, scene_msg = ManimCodeTools.check_scene_class(code)\n",
|
||||
"\n",
|
||||
" return {\n",
|
||||
" \"scene_name\": scene_name,\n",
|
||||
" \"syntax_valid\": syntax_valid,\n",
|
||||
" \"syntax_message\": syntax_msg,\n",
|
||||
" \"imports_ok\": imports_ok,\n",
|
||||
" \"imports_message\": imports_msg,\n",
|
||||
" \"scene_ok\": scene_ok,\n",
|
||||
" \"scene_message\": scene_msg,\n",
|
||||
" \"code_length\": len(code),\n",
|
||||
" \"lines\": len(code.split('\\n'))\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
"# Initialize tools\n",
|
||||
"manim_tools = ManimCodeTools()\n",
|
||||
"print(\"✅ Custom Manim code tools initialized!\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000,
|
||||
"referenced_widgets": [
|
||||
"5a67a4a41d0d48d3870a3c1eb967493b",
|
||||
"f748833f06464214a9d4e7cf0cec7a68"
|
||||
]
|
||||
},
|
||||
"id": "zsrklVrjPCFU",
|
||||
"outputId": "6327299f-416a-4f68-8b13-a9813e6528ad"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" AI Manim Code Generator Ready!\n",
|
||||
"============================================================\n",
|
||||
"🚀 Demo: Generating Manim code...\n",
|
||||
"🎬 Generating Manim code for: 'Create an animation showing a circle moving in a sine wave pattern'\n",
|
||||
"============================================================\n",
|
||||
"�� Step 1: Generating Manim code...\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Manim Code Generator</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Complete Manim Animation Specialist</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span> <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
|
||||
"<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mManim Code Generator\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mComplete Manim Animation Specialist\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n",
|
||||
"\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "5a67a4a41d0d48d3870a3c1eb967493b",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
||||
],
|
||||
"text/plain": []
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 7.6s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 7.6s\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> You need to do the following task: Generate high-quality Manim code for this animation request: Create an <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> animation showing a circle moving in a sine wave pattern <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> Requirements:</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> - Create a class that inherits from Scene</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> - Include proper imports (from manim import *)</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> - Use descriptive class names</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> - Include a construct method with self.play() calls</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> - Add comments for clarity</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> - Ensure code is complete and runnable</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> - Follow Manim best practices</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> - Handle mathematical concepts properly</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> - Use appropriate animation timing</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> .</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Expected Output: Complete the task successfully. Please provide only the final result of your work. Do not add <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> any conversation or extra explanation. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m You need to do the following task: Generate high-quality Manim code for this animation request: Create an \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m animation showing a circle moving in a sine wave pattern \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m Requirements:\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m - Create a class that inherits from Scene\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m - Include proper imports (from manim import *)\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m - Use descriptive class names\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m - Include a construct method with self.play() calls\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m - Add comments for clarity\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m - Ensure code is complete and runnable\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m - Follow Manim best practices\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m - Handle mathematical concepts properly\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m - Use appropriate animation timing\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m .\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Expected Output: Complete the task successfully. Please provide only the final result of your work. Do not add \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m any conversation or extra explanation. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">from</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> manim </span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">import</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> </span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">*</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #66d9ef; text-decoration-color: #66d9ef; background-color: #272822\">class</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> </span><span style=\"color: #a6e22e; text-decoration-color: #a6e22e; background-color: #272822\">CircleSineWave</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">(Scene):</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> </span><span style=\"color: #66d9ef; text-decoration-color: #66d9ef; background-color: #272822\">def</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> </span><span style=\"color: #a6e22e; text-decoration-color: #a6e22e; background-color: #272822\">construct</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">(self):</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> </span><span style=\"color: #959077; text-decoration-color: #959077; background-color: #272822\"># Create a circle</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> circle </span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">=</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> Circle(radius</span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">=</span><span style=\"color: #ae81ff; text-decoration-color: #ae81ff; background-color: #272822\">0.2</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">, color</span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">=</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">BLUE)</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> </span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> </span><span style=\"color: #959077; text-decoration-color: #959077; background-color: #272822\"># Define the sine wave path</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> sine_wave_path </span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">=</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> ParametricFunction(</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> </span><span style=\"color: #66d9ef; text-decoration-color: #66d9ef; background-color: #272822\">lambda</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> t: np</span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">.</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">array([t, np</span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">.</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">sin(t), </span><span style=\"color: #ae81ff; text-decoration-color: #ae81ff; background-color: #272822\">0</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">]),</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> t_range</span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">=</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">np</span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">.</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">array([</span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">-</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">PI, PI, </span><span style=\"color: #ae81ff; text-decoration-color: #ae81ff; background-color: #272822\">0.01</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">]),</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> color</span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">=</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">YELLOW</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> )</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> </span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> </span><span style=\"color: #959077; text-decoration-color: #959077; background-color: #272822\"># Add the sine wave path to the scene</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> self</span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">.</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">add(sine_wave_path)</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> </span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> </span><span style=\"color: #959077; text-decoration-color: #959077; background-color: #272822\"># Animate the circle moving along the sine wave path</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> self</span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">.</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">play(</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> MoveAlongPath(circle, sine_wave_path, rate_func</span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">=</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">linear),</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> run_time</span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">=</span><span style=\"color: #ae81ff; text-decoration-color: #ae81ff; background-color: #272822\">4</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> )</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> </span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> </span><span style=\"color: #959077; text-decoration-color: #959077; background-color: #272822\"># Hold the final position for a moment</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> self</span><span style=\"color: #ff4689; text-decoration-color: #ff4689; background-color: #272822\">.</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">wait(</span><span style=\"color: #ae81ff; text-decoration-color: #ae81ff; background-color: #272822\">1</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">)</span><span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"background-color: #272822\"> </span> <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34mfrom\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mmanim\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34mimport\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m*\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;102;217;239;48;2;39;40;34mclass\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;166;226;46;48;2;39;40;34mCircleSineWave\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mScene\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m:\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;102;217;239;48;2;39;40;34mdef\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;166;226;46;48;2;39;40;34mconstruct\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mself\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m:\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;149;144;119;48;2;39;40;34m# Create a circle\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mcircle\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m=\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mCircle\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mradius\u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m=\u001b[0m\u001b[38;2;174;129;255;48;2;39;40;34m0.2\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m,\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mcolor\u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m=\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mBLUE\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;149;144;119;48;2;39;40;34m# Define the sine wave path\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34msine_wave_path\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m=\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mParametricFunction\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;102;217;239;48;2;39;40;34mlambda\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mt\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m:\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mnp\u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m.\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34marray\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m[\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mt\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m,\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mnp\u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m.\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34msin\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mt\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m,\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;174;129;255;48;2;39;40;34m0\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m]\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m,\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mt_range\u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m=\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mnp\u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m.\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34marray\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m[\u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m-\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mPI\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m,\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mPI\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m,\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;174;129;255;48;2;39;40;34m0.01\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m]\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m,\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mcolor\u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m=\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mYELLOW\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;149;144;119;48;2;39;40;34m# Add the sine wave path to the scene\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mself\u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m.\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34madd\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34msine_wave_path\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;149;144;119;48;2;39;40;34m# Animate the circle moving along the sine wave path\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mself\u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m.\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mplay\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mMoveAlongPath\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mcircle\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m,\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34msine_wave_path\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m,\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mrate_func\u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m=\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mlinear\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m,\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mrun_time\u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m=\u001b[0m\u001b[38;2;174;129;255;48;2;39;40;34m4\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;149;144;119;48;2;39;40;34m# Hold the final position for a moment\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mself\u001b[0m\u001b[38;2;255;70;137;48;2;39;40;34m.\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mwait\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;174;129;255;48;2;39;40;34m1\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[48;2;39;40;34m \u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"✅ Generated code: from manim import *\n",
|
||||
"\n",
|
||||
"class CircleSineWave(Scene):\n",
|
||||
" def construct(self):\n",
|
||||
" # Create a circle\n",
|
||||
" circle = Circle(radius=0.2, color=BLUE)\n",
|
||||
" \n",
|
||||
" # Define the sine wave path\n",
|
||||
" ...\n",
|
||||
" Step 2: Validating generated code...\n",
|
||||
"📝 Code Summary:\n",
|
||||
" - Scene Name: CircleSineWave\n",
|
||||
" - Syntax Valid: True\n",
|
||||
" - Manim Imports: True\n",
|
||||
" - Scene Class: True\n",
|
||||
" - Code Length: 727 characters\n",
|
||||
" - Lines: 25\n",
|
||||
"\n",
|
||||
" Generated Code:\n",
|
||||
"========================================\n",
|
||||
"from manim import *\n",
|
||||
"\n",
|
||||
"class CircleSineWave(Scene):\n",
|
||||
" def construct(self):\n",
|
||||
" # Create a circle\n",
|
||||
" circle = Circle(radius=0.2, color=BLUE)\n",
|
||||
" \n",
|
||||
" # Define the sine wave path\n",
|
||||
" sine_wave_path = ParametricFunction(\n",
|
||||
" lambda t: np.array([t, np.sin(t), 0]),\n",
|
||||
" t_range=np.array([-PI, PI, 0.01]),\n",
|
||||
" color=YELLOW\n",
|
||||
" )\n",
|
||||
" \n",
|
||||
" # Add the sine wave path to the scene\n",
|
||||
" self.add(sine_wave_path)\n",
|
||||
" \n",
|
||||
" # Animate the circle moving along the sine wave path\n",
|
||||
" self.play(\n",
|
||||
" MoveAlongPath(circle, sine_wave_path, rate_func=linear),\n",
|
||||
" run_time=4\n",
|
||||
" )\n",
|
||||
" \n",
|
||||
" # Hold the final position for a moment\n",
|
||||
" self.wait(1)\n",
|
||||
"========================================\n",
|
||||
"\n",
|
||||
"✅ Code generation complete!\n",
|
||||
"🎬 Scene name: CircleSineWave\n",
|
||||
"📊 Code quality: 25 lines, 727 characters\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# @title **🚀 Execute Code Generation (FINAL WORKING VERSION)**\n",
|
||||
"\n",
|
||||
"# Import PraisonAI after setting API key\n",
|
||||
"from praisonaiagents import Agent, Task, PraisonAIAgents\n",
|
||||
"\n",
|
||||
"def generate_manim_code(query: str):\n",
|
||||
" \"\"\"Generate Manim code from user query using PraisonAI\"\"\"\n",
|
||||
" print(f\"🎬 Generating Manim code for: '{query}'\")\n",
|
||||
" print(\"=\" * 60)\n",
|
||||
"\n",
|
||||
" # Create agents\n",
|
||||
" manim_agent = Agent(\n",
|
||||
" name=\"Manim Code Generator\",\n",
|
||||
" role=\"Complete Manim Animation Specialist\",\n",
|
||||
" goal=\"Generate high-quality, working Manim code from natural language descriptions\",\n",
|
||||
" backstory=\"Expert Manim developer with deep knowledge of mathematical animations, code generation, debugging, and educational content creation\",\n",
|
||||
" verbose=True,\n",
|
||||
" allow_delegation=False,\n",
|
||||
" tools=[]\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" debugger_agent = Agent(\n",
|
||||
" name=\"Code Debugger\",\n",
|
||||
" role=\"Manim Code Debugger\",\n",
|
||||
" goal=\"Fix errors in Manim code and ensure successful execution\",\n",
|
||||
" backstory=\"Expert in debugging Manim animations and resolving technical issues in mathematical visualization code\",\n",
|
||||
" verbose=True,\n",
|
||||
" allow_delegation=False,\n",
|
||||
" tools=[]\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" # Create tasks\n",
|
||||
" code_generation_task = Task(\n",
|
||||
" description=f\"\"\"\n",
|
||||
" Generate high-quality Manim code for this animation request: {query}\n",
|
||||
"\n",
|
||||
" Requirements:\n",
|
||||
" - Create a class that inherits from Scene\n",
|
||||
" - Include proper imports (from manim import *)\n",
|
||||
" - Use descriptive class names\n",
|
||||
" - Include a construct method with self.play() calls\n",
|
||||
" - Add comments for clarity\n",
|
||||
" - Ensure code is complete and runnable\n",
|
||||
" - Follow Manim best practices\n",
|
||||
" - Handle mathematical concepts properly\n",
|
||||
" - Use appropriate animation timing\n",
|
||||
" \"\"\",\n",
|
||||
" agent=manim_agent\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" # Step 1: Generate code\n",
|
||||
" print(\"�� Step 1: Generating Manim code...\")\n",
|
||||
"\n",
|
||||
" # Use PraisonAIAgents to execute the task\n",
|
||||
" agents_system = PraisonAIAgents(\n",
|
||||
" agents=[manim_agent],\n",
|
||||
" tasks=[code_generation_task],\n",
|
||||
" verbose=True,\n",
|
||||
" process=\"sequential\"\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" result = agents_system.start()\n",
|
||||
" manim_code = manim_tools.clean_manim_code(result)\n",
|
||||
" print(f\"✅ Generated code: {manim_code[:200]}...\")\n",
|
||||
"\n",
|
||||
" # Step 2: Validate code\n",
|
||||
" print(\" Step 2: Validating generated code...\")\n",
|
||||
" code_summary = manim_tools.generate_code_summary(manim_code)\n",
|
||||
"\n",
|
||||
" print(f\"📝 Code Summary:\")\n",
|
||||
" print(f\" - Scene Name: {code_summary['scene_name']}\")\n",
|
||||
" print(f\" - Syntax Valid: {code_summary['syntax_valid']}\")\n",
|
||||
" print(f\" - Manim Imports: {code_summary['imports_ok']}\")\n",
|
||||
" print(f\" - Scene Class: {code_summary['scene_ok']}\")\n",
|
||||
" print(f\" - Code Length: {code_summary['code_length']} characters\")\n",
|
||||
" print(f\" - Lines: {code_summary['lines']}\")\n",
|
||||
"\n",
|
||||
" # Step 3: Debug if needed\n",
|
||||
" if not code_summary['syntax_valid'] or not code_summary['imports_ok'] or not code_summary['scene_ok']:\n",
|
||||
" print(\"🐛 Step 3: Fixing code issues...\")\n",
|
||||
" issues = []\n",
|
||||
" if not code_summary['syntax_valid']:\n",
|
||||
" issues.append(code_summary['syntax_message'])\n",
|
||||
" if not code_summary['imports_ok']:\n",
|
||||
" issues.append(code_summary['imports_message'])\n",
|
||||
" if not code_summary['scene_ok']:\n",
|
||||
" issues.append(code_summary['scene_message'])\n",
|
||||
"\n",
|
||||
" error_msg = \"; \".join(issues)\n",
|
||||
"\n",
|
||||
" debug_task = Task(\n",
|
||||
" description=f\"\"\"\n",
|
||||
" Fix these issues in the Manim code:\n",
|
||||
"\n",
|
||||
" Code: {manim_code}\n",
|
||||
" Errors: {error_msg}\n",
|
||||
"\n",
|
||||
" Provide corrected Manim code that:\n",
|
||||
" - Fixes all syntax errors\n",
|
||||
" - Includes proper Manim imports\n",
|
||||
" - Has a valid Scene class\n",
|
||||
" - Maintains the original animation intent\n",
|
||||
" - Is complete and runnable\n",
|
||||
" \"\"\",\n",
|
||||
" agent=debugger_agent\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" debug_system = PraisonAIAgents(\n",
|
||||
" agents=[debugger_agent],\n",
|
||||
" tasks=[debug_task],\n",
|
||||
" verbose=True,\n",
|
||||
" process=\"sequential\"\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" debug_result = debug_system.start()\n",
|
||||
" manim_code = manim_tools.clean_manim_code(debug_result)\n",
|
||||
"\n",
|
||||
" # Re-validate\n",
|
||||
" code_summary = manim_tools.generate_code_summary(manim_code)\n",
|
||||
" print(f\"✅ Debug completed! Code is now valid.\")\n",
|
||||
"\n",
|
||||
" return {\n",
|
||||
" \"manim_code\": manim_code,\n",
|
||||
" \"code_summary\": code_summary,\n",
|
||||
" \"scene_name\": code_summary['scene_name']\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
"def update_manim_code(query: str, existing_code: str):\n",
|
||||
" \"\"\"Update existing Manim code with new requirements\"\"\"\n",
|
||||
" print(f\" Updating Manim code: '{query}'\")\n",
|
||||
" print(\"=\" * 60)\n",
|
||||
"\n",
|
||||
" # Create updater agent\n",
|
||||
" updater_agent = Agent(\n",
|
||||
" name=\"Code Updater\",\n",
|
||||
" role=\"Manim Code Updater\",\n",
|
||||
" goal=\"Modify existing Manim animations based on new requirements\",\n",
|
||||
" backstory=\"Specialist in updating and enhancing existing Manim animations while maintaining code quality and functionality\",\n",
|
||||
" verbose=True,\n",
|
||||
" allow_delegation=False,\n",
|
||||
" tools=[]\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" # Create update task\n",
|
||||
" update_task = Task(\n",
|
||||
" description=f\"\"\"\n",
|
||||
" Update this Manim code based on the request:\n",
|
||||
"\n",
|
||||
" Original Code: {existing_code}\n",
|
||||
" Update Request: {query}\n",
|
||||
"\n",
|
||||
" Provide updated Manim code that:\n",
|
||||
" - Maintains the original structure\n",
|
||||
" - Applies the requested changes\n",
|
||||
" - Keeps the same Scene class\n",
|
||||
" - Ensures code remains runnable\n",
|
||||
" - Preserves existing functionality\n",
|
||||
" \"\"\",\n",
|
||||
" agent=updater_agent\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" # Execute update\n",
|
||||
" print(\"💻 Updating Manim code...\")\n",
|
||||
"\n",
|
||||
" update_system = PraisonAIAgents(\n",
|
||||
" agents=[updater_agent],\n",
|
||||
" tasks=[update_task],\n",
|
||||
" verbose=True,\n",
|
||||
" process=\"sequential\"\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" updated_result = update_system.start()\n",
|
||||
" updated_code = manim_tools.clean_manim_code(updated_result)\n",
|
||||
"\n",
|
||||
" # Validate updated code\n",
|
||||
" print(\" Validating updated code...\")\n",
|
||||
" code_summary = manim_tools.generate_code_summary(updated_code)\n",
|
||||
"\n",
|
||||
" print(f\"📝 Updated Code Summary:\")\n",
|
||||
" print(f\" - Scene Name: {code_summary['scene_name']}\")\n",
|
||||
" print(f\" - Syntax Valid: {code_summary['syntax_valid']}\")\n",
|
||||
" print(f\" - Manim Imports: {code_summary['imports_ok']}\")\n",
|
||||
" print(f\" - Scene Class: {code_summary['scene_ok']}\")\n",
|
||||
"\n",
|
||||
" return {\n",
|
||||
" \"manim_code\": updated_code,\n",
|
||||
" \"code_summary\": code_summary,\n",
|
||||
" \"scene_name\": code_summary['scene_name']\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
"# Demo execution\n",
|
||||
"print(\" AI Manim Code Generator Ready!\")\n",
|
||||
"print(\"=\" * 60)\n",
|
||||
"\n",
|
||||
"# Example usage\n",
|
||||
"demo_query = \"Create an animation showing a circle moving in a sine wave pattern\"\n",
|
||||
"\n",
|
||||
"print(\"🚀 Demo: Generating Manim code...\")\n",
|
||||
"result = generate_manim_code(demo_query)\n",
|
||||
"\n",
|
||||
"print(\"\\n Generated Code:\")\n",
|
||||
"print(\"=\" * 40)\n",
|
||||
"print(result['manim_code'])\n",
|
||||
"print(\"=\" * 40)\n",
|
||||
"\n",
|
||||
"print(f\"\\n✅ Code generation complete!\")\n",
|
||||
"print(f\"🎬 Scene name: {result['scene_name']}\")\n",
|
||||
"print(f\"📊 Code quality: {result['code_summary']['lines']} lines, {result['code_summary']['code_length']} characters\")"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
@@ -0,0 +1,617 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6UeqOiyEijl3",
|
||||
"metadata": {
|
||||
"id": "6UeqOiyEijl3"
|
||||
},
|
||||
"source": [
|
||||
"**MistralTechAgent Lightweight Technical Assistant Using Mistral-7B-Instruct**"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "fYuCNTAtiuD3",
|
||||
"metadata": {
|
||||
"id": "fYuCNTAtiuD3"
|
||||
},
|
||||
"source": [
|
||||
"# 📄 Description:\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "hmbRZinQivwt",
|
||||
"metadata": {
|
||||
"id": "hmbRZinQivwt"
|
||||
},
|
||||
"source": [
|
||||
"MistralTechAgent is a simple and efficient AI assistant powered by the Mistral-7B-Instruct model. It is designed to provide accurate and easy-to-understand answers to technical questions. This agent uses a lightweight instruction-tuned model that runs smoothly on limited hardware while delivering high-quality responses. It also supports a customizable prompt format for structured queries."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "8qf1K5ycjU1r",
|
||||
"metadata": {
|
||||
"id": "8qf1K5ycjU1r"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/MistralTechAgent.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6oVNaoxbfsCP",
|
||||
"metadata": {
|
||||
"id": "6oVNaoxbfsCP"
|
||||
},
|
||||
"source": [
|
||||
"# SETUP: Install Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "af21b3c7",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "af21b3c7",
|
||||
"outputId": "3c900128-c9c1-4688-9f83-eaa2f9d2872e"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m67.0/67.0 MB\u001b[0m \u001b[31m13.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m363.4/363.4 MB\u001b[0m \u001b[31m5.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m13.8/13.8 MB\u001b[0m \u001b[31m78.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m24.6/24.6 MB\u001b[0m \u001b[31m70.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m883.7/883.7 kB\u001b[0m \u001b[31m57.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m664.8/664.8 MB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m211.5/211.5 MB\u001b[0m \u001b[31m5.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m56.3/56.3 MB\u001b[0m \u001b[31m13.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m127.9/127.9 MB\u001b[0m \u001b[31m8.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m207.5/207.5 MB\u001b[0m \u001b[31m6.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m21.1/21.1 MB\u001b[0m \u001b[31m88.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[?25h"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"!pip install -q transformers accelerate bitsandbytes"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "xjXmh8sQf476",
|
||||
"metadata": {
|
||||
"id": "xjXmh8sQf476"
|
||||
},
|
||||
"source": [
|
||||
"# SETUP: Hugging Face Token"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "8405c936",
|
||||
"metadata": {
|
||||
"id": "8405c936"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"os.environ[\"HF_TOKEN\"] = \"Enter your hugging api key\"\n",
|
||||
"os.environ[\"TRANSFORMERS_CACHE\"] = \"/content/hf_cache\" # Optional: Faster repeat runs\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "PfKEoHt3haFV",
|
||||
"metadata": {
|
||||
"id": "PfKEoHt3haFV"
|
||||
},
|
||||
"source": [
|
||||
"# YAML Prompt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "iNfVRVN_hJOn",
|
||||
"metadata": {
|
||||
"id": "iNfVRVN_hJOn"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"prompt_template = {\n",
|
||||
" \"role\": \"system\",\n",
|
||||
" \"content\": \"\"\"You are MistralTechAgent, an expert AI model assistant.\n",
|
||||
"You provide clear, concise, and technically correct answers.\"\"\",\n",
|
||||
" \"user_prompt\": \"{{ user_input }}\"\n",
|
||||
"}\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "LJAKEnSQf8gq",
|
||||
"metadata": {
|
||||
"id": "LJAKEnSQf8gq"
|
||||
},
|
||||
"source": [
|
||||
"# Load the Model (Fallback Safe)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d6a29e6a",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 545,
|
||||
"referenced_widgets": [
|
||||
"d84722f34b2847f29f5d72690fc4dac6",
|
||||
"cff68559d8ad46c190e7fe7f9403b9ee",
|
||||
"36abbc31f97041b6a7786ccc3214e6ff",
|
||||
"07d8084255bb465ab1eac565b9f8752f",
|
||||
"9deaf08dabdf4679a2a44bb76e9a90f7",
|
||||
"d07f025f4fe44db082fdf9ffc460ef63",
|
||||
"56f8056ba6964bef922831ba1d4b1c1f",
|
||||
"4f0419a3b0ab450aac64c1cd0ff12e5b",
|
||||
"fe77c87b1caa40ae841bd65f499fc83a",
|
||||
"83ba36ab3e5b455887f5d1fa5594ab78",
|
||||
"005ec31a3aed4dc9b6083a59a9868bbd",
|
||||
"15321d3071894e1c8948664d4e9066d2",
|
||||
"4b43fc4bbce14f98bf8fc253fa3ed054",
|
||||
"5d1662cd47b9477c84e77c29ce5ceeef",
|
||||
"0be07a3e7a094dd09672bea04df7bc80",
|
||||
"4b01774127fc4cf0b67baf13583ba8ed",
|
||||
"ef2f3f069ade44fa8000cfd560b618a9",
|
||||
"21b4e8cefdee4c5e8a2ba142d503fc87",
|
||||
"d426d2480422465eb8b625ebb584feb1",
|
||||
"8c4a7ec3cf8b462eaa5c9df357e216ee",
|
||||
"b80e114ea4e6475297b61f9693d231c1",
|
||||
"7c94da36524d402a81326a49a30cbbb5",
|
||||
"f005c11730fd499bb8f81aaf56c653d9",
|
||||
"c88dca8e5c164bd1a655adf7ced0e86a",
|
||||
"104aa6d812164a76be60cd7d39dd8cde",
|
||||
"f2729ef32b5d48bc8fb5a90f72d5ada2",
|
||||
"38fa0e67450e40ecaf0a35feacb26186",
|
||||
"0a74dde6fe1b45ef9c454dc23e4ccc9e",
|
||||
"238917a3bcc24b5fa68fe2c7edc9234b",
|
||||
"c6484ba3a50b4bec9086d8497b8c2692",
|
||||
"41f62ed77f0449c99362997b36a866ed",
|
||||
"ac54271d234f451eb793f7da28a8b802",
|
||||
"d1574df5392c4bb2a2a6dece0cc30679",
|
||||
"3a8da99cdb184f68b51d9706a867654b",
|
||||
"0e32a6e4428f4ef3afa9a487c1524f89",
|
||||
"b88cc5c73c734d15a4f8e073c8f3355a",
|
||||
"0dde4efd517d422cbc70f9379cf831f6",
|
||||
"4ffe478a8f654f008453fcb1e159b5c7",
|
||||
"053d6a80586e41ba88299b55570922ac",
|
||||
"f84040d89eb14f2ca2f3a88121c02182",
|
||||
"7536d676b440429cb157919373401266",
|
||||
"d2bada90caee4a37a6172ea6b046aec8",
|
||||
"0c84482a056a4dd89f0369fc0ce33a89",
|
||||
"648e7a00926845cd91344ce8cec2f8c7",
|
||||
"ffa6acc3f9ba41dc8a3b57716cd9e040",
|
||||
"a875f5aaea024290b2c347bdc9216b0c",
|
||||
"a60321d756a54737ba37053a43890129",
|
||||
"4aba7d0dd458437ab2d38d615fce9fc2",
|
||||
"7b2205697a1b41cdbe363c56345b8d01",
|
||||
"e2c0fd4a5436449cb3adca1f2204088e",
|
||||
"0e3fa8394aa749498e2898049fad0536",
|
||||
"fec704faaa5945b9917e730d2db8dd41",
|
||||
"6a117742183c4b7d8011df4b8a1a4a76",
|
||||
"60284b7ab8d845389419c7ac13d3cd3f",
|
||||
"2f36f3edcdd14cdbafa6217758ce99f6",
|
||||
"b9a0aeb8daf24fbd901a13cf728a7f31",
|
||||
"d769287686274598b83c6d4f3adf86eb",
|
||||
"6092a601fee7400187e85322d8c392d4",
|
||||
"3e397abc9c704ddb8b7bc8e0dcbee6bc",
|
||||
"ea3d99ef60e048fab9b9fb8c4c8c30b8",
|
||||
"8bb3bacb95b447a8b3c58edf8f61e787",
|
||||
"f586830e76dc42cd960b3f0b85103307",
|
||||
"6ad155c4df5d4f30a481e5041e45edd2",
|
||||
"31f8ebe87ae34e42ae0a78a6f9099191",
|
||||
"87bd98a893ca4a8eae7c8e1a12449b52",
|
||||
"3c3ccb3c9cbf4cacace8e24abb0a91ea",
|
||||
"1edd5f953fd04bc7b8d20b5ffceabb3c",
|
||||
"4df5649528874b209439c0c228dfabc0",
|
||||
"fd76767d90c14fa596ee606ce4ed04da",
|
||||
"259ecb69082644418e64abeb668ac24a",
|
||||
"31d294d5e1ec4b229cf6f84f4d5ae1b0",
|
||||
"24b5318baf2e4a45bda8fc93168b8a14",
|
||||
"503c7ac86036420ba69af49ac8b3b9c6",
|
||||
"13ad3a362cf341c1923abb4b3b1cd680",
|
||||
"1eb86202e6aa4fe39e8de1f0af54b794",
|
||||
"c24ffdfc0cd44a18b32803f93951029d",
|
||||
"99190548afb445b9bcc552ec16971a8f",
|
||||
"5b59bb8867b74cd28f342b5750232986",
|
||||
"cd1b87d6fdd94f92ad015506b2ba2c5e",
|
||||
"9a47c5378bce4a619409df36231ada16",
|
||||
"a9cac4aa7fc243238c17c3fa76d3fdfb",
|
||||
"d0da7d1ddbeb45deaeca52b1a8446ce1",
|
||||
"4c30d02b0b7947c4ad60bb822dac264e",
|
||||
"7a62762db5f84a6782663e36565f7cea",
|
||||
"64c0dff073c24b15b9a211112ccc2d47",
|
||||
"d6d5d90e878e4aa3a9d5c09d1ac8cd92",
|
||||
"c9fef86db14d4e8e9a127c1dd1edc729",
|
||||
"212f60982a33493497050c3d12c2363d",
|
||||
"05010758eed94155887ee707b3648ca0",
|
||||
"43f71ce03f874002afcabf2b64f946be",
|
||||
"5282b4041f064cbc890dcdaa3bbd6104",
|
||||
"07cb2d7c0c0f4bfd8ec7a3857a731390",
|
||||
"3a8973062f654466925d40e35fe5e063",
|
||||
"ded64c09b9b44838bc86e0e648c1c52b",
|
||||
"0eb43a6eb7aa484a9e07309479978586",
|
||||
"bbe209e71cad4c6d99a073bc900cf880",
|
||||
"8cb9fb71cbd64904bbad6c2c5f7d1ffe",
|
||||
"e8a986f524aa40339ab1f9fc5c92c0d4",
|
||||
"02a5f1682b5e4afb875f3542b4b26c74",
|
||||
"a7d0ecbe717f4427a99296ce2054e3fc",
|
||||
"ed0039d420fa47518e2bc4626a549c86",
|
||||
"0e14815b8e4d4fb2a39a97ca1e743a69",
|
||||
"022675075da14683b86d4e56d29e291e",
|
||||
"550b21f1e49e4cefa4a68d5b5e9bac01",
|
||||
"0b598550b4234654a8454d5f9c70b1e4",
|
||||
"880f0cf380fc4b499468db81b063a27e",
|
||||
"758ce764b5294a5ab0c97e439a172cb2",
|
||||
"410954f602984cd7bf39d2b12c5105c4",
|
||||
"8eab2746f98e4d57b148969f9af8b17f",
|
||||
"b622a9fb49fb43a6ae12004823b9b6e9",
|
||||
"53a30b0dc2034bf0aa28c853b9c0e270",
|
||||
"174544c42508419a9ea1dec2b5a48eec",
|
||||
"aaa735b347074f02b9b174724beabfce",
|
||||
"66fd00b5b01f46f1b362013d022ad437",
|
||||
"734c206c4bbb4cc08da0a061a0671baa",
|
||||
"5a185bcc5f814b1c829fa7a702a763a2",
|
||||
"c1928ef5ac3841a8a97c69b11ea8a6da",
|
||||
"2c318f2f01fc4271a890ec6b8238c9ad",
|
||||
"2d7ff096493b425eafb671f6d23de282",
|
||||
"493fd41d50bc4ed5aa33e58a50254edb",
|
||||
"5016341a1d0d4e59ad263aa81f81d5fd"
|
||||
]
|
||||
},
|
||||
"id": "d6a29e6a",
|
||||
"outputId": "9417ca92-9348-427d-e8e1-aabf3e716dbd"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/usr/local/lib/python3.11/dist-packages/transformers/utils/hub.py:111: FutureWarning: Using `TRANSFORMERS_CACHE` is deprecated and will be removed in v5 of Transformers. Use `HF_HOME` instead.\n",
|
||||
" warnings.warn(\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"🔄 Loading model: mistralai/Mistral-7B-Instruct-v0.1\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/usr/local/lib/python3.11/dist-packages/transformers/models/auto/tokenization_auto.py:902: FutureWarning: The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.\n",
|
||||
" warnings.warn(\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "d84722f34b2847f29f5d72690fc4dac6",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"tokenizer_config.json: 0%| | 0.00/2.10k [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "15321d3071894e1c8948664d4e9066d2",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"tokenizer.model: 0%| | 0.00/493k [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "f005c11730fd499bb8f81aaf56c653d9",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"tokenizer.json: 0%| | 0.00/1.80M [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "3a8da99cdb184f68b51d9706a867654b",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"special_tokens_map.json: 0%| | 0.00/414 [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/usr/local/lib/python3.11/dist-packages/transformers/models/auto/auto_factory.py:476: FutureWarning: The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.\n",
|
||||
" warnings.warn(\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "ffa6acc3f9ba41dc8a3b57716cd9e040",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"config.json: 0%| | 0.00/571 [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "b9a0aeb8daf24fbd901a13cf728a7f31",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"model.safetensors.index.json: 0%| | 0.00/25.1k [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "1edd5f953fd04bc7b8d20b5ffceabb3c",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Fetching 2 files: 0%| | 0/2 [00:00<?, ?it/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "5b59bb8867b74cd28f342b5750232986",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"model-00002-of-00002.safetensors: 0%| | 0.00/4.54G [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "05010758eed94155887ee707b3648ca0",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"model-00001-of-00002.safetensors: 0%| | 0.00/9.94G [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "a7d0ecbe717f4427a99296ce2054e3fc",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Loading checkpoint shards: 0%| | 0/2 [00:00<?, ?it/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "53a30b0dc2034bf0aa28c853b9c0e270",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"generation_config.json: 0%| | 0.00/116 [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"WARNING:accelerate.big_modeling:Some parameters are on the meta device because they were offloaded to the cpu.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"✅ Model loaded successfully!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from transformers import AutoTokenizer, AutoModelForCausalLM\n",
|
||||
"import torch\n",
|
||||
"\n",
|
||||
"model_name = \"mistralai/Mistral-7B-Instruct-v0.1\"\n",
|
||||
"\n",
|
||||
"try:\n",
|
||||
" print(f\"🔄 Loading model: {model_name}\")\n",
|
||||
" tokenizer = AutoTokenizer.from_pretrained(\n",
|
||||
" model_name, use_auth_token=os.environ[\"HF_TOKEN\"], trust_remote_code=True\n",
|
||||
" )\n",
|
||||
" model = AutoModelForCausalLM.from_pretrained(\n",
|
||||
" model_name,\n",
|
||||
" use_auth_token=os.environ[\"HF_TOKEN\"],\n",
|
||||
" trust_remote_code=True,\n",
|
||||
" device_map=\"auto\",\n",
|
||||
" torch_dtype=torch.float16\n",
|
||||
" )\n",
|
||||
" model.eval()\n",
|
||||
" print(\"✅ Model loaded successfully!\")\n",
|
||||
"\n",
|
||||
"except Exception as e:\n",
|
||||
" print(f\"❌ Failed to load {model_name}\\nError: {e}\")\n",
|
||||
" model_name = \"distilgpt2\"\n",
|
||||
" tokenizer = AutoTokenizer.from_pretrained(model_name)\n",
|
||||
" model = AutoModelForCausalLM.from_pretrained(model_name)\n",
|
||||
" model.eval()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "GWj9n1cVg5xj",
|
||||
"metadata": {
|
||||
"id": "GWj9n1cVg5xj"
|
||||
},
|
||||
"source": [
|
||||
"# Define the MistralTechAgent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "83492929",
|
||||
"metadata": {
|
||||
"id": "83492929"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"\n",
|
||||
"class MistralTechAgent:\n",
|
||||
" def __init__(self, model, tokenizer):\n",
|
||||
" self.model = model\n",
|
||||
" self.tokenizer = tokenizer\n",
|
||||
"\n",
|
||||
" def chat(self, prompt: str, max_new_tokens=256) -> str:\n",
|
||||
" inputs = self.tokenizer(prompt, return_tensors=\"pt\").to(self.model.device)\n",
|
||||
" with torch.no_grad():\n",
|
||||
" outputs = self.model.generate(\n",
|
||||
" **inputs,\n",
|
||||
" max_new_tokens=max_new_tokens,\n",
|
||||
" do_sample=False, # DETERMINISTIC output\n",
|
||||
" temperature=1.0,\n",
|
||||
" top_p=1.0,\n",
|
||||
" pad_token_id=self.tokenizer.eos_token_id\n",
|
||||
" )\n",
|
||||
" full_output = self.tokenizer.decode(outputs[0], skip_special_tokens=True)\n",
|
||||
" return full_output[len(prompt):].strip()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "QZC6QzA4hB8m",
|
||||
"metadata": {
|
||||
"id": "QZC6QzA4hB8m"
|
||||
},
|
||||
"source": [
|
||||
"# Test the Agent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "83a3388e",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "83a3388e",
|
||||
"outputId": "ebfc13f5-bae9-4647-fc7c-78c386afa03c"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"=== Agent Response ===\n",
|
||||
"A language model is a type of artificial intelligence (AI) model that is designed to understand, interpret, and generate human language. It is a machine learning model that is trained on large amounts of text data to learn the patterns and structures of language, including grammar, vocabulary, and syntax.\n",
|
||||
"\n",
|
||||
"Language models can be used for a variety of tasks, such as language translation, sentiment analysis, text summarization, and speech recognition. They are often used in natural language processing (NLP) applications, where they help machines to understand and interact with humans in a more natural and intuitive way.\n",
|
||||
"\n",
|
||||
"There are several types of language models, including statistical language models, neural language models, and transformer-based language models. These models differ in their architecture, training methods, and performance on different NLP tasks.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\n",
|
||||
"agent = MistralTechAgent(model, tokenizer)\n",
|
||||
"\n",
|
||||
"prompt = \"You are an AI agent helping with technical queries. Explain what a language model is.\"\n",
|
||||
"response = agent.chat(prompt)\n",
|
||||
"\n",
|
||||
"print(\"=== Agent Response ===\")\n",
|
||||
"print(response)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"accelerator": "GPU",
|
||||
"colab": {
|
||||
"gpuType": "T4",
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "ZOWgx2fYqW8T"
|
||||
},
|
||||
"source": [
|
||||
"# GitHub Repository Insights with PraisonAIAgents"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "XgJdLRiIqZ2L"
|
||||
},
|
||||
"source": [
|
||||
"This notebook demonstrates how to explore and analyze GitHub repositories using PraisonAIAgents in Google Colab. You can query repository issues, pull requests, and activity patterns with natural language, leveraging the power of agentic tools—all without leaving your notebook."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "Y_koMT6qzxne"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/Programming_Code_Analysis_Agents/GitHub_Repository_Insights.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "2ey7zWAJrIPx"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"metadata": {
|
||||
"id": "_xFH-iLTxzd8"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonaiagents openai requests --quiet"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "Kzty0zxzsbZ_"
|
||||
},
|
||||
"source": [
|
||||
"# Set Up Key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"metadata": {
|
||||
"id": "HCVP5fmvx2hH"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"# Set your GitHub token here\n",
|
||||
"GITHUB_TOKEN = \"your-github-token\" # <-- Replace with your actual token\n",
|
||||
"\n",
|
||||
"# Set your OpenAI API key here (required by PraisonAIAgents, even if not used for LLM)\n",
|
||||
"OPENAI_API_KEY = \"your-openai-api-key\" # <-- Replace with your actual OpenAI API key\n",
|
||||
"\n",
|
||||
"# Set environment variable for OpenAI\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = OPENAI_API_KEY"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "10BTLbF4s_f-"
|
||||
},
|
||||
"source": [
|
||||
"# Import Libraries"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"metadata": {
|
||||
"id": "_sLahvfXyEb0"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from praisonaiagents import Agent\n",
|
||||
"import requests\n",
|
||||
"from IPython.display import display, Markdown"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "GRftdghxtUDs"
|
||||
},
|
||||
"source": [
|
||||
"# Custom Tool"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"metadata": {
|
||||
"id": "nT11EFNNyIHl"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def github_query_tool(query: str, repo: str, github_token: str) -> str:\n",
|
||||
" \"\"\"\n",
|
||||
" Custom tool to query GitHub repository data using the GitHub API.\n",
|
||||
" Supports basic queries for issues, pull requests, and repository info.\n",
|
||||
" \"\"\"\n",
|
||||
" headers = {\n",
|
||||
" \"Authorization\": f\"token {github_token}\",\n",
|
||||
" \"Accept\": \"application/vnd.github.v3+json\"\n",
|
||||
" }\n",
|
||||
" base_url = f\"https://api.github.com/repos/{repo}\"\n",
|
||||
" result = \"\"\n",
|
||||
"\n",
|
||||
" if \"issue\" in query.lower():\n",
|
||||
" url = f\"{base_url}/issues\"\n",
|
||||
" response = requests.get(url, headers=headers)\n",
|
||||
" if response.ok:\n",
|
||||
" issues = response.json()\n",
|
||||
" result = f\"Found {len(issues)} issues in {repo}.\\n\"\n",
|
||||
" for issue in issues[:5]:\n",
|
||||
" result += f\"- #{issue['number']}: {issue['title']} (State: {issue['state']})\\n\"\n",
|
||||
" else:\n",
|
||||
" result = f\"Failed to fetch issues: {response.text}\"\n",
|
||||
"\n",
|
||||
" elif \"pull request\" in query.lower() or \"pr\" in query.lower():\n",
|
||||
" url = f\"{base_url}/pulls\"\n",
|
||||
" response = requests.get(url, headers=headers)\n",
|
||||
" if response.ok:\n",
|
||||
" pulls = response.json()\n",
|
||||
" result = f\"Found {len(pulls)} pull requests in {repo}.\\n\"\n",
|
||||
" for pr in pulls[:5]:\n",
|
||||
" result += f\"- #{pr['number']}: {pr['title']} (State: {pr['state']})\\n\"\n",
|
||||
" else:\n",
|
||||
" result = f\"Failed to fetch pull requests: {response.text}\"\n",
|
||||
"\n",
|
||||
" elif \"activity\" in query.lower() or \"stats\" in query.lower():\n",
|
||||
" url = f\"{base_url}/stats/contributors\"\n",
|
||||
" response = requests.get(url, headers=headers)\n",
|
||||
" if response.ok:\n",
|
||||
" stats = response.json()\n",
|
||||
" result = f\"Repository activity for {repo}:\\n\"\n",
|
||||
" for contributor in stats[:5]:\n",
|
||||
" result += f\"- {contributor['author']['login']}: {contributor['total']} commits\\n\"\n",
|
||||
" else:\n",
|
||||
" result = f\"Failed to fetch activity stats: {response.text}\"\n",
|
||||
"\n",
|
||||
" else:\n",
|
||||
" # Default: basic repo info\n",
|
||||
" response = requests.get(base_url, headers=headers)\n",
|
||||
" if response.ok:\n",
|
||||
" info = response.json()\n",
|
||||
" result = (\n",
|
||||
" f\"Repository: {info['full_name']}\\n\"\n",
|
||||
" f\"Description: {info.get('description', 'No description')}\\n\"\n",
|
||||
" f\"Stars: {info['stargazers_count']}\\n\"\n",
|
||||
" f\"Forks: {info['forks_count']}\\n\"\n",
|
||||
" f\"Open Issues: {info['open_issues_count']}\\n\"\n",
|
||||
" )\n",
|
||||
" else:\n",
|
||||
" result = f\"Failed to fetch repository info: {response.text}\"\n",
|
||||
"\n",
|
||||
" return result"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "mAFg5SW-tacD"
|
||||
},
|
||||
"source": [
|
||||
"# Register Tool and Create Agent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 28,
|
||||
"metadata": {
|
||||
"id": "x_MmUc_AyMaB"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def github_tool_wrapper(inputs):\n",
|
||||
" query = inputs.get(\"query\", \"\")\n",
|
||||
" repo = inputs.get(\"repo\", \"\")\n",
|
||||
" github_token = inputs.get(\"github_token\", \"\")\n",
|
||||
" return github_query_tool(query, repo, github_token)\n",
|
||||
"\n",
|
||||
"agent = Agent(\n",
|
||||
" instructions=\"\"\"\n",
|
||||
" You are a GitHub assistant. Help users explore repositories and their activity.\n",
|
||||
" - Provide organized, concise insights about the repository.\n",
|
||||
" - Focus on facts and data from the GitHub API.\n",
|
||||
" - Use markdown formatting for better readability.\n",
|
||||
" - Present numerical data in tables when appropriate.\n",
|
||||
" - Include links to relevant GitHub pages when helpful.\n",
|
||||
" \"\"\",\n",
|
||||
" tools={\n",
|
||||
" \"github_query_tool\": github_tool_wrapper\n",
|
||||
" }\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "lPstz7bbtr0k"
|
||||
},
|
||||
"source": [
|
||||
"# User Input and Run Agent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 30,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 118
|
||||
},
|
||||
"id": "MymtRmlnyQqd",
|
||||
"outputId": "33a23810-4a67-4615-f9e9-146b3030fcbf"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Enter the GitHub repository (owner/repo): Dhivya-Bharathy/PraisonAI\n",
|
||||
"Enter your question (e.g., Show me open issues): Show me open issues\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"### Results\n",
|
||||
"Found 0 issues in Dhivya-Bharathy/PraisonAI.\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# User input\n",
|
||||
"repo = input(\"Enter the GitHub repository (owner/repo): \")\n",
|
||||
"query = input(\"Enter your question (e.g., Show me open issues): \")\n",
|
||||
"\n",
|
||||
"# Call the tool directly (since agent.chat expects an LLM, but we want tool output)\n",
|
||||
"response = agent.execute_tool(\"github_query_tool\", {\n",
|
||||
" \"query\": query,\n",
|
||||
" \"repo\": repo,\n",
|
||||
" \"github_token\": GITHUB_TOKEN\n",
|
||||
"})\n",
|
||||
"\n",
|
||||
"# Display the result\n",
|
||||
"display(Markdown(f\"### Results\\n{response}\"))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
Loaded 100 of 1489 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user