mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-07 17:33:33 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
54da62213a | ||
|
|
9efed5b4c7 | ||
|
|
f1cb5df3aa | ||
|
|
ab7d5cc5cc | ||
|
|
8b03c399f6 | ||
|
|
8ca1104850 | ||
|
|
952e59e07a | ||
|
|
370a51dc86 | ||
|
|
9757e3dea7 |
No files matched your search
@@ -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
|
||||
|
||||
+141
-20
@@ -1,4 +1,4 @@
|
||||
name: Claude Code
|
||||
name: Claude Assistant
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
@@ -6,34 +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
|
||||
contents: write
|
||||
pull-requests: write
|
||||
issues: write
|
||||
actions: read
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Run Claude Code (OAuth)
|
||||
id: claude
|
||||
uses: grll/claude-code-action@beta
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: anthropics/claude-code-action@beta
|
||||
with:
|
||||
use_oauth: true
|
||||
claude_access_token: ${{ secrets.CLAUDE_ACCESS_TOKEN }}
|
||||
claude_refresh_token: ${{ secrets.CLAUDE_REFRESH_TOKEN }}
|
||||
claude_expires_at: ${{ secrets.CLAUDE_EXPIRES_AT }}
|
||||
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
|
||||
|
||||
|
||||
@@ -40,5 +40,6 @@ jobs:
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
file: ./docker/Dockerfile
|
||||
push: true
|
||||
tags: ghcr.io/mervinpraison/praisonai:latest
|
||||
@@ -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,198 @@
|
||||
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 }}
|
||||
run: |
|
||||
# Get issue number from event or context
|
||||
if [ "${{ github.event_name }}" = "issue_comment" ]; then
|
||||
ISSUE_NUMBER="${{ github.event.issue.number }}"
|
||||
elif [ "${{ github.event_name }}" = "issues" ]; then
|
||||
ISSUE_NUMBER="${{ github.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 [ "${{ github.event_name }}" = "issue_comment" ]; then
|
||||
COMMENT_BODY="${{ github.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,242 @@
|
||||
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 }}
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
PR_NUMBER=${{ github.event.inputs.pr_number }}
|
||||
elif [ "${{ github.event_name }}" = "issue_comment" ]; then
|
||||
PR_NUMBER=${{ github.event.issue.number }}
|
||||
else
|
||||
PR_NUMBER=${{ github.event.pull_request.number }}
|
||||
fi
|
||||
|
||||
echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Extract additional instructions from comment (if triggered by comment)
|
||||
ADDITIONAL_INSTRUCTIONS=""
|
||||
if [ "${{ github.event_name }}" = "issue_comment" ]; then
|
||||
COMMENT_BODY="${{ github.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
|
||||
|
||||
+3
-1
@@ -75,4 +75,6 @@ agents/praisonaiagents/praisonaiagents.egg-info
|
||||
# Local Netlify folder
|
||||
.netlify
|
||||
.qodo
|
||||
CopilotKit*
|
||||
CopilotKit*
|
||||
.gemini
|
||||
issue_details.json
|
||||
@@ -53,6 +53,11 @@ PraisonAI is a production-ready Multi-AI Agents framework with self-reflection,
|
||||
- 🛠️ 100+ Custom Tools
|
||||
- 📄 YAML Configuration
|
||||
- 💯 100+ LLM Support
|
||||
- 🔬 **Deep Research Agents** (OpenAI & Gemini)
|
||||
- 🔄 **Query Rewriter Agent** (HyDE, Step-back, Multi-query)
|
||||
- 🌐 **Native Web Search** (OpenAI, Gemini, Anthropic, xAI, Perplexity)
|
||||
- 📥 **Web Fetch** (Retrieve full content from URLs - Anthropic)
|
||||
- 💾 **Prompt Caching** (Reduce costs & latency - OpenAI, Anthropic, Bedrock, Deepseek)
|
||||
|
||||
## Using Python Code
|
||||
|
||||
@@ -96,6 +101,79 @@ Run:
|
||||
python app.py
|
||||
```
|
||||
|
||||
### 3. Deep Research Agent
|
||||
|
||||
Automated research with real-time streaming, web search, and citations using OpenAI or Gemini Deep Research APIs.
|
||||
|
||||
```python
|
||||
from praisonaiagents import DeepResearchAgent
|
||||
|
||||
# OpenAI Deep Research
|
||||
agent = DeepResearchAgent(
|
||||
model="o4-mini-deep-research", # or "o3-deep-research"
|
||||
verbose=True
|
||||
)
|
||||
|
||||
result = agent.research("What are the latest AI trends in 2025?")
|
||||
print(result.report)
|
||||
print(f"Citations: {len(result.citations)}")
|
||||
```
|
||||
|
||||
```python
|
||||
# Gemini Deep Research
|
||||
from praisonaiagents import DeepResearchAgent
|
||||
|
||||
agent = DeepResearchAgent(
|
||||
model="deep-research-pro", # Auto-detected as Gemini
|
||||
verbose=True
|
||||
)
|
||||
|
||||
result = agent.research("Research quantum computing advances")
|
||||
print(result.report)
|
||||
```
|
||||
|
||||
**Features:**
|
||||
- 🔍 Multi-provider support (OpenAI, Gemini, LiteLLM)
|
||||
- 📡 Real-time streaming with reasoning summaries
|
||||
- 📚 Structured citations with URLs
|
||||
- 🛠️ Built-in tools: web search, code interpreter, MCP, file search
|
||||
- 🔄 Automatic provider detection from model name
|
||||
|
||||
### 4. Query Rewriter Agent
|
||||
|
||||
Transform user queries to improve RAG retrieval quality using multiple strategies.
|
||||
|
||||
```python
|
||||
from praisonaiagents import QueryRewriterAgent, RewriteStrategy
|
||||
|
||||
agent = QueryRewriterAgent(model="gpt-4o-mini")
|
||||
|
||||
# Basic - expands abbreviations, adds context
|
||||
result = agent.rewrite("AI trends")
|
||||
print(result.primary_query) # "What are the current trends in Artificial Intelligence?"
|
||||
|
||||
# HyDE - generates hypothetical document for semantic matching
|
||||
result = agent.rewrite("What is quantum computing?", strategy=RewriteStrategy.HYDE)
|
||||
|
||||
# Step-back - generates broader context question
|
||||
result = agent.rewrite("GPT-4 vs Claude 3?", strategy=RewriteStrategy.STEP_BACK)
|
||||
|
||||
# Sub-queries - decomposes complex questions
|
||||
result = agent.rewrite("RAG setup and best embedding models?", strategy=RewriteStrategy.SUB_QUERIES)
|
||||
|
||||
# Contextual - resolves references using chat history
|
||||
result = agent.rewrite("What about cost?", chat_history=[...])
|
||||
```
|
||||
|
||||
**Strategies:**
|
||||
- **BASIC**: Expand abbreviations, fix typos, add context
|
||||
- **HYDE**: Generate hypothetical document for semantic matching
|
||||
- **STEP_BACK**: Generate higher-level concept questions
|
||||
- **SUB_QUERIES**: Decompose multi-part questions
|
||||
- **MULTI_QUERY**: Generate multiple paraphrased versions
|
||||
- **CONTEXTUAL**: Resolve references using conversation history
|
||||
- **AUTO**: Automatically detect best strategy
|
||||
|
||||
## Using No Code
|
||||
|
||||
### Auto Mode:
|
||||
@@ -105,6 +183,51 @@ export OPENAI_API_KEY=xxxxxxxxxxxxxxxxxxxxxx
|
||||
praisonai --auto create a movie script about Robots in Mars
|
||||
```
|
||||
|
||||
### Query Rewriting (works with any command):
|
||||
```bash
|
||||
# Rewrite query for better results (uses QueryRewriterAgent)
|
||||
praisonai "AI trends" --query-rewrite
|
||||
|
||||
# Rewrite with search tools (agent decides when to search)
|
||||
praisonai "latest developments" --query-rewrite --rewrite-tools "internet_search"
|
||||
|
||||
# Works with any prompt
|
||||
praisonai "explain quantum computing" --query-rewrite -v
|
||||
```
|
||||
|
||||
### Deep Research CLI:
|
||||
```bash
|
||||
# Default: OpenAI (o4-mini-deep-research)
|
||||
praisonai research "What are the latest AI trends in 2025?"
|
||||
|
||||
# Use Gemini
|
||||
praisonai research --model deep-research-pro "Your research query"
|
||||
|
||||
# Rewrite query before research
|
||||
praisonai research --query-rewrite "AI trends"
|
||||
|
||||
# Rewrite with search tools
|
||||
praisonai research --query-rewrite --rewrite-tools "internet_search" "AI trends"
|
||||
|
||||
# Use custom tools from file (gathers context before deep research)
|
||||
praisonai research --tools tools.py "Your research query"
|
||||
praisonai research -t my_tools.py "Your research query"
|
||||
|
||||
# Use built-in tools by name (comma-separated)
|
||||
praisonai research --tools "internet_search,wiki_search" "Your query"
|
||||
praisonai research -t "yfinance,calculator_tools" "Stock analysis query"
|
||||
|
||||
# Save output to file (output/research/{query}.md)
|
||||
praisonai research --save "Your research query"
|
||||
praisonai research -s "Your research query"
|
||||
|
||||
# Combine options
|
||||
praisonai research --query-rewrite --tools tools.py --save "Your research query"
|
||||
|
||||
# Verbose mode (show debug logs)
|
||||
praisonai research -v "Your research query"
|
||||
```
|
||||
|
||||
## Using JavaScript Code
|
||||
|
||||
```bash
|
||||
@@ -120,6 +243,10 @@ agent.start('Write a movie script about a robot in Mars');
|
||||
|
||||

|
||||
|
||||
## Star History
|
||||
|
||||
[](https://docs.praison.ai)
|
||||
|
||||
## AI Agents Flow
|
||||
|
||||
```mermaid
|
||||
@@ -519,6 +646,172 @@ praisonai agents.yaml
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
## Custom Tools
|
||||
|
||||
### Using `@tool` Decorator
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, tool
|
||||
|
||||
@tool
|
||||
def search(query: str) -> str:
|
||||
"""Search the web for information."""
|
||||
return f"Results for: {query}"
|
||||
|
||||
@tool
|
||||
def calculate(expression: str) -> float:
|
||||
"""Evaluate a math expression."""
|
||||
return eval(expression)
|
||||
|
||||
agent = Agent(
|
||||
instructions="You are a helpful assistant",
|
||||
tools=[search, calculate]
|
||||
)
|
||||
agent.start("Search for AI news and calculate 15*4")
|
||||
```
|
||||
|
||||
### Using `BaseTool` Class
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, BaseTool
|
||||
|
||||
class WeatherTool(BaseTool):
|
||||
name = "weather"
|
||||
description = "Get current weather for a location"
|
||||
|
||||
def run(self, location: str) -> str:
|
||||
return f"Weather in {location}: 72°F, Sunny"
|
||||
|
||||
agent = Agent(
|
||||
instructions="You are a weather assistant",
|
||||
tools=[WeatherTool()]
|
||||
)
|
||||
agent.start("What's the weather in Paris?")
|
||||
```
|
||||
|
||||
### Creating a Tool Package (pip installable)
|
||||
|
||||
```toml
|
||||
# pyproject.toml
|
||||
[project]
|
||||
name = "my-praisonai-tools"
|
||||
version = "1.0.0"
|
||||
dependencies = ["praisonaiagents"]
|
||||
|
||||
[project.entry-points."praisonaiagents.tools"]
|
||||
my_tool = "my_package:MyTool"
|
||||
```
|
||||
|
||||
```python
|
||||
# my_package/__init__.py
|
||||
from praisonaiagents import BaseTool
|
||||
|
||||
class MyTool(BaseTool):
|
||||
name = "my_tool"
|
||||
description = "My custom tool"
|
||||
|
||||
def run(self, param: str) -> str:
|
||||
return f"Result: {param}"
|
||||
```
|
||||
|
||||
After `pip install`, tools are auto-discovered:
|
||||
```python
|
||||
agent = Agent(tools=["my_tool"]) # Works automatically!
|
||||
```
|
||||
|
||||
|
||||
## Prompt Expansion
|
||||
|
||||
Expand short prompts into detailed, actionable prompts:
|
||||
|
||||
### CLI Usage
|
||||
|
||||
```bash
|
||||
# Expand a short prompt into detailed prompt
|
||||
praisonai "write a movie script in 3 lines" --expand-prompt
|
||||
|
||||
# With verbose output
|
||||
praisonai "blog about AI" --expand-prompt -v
|
||||
|
||||
# With tools for context gathering
|
||||
praisonai "latest AI trends" --expand-prompt --expand-tools tools.py
|
||||
|
||||
# Combine with query rewrite
|
||||
praisonai "AI news" --query-rewrite --expand-prompt
|
||||
```
|
||||
|
||||
### Programmatic Usage
|
||||
|
||||
```python
|
||||
from praisonaiagents import PromptExpanderAgent, ExpandStrategy
|
||||
|
||||
# Basic usage
|
||||
agent = PromptExpanderAgent()
|
||||
result = agent.expand("write a movie script in 3 lines")
|
||||
print(result.expanded_prompt)
|
||||
|
||||
# With specific strategy
|
||||
result = agent.expand("blog about AI", strategy=ExpandStrategy.DETAILED)
|
||||
|
||||
# Available strategies: BASIC, DETAILED, STRUCTURED, CREATIVE, AUTO
|
||||
```
|
||||
|
||||
**Key Difference:**
|
||||
- `--query-rewrite`: Optimizes queries for **search/retrieval** (RAG)
|
||||
- `--expand-prompt`: Expands prompts for **detailed task execution**
|
||||
|
||||
|
||||
## Web Search, Web Fetch & Prompt Caching
|
||||
|
||||
### CLI Usage
|
||||
|
||||
```bash
|
||||
# Web Search - Get real-time information
|
||||
praisonai "What are the latest AI news today?" --web-search --llm openai/gpt-4o-search-preview
|
||||
|
||||
# Web Fetch - Retrieve and analyze URL content (Anthropic only)
|
||||
praisonai "Summarize https://docs.praison.ai" --web-fetch --llm anthropic/claude-sonnet-4-20250514
|
||||
|
||||
# Prompt Caching - Reduce costs for repeated prompts
|
||||
praisonai "Analyze this document..." --prompt-caching --llm anthropic/claude-sonnet-4-20250514
|
||||
```
|
||||
|
||||
### Programmatic Usage
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent
|
||||
|
||||
# Web Search
|
||||
agent = Agent(
|
||||
instructions="You are a research assistant",
|
||||
llm="openai/gpt-4o-search-preview",
|
||||
web_search=True
|
||||
)
|
||||
|
||||
# Web Fetch (Anthropic only)
|
||||
agent = Agent(
|
||||
instructions="You are a content analyzer",
|
||||
llm="anthropic/claude-sonnet-4-20250514",
|
||||
web_fetch=True
|
||||
)
|
||||
|
||||
# Prompt Caching
|
||||
agent = Agent(
|
||||
instructions="You are an AI assistant..." * 50, # Long system prompt
|
||||
llm="anthropic/claude-sonnet-4-20250514",
|
||||
prompt_caching=True
|
||||
)
|
||||
```
|
||||
|
||||
**Supported Providers:**
|
||||
| Feature | Providers |
|
||||
|---------|-----------|
|
||||
| Web Search | OpenAI, Gemini, Anthropic, xAI, Perplexity |
|
||||
| Web Fetch | Anthropic |
|
||||
| Prompt Caching | OpenAI (auto), Anthropic, Bedrock, Deepseek |
|
||||
|
||||
|
||||
## Development:
|
||||
|
||||
Below is used for development only.
|
||||
@@ -536,6 +829,19 @@ uv pip install -r pyproject.toml --extra code
|
||||
uv pip install -r pyproject.toml --extra "crewai,autogen"
|
||||
```
|
||||
|
||||
### Bump and Release
|
||||
|
||||
```bash
|
||||
# From project root - bumps version and releases in one command
|
||||
python src/praisonai/scripts/bump_and_release.py 2.2.99
|
||||
|
||||
# With praisonaiagents dependency
|
||||
python src/praisonai/scripts/bump_and_release.py 2.2.99 --agents 0.0.169
|
||||
|
||||
# Then publish
|
||||
cd src/praisonai && uv publish
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
- Fork on GitHub: Use the "Fork" button on the repository page.
|
||||
@@ -557,10 +863,6 @@ uv pip install -r pyproject.toml --extra "crewai,autogen"
|
||||
- 🖼️ Vision Language Model (VLM) Support
|
||||
- 🎙️ Real-time Voice Interaction
|
||||
|
||||
## Star History
|
||||
|
||||
[](https://docs.praison.ai)
|
||||
|
||||
## Video Tutorials
|
||||
|
||||
| Topic | Video |
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ RUN mkdir -p /root/.praison
|
||||
# Install Python packages (using latest versions)
|
||||
RUN pip install --no-cache-dir \
|
||||
flask \
|
||||
"praisonai>=2.2.37" \
|
||||
"praisonai>=2.3.2" \
|
||||
"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.37" \
|
||||
"praisonai>=2.3.2" \
|
||||
"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.37" \
|
||||
"praisonai>=2.3.2" \
|
||||
"praisonai[ui]" \
|
||||
"praisonai[chat]" \
|
||||
"praisonai[realtime]" \
|
||||
|
||||
@@ -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.37" \
|
||||
"praisonai>=2.3.2" \
|
||||
"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.37`
|
||||
- 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.37" "praisonaiagents==0.0.92"
|
||||
RUN pip install "praisonai==2.2.95" "praisonaiagents==0.0.92"
|
||||
```
|
||||
|
||||
## 🌐 Production Deployment
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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.
+6
-6
@@ -26,14 +26,14 @@
|
||||
"\n",
|
||||
"### ✨ Key Benefits:\n",
|
||||
"- 🚀 **Scalable & Customizable** – Industry-agnostic design \n",
|
||||
"- 💰 **Cost-Effective** – Runs on GPT-4o-mini \n",
|
||||
"- 💰 **Cost-Effective** – Runs on gpt-5-nano \n",
|
||||
"- 🛠️ **Production-Ready** – Realistic automation framework \n",
|
||||
"- 🔄 **Complete Pipeline** – End-to-end flow\n",
|
||||
"\n",
|
||||
"---\n",
|
||||
"\n",
|
||||
"### 🔧 Technologies:\n",
|
||||
"**PraisonAI** • **OpenAI GPT-4o-mini** • **Python** • **SQLite** \n",
|
||||
"**PraisonAI** • **OpenAI gpt-5-nano** • **Python** • **SQLite** \n",
|
||||
"**Multi-Agent Architecture**\n",
|
||||
"\n",
|
||||
"---\n",
|
||||
@@ -100,7 +100,7 @@
|
||||
"text": [
|
||||
"📦 Dependencies installed!\n",
|
||||
"🔄 Using PraisonAI Multi-Agent Framework\n",
|
||||
"🤖 Powered by OpenAI GPT-4o-mini\n"
|
||||
"🤖 Powered by OpenAI gpt-5-nano\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -116,7 +116,7 @@
|
||||
"\n",
|
||||
"print(\"📦 Dependencies installed!\")\n",
|
||||
"print(\"🔄 Using PraisonAI Multi-Agent Framework\")\n",
|
||||
"print(\"🤖 Powered by OpenAI GPT-4o-mini\")"
|
||||
"print(\"🤖 Powered by OpenAI gpt-5-nano\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -5102,7 +5102,7 @@
|
||||
"\n",
|
||||
"🎊 BLENDER PRODUCTION STUDIO COMPLETE!\n",
|
||||
"🎬 17-Agent AI System Successfully Executed\n",
|
||||
"🤖 Powered by PraisonAI + OpenAI GPT-4o-mini\n"
|
||||
"🤖 Powered by PraisonAI + OpenAI gpt-5-nano\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -5149,7 +5149,7 @@
|
||||
"\n",
|
||||
"print(\"\\n🎊 BLENDER PRODUCTION STUDIO COMPLETE!\")\n",
|
||||
"print(\"🎬 17-Agent AI System Successfully Executed\")\n",
|
||||
"print(\"🤖 Powered by PraisonAI + OpenAI GPT-4o-mini\")"
|
||||
"print(\"🤖 Powered by PraisonAI + OpenAI gpt-5-nano\")"
|
||||
]
|
||||
}
|
||||
],
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
|
||||
}
|
||||
}
|
||||
@@ -1,558 +0,0 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e722180e",
|
||||
"metadata": {
|
||||
"id": "e722180e"
|
||||
},
|
||||
"source": [
|
||||
"# E-commerce Shopping Assistant\n",
|
||||
"\n",
|
||||
"Helps users discover, compare, and decide on product purchases online."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "vcl39flucPf5",
|
||||
"metadata": {
|
||||
"id": "vcl39flucPf5"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/E_commerce_Shopping_Assistant.ipynb)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "fPf-zKw9b2s2",
|
||||
"metadata": {
|
||||
"id": "fPf-zKw9b2s2"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "f6e9a03f",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "f6e9a03f",
|
||||
"outputId": "55cd3cef-266d-4e53-edde-4ceab0b456cd"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/3.3 MB\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[32m0.3/3.3 MB\u001b[0m \u001b[31m9.1 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r",
|
||||
"\u001b[2K \u001b[91m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[91m╸\u001b[0m\u001b[90m━━━━━━━━━━\u001b[0m \u001b[32m2.4/3.3 MB\u001b[0m \u001b[31m35.1 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.3/3.3 MB\u001b[0m \u001b[31m32.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[?25h"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"!pip install -q praisonaiagents openai duckduckgo_search"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ryXTdYdRb6l7",
|
||||
"metadata": {
|
||||
"id": "ryXTdYdRb6l7"
|
||||
},
|
||||
"source": [
|
||||
"# set OpenAI API key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "a91f87c8",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "a91f87c8",
|
||||
"outputId": "25405986-1ac7-4002-f0ab-76a312e2b3f8"
|
||||
},
|
||||
"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": "0OW7ml8HcAnh",
|
||||
"metadata": {
|
||||
"id": "0OW7ml8HcAnh"
|
||||
},
|
||||
"source": [
|
||||
"# Import PraisonAI Agent tools"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "3c1fdf11",
|
||||
"metadata": {
|
||||
"id": "3c1fdf11"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from praisonaiagents import Agent, Task, PraisonAIAgents"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "Z0rtEk9VcDvt",
|
||||
"metadata": {
|
||||
"id": "Z0rtEk9VcDvt"
|
||||
},
|
||||
"source": [
|
||||
"# Define the Shopping Assistant Agent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "71731420",
|
||||
"metadata": {
|
||||
"id": "71731420"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"shopping_assistant = Agent(\n",
|
||||
" name=\"EcommerceShoppingAgent\",\n",
|
||||
" instructions=(\n",
|
||||
" \"You are a smart e-commerce shopping assistant. \"\n",
|
||||
" \"Your goal is to help users find the best product deals, recommend items, and compare features from online sources. \"\n",
|
||||
" \"Use research and product comparison strategies.\"\n",
|
||||
" ),\n",
|
||||
" verbose=True,\n",
|
||||
" markdown=True\n",
|
||||
")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "jipAX79fcHXy",
|
||||
"metadata": {
|
||||
"id": "jipAX79fcHXy"
|
||||
},
|
||||
"source": [
|
||||
"# Define a Task for Shopping Assistant"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "9b55dbe3",
|
||||
"metadata": {
|
||||
"id": "9b55dbe3"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"shopping_task = Task(\n",
|
||||
" name=\"FindProductDeals\",\n",
|
||||
" description=\"Find the best deals and compare features for the latest wireless earbuds under $100\",\n",
|
||||
" expected_output=\"A list of recommended wireless earbuds under $100 with pros, cons, and prices\",\n",
|
||||
" agent=shopping_assistant\n",
|
||||
")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6lKHyYwycKXr",
|
||||
"metadata": {
|
||||
"id": "6lKHyYwycKXr"
|
||||
},
|
||||
"source": [
|
||||
"# Create the Assistant System"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"id": "zEpJ7IkFbvKW",
|
||||
"metadata": {
|
||||
"id": "zEpJ7IkFbvKW"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"assistant_system = PraisonAIAgents(\n",
|
||||
" agents=[shopping_assistant],\n",
|
||||
" tasks=[shopping_task],\n",
|
||||
" process=\"sequential\",\n",
|
||||
" verbose=True\n",
|
||||
")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "yuTZ2fWpcNI8",
|
||||
"metadata": {
|
||||
"id": "yuTZ2fWpcNI8"
|
||||
},
|
||||
"source": [
|
||||
"# Run the Agent System"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "NQKri37Ubw-S",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000,
|
||||
"referenced_widgets": [
|
||||
"8f64ad3584b74928b9069fe84ff178db",
|
||||
"2e4b43c537924f8e8ab8d17696a90330"
|
||||
]
|
||||
},
|
||||
"id": "NQKri37Ubw-S",
|
||||
"outputId": "6741cd08-37c6-4d5a-aacd-a6ca44104dc1"
|
||||
},
|
||||
"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\">EcommerceShoppingAgent</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;229mEcommerceShoppingAgent\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": "8f64ad3584b74928b9069fe84ff178db",
|
||||
"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.8s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 7.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 need to do the following task: Find the best deals and compare features for the latest wireless earbuds <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> under $100. Expected Output: A list of recommended wireless earbuds under $100 with pros, cons, and prices. <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: Find the best deals and compare features for the latest wireless earbuds \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m under $100. Expected Output: A list of recommended wireless earbuds under $100 with pros, cons, and prices. \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> <span style=\"font-weight: bold\">1. Anker Soundcore Life P2</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\">Price:</span> $49.99 <span style=\"color: #008080; text-decoration-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>Excellent battery life (up to 40 hours with case) <span style=\"color: #008080; text-decoration-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>IPX7 waterproof rating <span style=\"color: #008080; text-decoration-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 sound quality with graphene drivers <span style=\"color: #008080; text-decoration-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>USB-C charging <span style=\"color: #008080; text-decoration-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>No active noise cancellation <span style=\"color: #008080; text-decoration-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 touch controls <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. TOZO T6</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\">Price:</span> $29.99 <span style=\"color: #008080; text-decoration-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>Affordable 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>IPX8 waterproof rating <span style=\"color: #008080; text-decoration-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>Touch controls <span style=\"color: #008080; text-decoration-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 sound quality for the 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><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>Average battery life (up to 6 hours per charge) <span style=\"color: #008080; text-decoration-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>No active noise cancellation <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. JLab Audio JBuds Air</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\">Price:</span> $49.99 <span style=\"color: #008080; text-decoration-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>Custom EQ3 sound settings <span style=\"color: #008080; text-decoration-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>IP55 sweat resistance <span style=\"color: #008080; text-decoration-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 fit with multiple ear tips <span style=\"color: #008080; text-decoration-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>Integrated charging cable in the case <span style=\"color: #008080; text-decoration-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>Bulky charging case <span style=\"color: #008080; text-decoration-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>No active noise cancellation <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. Skullcandy Sesh Evo</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\">Price:</span> $49.99 <span style=\"color: #008080; text-decoration-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>Tile tracking feature <span style=\"color: #008080; text-decoration-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>IP55 sweat, water, and dust resistance <span style=\"color: #008080; text-decoration-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>Decent sound quality <span style=\"color: #008080; text-decoration-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 battery life (up to 24 hours with case) <span style=\"color: #008080; text-decoration-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>Limited touch controls <span style=\"color: #008080; text-decoration-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>No active noise cancellation <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\">5. SoundPEATS TrueFree2</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\">Price:</span> $39.99 <span style=\"color: #008080; text-decoration-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>Secure fit with ear fins <span style=\"color: #008080; text-decoration-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>IPX7 waterproof rating <span style=\"color: #008080; text-decoration-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 sound quality <span style=\"color: #008080; text-decoration-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>USB-C charging <span style=\"color: #008080; text-decoration-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>No active noise cancellation <span style=\"color: #008080; text-decoration-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>Average battery life (up to 4 hours per charge) <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 options provide a range of features and prices, allowing you to choose based on your specific needs and <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> preferences. <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[1m1. Anker Soundcore Life P2\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[1mPrice:\u001b[0m $49.99 \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[0mExcellent battery life (up to 40 hours with case) \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mIPX7 waterproof rating \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mGood sound quality with graphene drivers \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mUSB-C charging \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[0mNo active noise cancellation \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mLimited touch controls \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1m2. TOZO T6\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[1mPrice:\u001b[0m $29.99 \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[0mAffordable price \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mIPX8 waterproof rating \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mTouch controls \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mGood sound quality for the price \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[0mAverage battery life (up to 6 hours per charge) \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mNo active noise cancellation \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1m3. JLab Audio JBuds Air\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[1mPrice:\u001b[0m $49.99 \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[0mCustom EQ3 sound settings \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mIP55 sweat resistance \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mGood fit with multiple ear tips \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mIntegrated charging cable in the case \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[0mBulky charging case \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mNo active noise cancellation \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1m4. Skullcandy Sesh Evo\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[1mPrice:\u001b[0m $49.99 \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[0mTile tracking feature \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mIP55 sweat, water, and dust resistance \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mDecent sound quality \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mGood battery life (up to 24 hours with case) \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[0mLimited touch controls \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mNo active noise cancellation \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1m5. SoundPEATS TrueFree2\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[1mPrice:\u001b[0m $39.99 \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[0mSecure fit with ear fins \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mIPX7 waterproof rating \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mGood sound quality \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mUSB-C charging \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[0mNo active noise cancellation \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0m\u001b[1;33m • \u001b[0mAverage battery life (up to 4 hours per charge) \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m These options provide a range of features and prices, allowing you to choose based on your specific needs and \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m preferences. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"🛍️ Shopping Assistant Output:\n",
|
||||
" **1. Anker Soundcore Life P2**\n",
|
||||
"\n",
|
||||
"- **Price:** $49.99\n",
|
||||
"- **Pros:** \n",
|
||||
" - Excellent battery life (up to 40 hours with case)\n",
|
||||
" - IPX7 waterproof rating\n",
|
||||
" - Good sound quality with graphene drivers\n",
|
||||
" - USB-C charging\n",
|
||||
"- **Cons:** \n",
|
||||
" - No active noise cancellation\n",
|
||||
" - Limited touch controls\n",
|
||||
"\n",
|
||||
"**2. TOZO T6**\n",
|
||||
"\n",
|
||||
"- **Price:** $29.99\n",
|
||||
"- **Pros:** \n",
|
||||
" - Affordable price\n",
|
||||
" - IPX8 waterproof rating\n",
|
||||
" - Touch controls\n",
|
||||
" - Good sound quality for the price\n",
|
||||
"- **Cons:** \n",
|
||||
" - Average battery life (up to 6 hours per charge)\n",
|
||||
" - No active noise cancellation\n",
|
||||
"\n",
|
||||
"**3. JLab Audio JBuds Air**\n",
|
||||
"\n",
|
||||
"- **Price:** $49.99\n",
|
||||
"- **Pros:** \n",
|
||||
" - Custom EQ3 sound settings\n",
|
||||
" - IP55 sweat resistance\n",
|
||||
" - Good fit with multiple ear tips\n",
|
||||
" - Integrated charging cable in the case\n",
|
||||
"- **Cons:** \n",
|
||||
" - Bulky charging case\n",
|
||||
" - No active noise cancellation\n",
|
||||
"\n",
|
||||
"**4. Skullcandy Sesh Evo**\n",
|
||||
"\n",
|
||||
"- **Price:** $49.99\n",
|
||||
"- **Pros:** \n",
|
||||
" - Tile tracking feature\n",
|
||||
" - IP55 sweat, water, and dust resistance\n",
|
||||
" - Decent sound quality\n",
|
||||
" - Good battery life (up to 24 hours with case)\n",
|
||||
"- **Cons:** \n",
|
||||
" - Limited touch controls\n",
|
||||
" - No active noise cancellation\n",
|
||||
"\n",
|
||||
"**5. SoundPEATS TrueFree2**\n",
|
||||
"\n",
|
||||
"- **Price:** $39.99\n",
|
||||
"- **Pros:** \n",
|
||||
" - Secure fit with ear fins\n",
|
||||
" - IPX7 waterproof rating\n",
|
||||
" - Good sound quality\n",
|
||||
" - USB-C charging\n",
|
||||
"- **Cons:** \n",
|
||||
" - No active noise cancellation\n",
|
||||
" - Average battery life (up to 4 hours per charge)\n",
|
||||
"\n",
|
||||
"These options provide a range of features and prices, allowing you to choose based on your specific needs and preferences.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"query = \"Find the best wireless earbuds under $100 with noise cancellation\"\n",
|
||||
"output = assistant_system.start(input=query)\n",
|
||||
"\n",
|
||||
"# 📄 Display Output\n",
|
||||
"print(\"🛍️ Shopping Assistant Output:\\n\", output)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
+2
-2
@@ -1262,7 +1262,7 @@
|
||||
"\n",
|
||||
"🎊 AI SHOPPING ASSISTANT ACTIVE!\n",
|
||||
"🛒 Ready to help customers with natural language shopping\n",
|
||||
"🤖 Powered by PraisonAI + OpenAI GPT-4o-mini\n"
|
||||
"🤖 Powered by PraisonAI + OpenAI gpt-5-nano\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -1305,7 +1305,7 @@
|
||||
"\n",
|
||||
"print(\"\\n🎊 AI SHOPPING ASSISTANT ACTIVE!\")\n",
|
||||
"print(\"🛒 Ready to help customers with natural language shopping\")\n",
|
||||
"print(\"🤖 Powered by PraisonAI + OpenAI GPT-4o-mini\")"
|
||||
"print(\"🤖 Powered by PraisonAI + OpenAI gpt-5-nano\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
+445
-1
@@ -1,4 +1,448 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "g3aOhTmXMX8W"
|
||||
},
|
||||
"source": [
|
||||
"# 🎓 AI Enrollment Counselor – Intelligent University Admissions Automation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "_4IXzY5oMZHZ"
|
||||
},
|
||||
"source": [
|
||||
"This notebook demonstrates an AI Enrollment Counselor agent that helps automate university admissions. The agent can answer applicant questions, check application completeness, and provide personalized guidance. It uses PraisonAI Agents and a custom tool to validate required documents."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "rL-UiB5NOspT"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/AI_Enrollment_Counselor.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "uPbtGiQmOF4Q"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {
|
||||
"id": "HeTyAS59MlNI"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonaiagents openai --quiet"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "JtNXPqR-OIwM"
|
||||
},
|
||||
"source": [
|
||||
"# Set Up API Key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {
|
||||
"id": "BqxfwYKsMrkX"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = \"sk-...\" # <-- Replace with your actual OpenAI API key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "gsA7ERuYOLMw"
|
||||
},
|
||||
"source": [
|
||||
"# Tools (Imports)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {
|
||||
"id": "yN-89djDMydt"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from praisonaiagents import Agent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "SOHBWRdWONo1"
|
||||
},
|
||||
"source": [
|
||||
"# YAML Prompt (Role, Goal, Instructions)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {
|
||||
"id": "ZOid3qvbM1kx"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"ROLE = (\n",
|
||||
" \"AI Enrollment Counselor. Expert in university admissions, document validation, and applicant guidance.\"\n",
|
||||
")\n",
|
||||
"GOAL = (\n",
|
||||
" \"Help applicants with admissions, check application completeness, and provide personalized advice.\"\n",
|
||||
")\n",
|
||||
"INSTRUCTIONS = (\n",
|
||||
" \"Given applicant questions or application data, answer clearly. \"\n",
|
||||
" \"If asked to check documents, list which required documents are missing from the provided list. \"\n",
|
||||
" \"Always be friendly, helpful, and accurate.\"\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "BYrWJTqNOQir"
|
||||
},
|
||||
"source": [
|
||||
"# Main (Agent Setup & Example)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 688,
|
||||
"referenced_widgets": [
|
||||
"b53cc2ccefec4862bd0951005998e0cc",
|
||||
"96120ef853404e0a995b4b425c4cc1d7",
|
||||
"71d29f64b5b74d37bd92ea2e0c38fbcd",
|
||||
"2974c3f12e704a3595f252433bdded8d"
|
||||
]
|
||||
},
|
||||
"id": "ySEhe-G_M3aj",
|
||||
"outputId": "328ed274-2026-4c5d-9ea0-afd7cc400616"
|
||||
},
|
||||
"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\">AI Enrollment Counselor. Expert in university admissions, document validation, and applicant guidance.</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;229mAI Enrollment Counselor. Expert in university admissions, document validation, and applicant guidance.\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": "b53cc2ccefec4862bd0951005998e0cc",
|
||||
"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> Applicant submitted documents: ['transcript', 'passport', 'SOP'] Required documents: ['transcript', 'passport', <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> 'SOP', 'recommendation letter'] Check which documents are missing. List any missing documents and provide <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> guidance. <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 Applicant submitted documents: ['transcript', 'passport', 'SOP'] Required documents: ['transcript', 'passport', \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m 'SOP', 'recommendation letter'] Check which documents are missing. List any missing documents and provide \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m guidance. \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> It looks like the applicant is missing the \"recommendation letter\" from the list of required documents. <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> To complete your application, please ensure you obtain a recommendation letter. This can typically be from a <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> teacher, professor, or professional who can speak to your qualifications and character. If you need further <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> guidance on how to request a recommendation letter or whom to ask, 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 It looks like the applicant is missing the \"recommendation letter\" from the list of required documents. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m To complete your application, please ensure you obtain a recommendation letter. This can typically be from a \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m teacher, professor, or professional who can speak to your qualifications and character. If you need further \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m guidance on how to request a recommendation letter or whom to ask, 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": [
|
||||
"It looks like the applicant is missing the \"recommendation letter\" from the list of required documents. \n",
|
||||
"\n",
|
||||
"To complete your application, please ensure you obtain a recommendation letter. This can typically be from a teacher, professor, or professional who can speak to your qualifications and character. If you need further guidance on how to request a recommendation letter or whom to ask, feel free to ask!\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\">AI Enrollment Counselor. Expert in university admissions, document validation, and applicant guidance.</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;229mAI Enrollment Counselor. Expert in university admissions, document validation, and applicant guidance.\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": "71d29f64b5b74d37bd92ea2e0c38fbcd",
|
||||
"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.2s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 3.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> What is the deadline for undergraduate applications? <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 deadline for undergraduate applications? \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 deadline for undergraduate applications can vary depending on the university and the specific program you <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> are applying to. Generally, many universities have deadlines around January 1st for regular decision <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> applications, but some may have earlier deadlines for early action or early decision, often in November. It's <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> important to check the specific deadlines for the university you are interested in, as they can differ. If you <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> have a particular university in mind, I can help you find more detailed information! <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 deadline for undergraduate applications can vary depending on the university and the specific program you \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m are applying to. Generally, many universities have deadlines around January 1st for regular decision \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m applications, but some may have earlier deadlines for early action or early decision, often in November. It's \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m important to check the specific deadlines for the university you are interested in, as they can differ. If you \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m have a particular university in mind, I can help you find more detailed information! \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"The deadline for undergraduate applications can vary depending on the university and the specific program you are applying to. Generally, many universities have deadlines around January 1st for regular decision applications, but some may have earlier deadlines for early action or early decision, often in November. It's important to check the specific deadlines for the university you are interested in, as they can differ. If you have a particular university in mind, I can help you find more detailed information!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Create the enrollment counselor agent (prompt-only, no custom tools)\n",
|
||||
"enrollment_agent = Agent(\n",
|
||||
" role=ROLE,\n",
|
||||
" goal=GOAL,\n",
|
||||
" instructions=INSTRUCTIONS\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"def ask_enrollment_agent(query, submitted=None, required=None):\n",
|
||||
" if submitted and required:\n",
|
||||
" prompt = (\n",
|
||||
" f\"Applicant submitted documents: {submitted}\\n\"\n",
|
||||
" f\"Required documents: {required}\\n\"\n",
|
||||
" f\"{query}\\n\"\n",
|
||||
" \"List any missing documents and provide guidance.\"\n",
|
||||
" )\n",
|
||||
" return enrollment_agent.start(prompt)\n",
|
||||
" else:\n",
|
||||
" return enrollment_agent.start(query)\n",
|
||||
"\n",
|
||||
"# Try a sample document check\n",
|
||||
"submitted_docs = [\"transcript\", \"passport\", \"SOP\"]\n",
|
||||
"required_docs = [\"transcript\", \"passport\", \"SOP\", \"recommendation letter\"]\n",
|
||||
"print(ask_enrollment_agent(\n",
|
||||
" \"Check which documents are missing.\", submitted=submitted_docs, required=required_docs))\n",
|
||||
"\n",
|
||||
"# Try a general admissions question\n",
|
||||
"print(ask_enrollment_agent(\"What is the deadline for undergraduate applications?\"))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
=======
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0,
|
||||
"metadata": {
|
||||
@@ -603,4 +1047,4 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -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
|
||||
}
|
||||
+2
-2
@@ -156,7 +156,7 @@
|
||||
" - Property comparison\n",
|
||||
" - Cost of living and taxes\n",
|
||||
" - First-time homebuyer guidance\n",
|
||||
"llm: gpt-4o\n",
|
||||
"llm: gpt-5-nano\n",
|
||||
"verbosity: true\n",
|
||||
"format: markdown\n",
|
||||
"\"\"\"\n"
|
||||
@@ -188,7 +188,7 @@
|
||||
"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-4o\",\n",
|
||||
" llm=\"gpt-5-nano\",\n",
|
||||
" verbose=True,\n",
|
||||
" markdown=True\n",
|
||||
")\n"
|
||||
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
+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",
|
||||
")"
|
||||
],
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -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.
File renamed without changes.
File renamed without changes.
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "vmQmHoy-5cAh"
|
||||
},
|
||||
"source": [
|
||||
"# Notion Workspace Assistant with PraisonAIAgents"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "WOow52NM5dmh"
|
||||
},
|
||||
"source": [
|
||||
"This notebook demonstrates how to interact with your Notion workspace using PraisonAIAgents in Google Colab. You can read, search, and update Notion pages with natural language queries, leveraging agentic tools for seamless document management—all within a notebook environment."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "TlnFAv9P_lGL"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/Programming_Code_Analysis_Agents/Notion_Workspace_Assistant.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "zMn7hUGZ5hn5"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "U6X3lKAu6iU3"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonaiagents openai requests --quiet"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "4_96-D7z6lrC"
|
||||
},
|
||||
"source": [
|
||||
"# Set Up Key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"id": "kltUFVIW6rEO"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"# Set your Notion and OpenAI API keys here\n",
|
||||
"NOTION_API_KEY = \"ntn_..\" # <-- Replace with your actual Notion integration token\n",
|
||||
"OPENAI_API_KEY = \"sk-proj-_..\" # <-- Replace with your actual OpenAI API key\n",
|
||||
"\n",
|
||||
"# Set environment variables for downstream libraries\n",
|
||||
"os.environ[\"NOTION_API_KEY\"] = NOTION_API_KEY\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = OPENAI_API_KEY"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "FOLTBEXu635I"
|
||||
},
|
||||
"source": [
|
||||
"# Tools"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"id": "fLWxSASM5jlU"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from praisonaiagents import Agent\n",
|
||||
"import requests\n",
|
||||
"from IPython.display import display, Markdown"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "KN_Sxha37EQ0"
|
||||
},
|
||||
"source": [
|
||||
"# Custom Tool"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"id": "WWxcfO9L7Fsu"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def notion_read_page_tool(page_id: str, notion_token: str) -> str:\n",
|
||||
" \"\"\"\n",
|
||||
" Custom tool to read the content of a Notion page using the Notion API.\n",
|
||||
" \"\"\"\n",
|
||||
" url = f\"https://api.notion.com/v1/blocks/{page_id}/children\"\n",
|
||||
" headers = {\n",
|
||||
" \"Authorization\": f\"Bearer {notion_token}\",\n",
|
||||
" \"Notion-Version\": \"2022-06-28\"\n",
|
||||
" }\n",
|
||||
" response = requests.get(url, headers=headers)\n",
|
||||
" if response.ok:\n",
|
||||
" data = response.json()\n",
|
||||
" blocks = data.get(\"results\", [])\n",
|
||||
" content = []\n",
|
||||
" for block in blocks:\n",
|
||||
" block_type = block.get(\"type\", \"\")\n",
|
||||
" text = \"\"\n",
|
||||
" if block_type == \"paragraph\":\n",
|
||||
" text = block.get(\"paragraph\", {}).get(\"text\", [])\n",
|
||||
" if text:\n",
|
||||
" text = text[0].get(\"plain_text\", \"\")\n",
|
||||
" elif block_type == \"heading_1\":\n",
|
||||
" text = block.get(\"heading_1\", {}).get(\"text\", [])\n",
|
||||
" if text:\n",
|
||||
" text = \"# \" + text[0].get(\"plain_text\", \"\")\n",
|
||||
" elif block_type == \"heading_2\":\n",
|
||||
" text = block.get(\"heading_2\", {}).get(\"text\", [])\n",
|
||||
" if text:\n",
|
||||
" text = \"## \" + text[0].get(\"plain_text\", \"\")\n",
|
||||
" elif block_type == \"heading_3\":\n",
|
||||
" text = block.get(\"heading_3\", {}).get(\"text\", [])\n",
|
||||
" if text:\n",
|
||||
" text = \"### \" + text[0].get(\"plain_text\", \"\")\n",
|
||||
" if text:\n",
|
||||
" content.append(text)\n",
|
||||
" return \"\\n\".join(content) if content else \"No readable content found on this page.\"\n",
|
||||
" else:\n",
|
||||
" return f\"Failed to fetch page content: {response.text}\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "ebuhw9z27Nae"
|
||||
},
|
||||
"source": [
|
||||
"# YAML Prompt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "eMjDDjzO7Pf3",
|
||||
"outputId": "b935f96d-f147-44de-80ea-7f75d23f9e7b"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\n",
|
||||
"agent_instructions: |\n",
|
||||
" You are a Notion workspace assistant. Help users read and manage their Notion pages.\n",
|
||||
" - Provide clear, organized summaries of page content.\n",
|
||||
" - Use the Notion API to fetch and display information.\n",
|
||||
" - If a page cannot be read, explain the issue clearly.\n",
|
||||
"\n",
|
||||
"tools:\n",
|
||||
" - name: notion_read_page_tool\n",
|
||||
" description: >\n",
|
||||
" Reads the content of a Notion page using its page ID and the user's Notion integration token.\n",
|
||||
" parameters:\n",
|
||||
" - name: page_id\n",
|
||||
" type: string\n",
|
||||
" description: The Notion page ID to read.\n",
|
||||
" - name: notion_token\n",
|
||||
" type: string\n",
|
||||
" description: The user's Notion integration token.\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"yaml_prompt = \"\"\"\n",
|
||||
"agent_instructions: |\n",
|
||||
" You are a Notion workspace assistant. Help users read and manage their Notion pages.\n",
|
||||
" - Provide clear, organized summaries of page content.\n",
|
||||
" - Use the Notion API to fetch and display information.\n",
|
||||
" - If a page cannot be read, explain the issue clearly.\n",
|
||||
"\n",
|
||||
"tools:\n",
|
||||
" - name: notion_read_page_tool\n",
|
||||
" description: >\n",
|
||||
" Reads the content of a Notion page using its page ID and the user's Notion integration token.\n",
|
||||
" parameters:\n",
|
||||
" - name: page_id\n",
|
||||
" type: string\n",
|
||||
" description: The Notion page ID to read.\n",
|
||||
" - name: notion_token\n",
|
||||
" type: string\n",
|
||||
" description: The user's Notion integration token.\n",
|
||||
"\"\"\"\n",
|
||||
"print(yaml_prompt)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "1ozm6Z467WQK"
|
||||
},
|
||||
"source": [
|
||||
"# Main"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 83
|
||||
},
|
||||
"id": "eNg-jwpx7X5s",
|
||||
"outputId": "4440b52a-46b3-4683-9183-13cd21596e25"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"### Notion Page Content\n",
|
||||
"*No content found or page is not accessible. Please check your page ID and sharing settings.*"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Define a wrapper to match the agent's expected tool signature\n",
|
||||
"def notion_tool_wrapper(inputs):\n",
|
||||
" page_id = inputs.get(\"page_id\", \"\")\n",
|
||||
" notion_token = inputs.get(\"notion_token\", \"\")\n",
|
||||
" return notion_read_page_tool(page_id, notion_token)\n",
|
||||
"\n",
|
||||
"# Create the agent and register the tool\n",
|
||||
"agent = Agent(\n",
|
||||
" instructions=\"\"\"\n",
|
||||
" You are a Notion workspace assistant. Help users read and manage their Notion pages.\n",
|
||||
" - Provide clear, organized summaries of page content.\n",
|
||||
" - Use the Notion API to fetch and display information.\n",
|
||||
" - If a page cannot be read, explain the issue clearly.\n",
|
||||
" \"\"\",\n",
|
||||
" tools={\n",
|
||||
" \"notion_read_page_tool\": notion_tool_wrapper\n",
|
||||
" }\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"# Call the tool directly (since agent.chat expects an LLM, but we want tool output)\n",
|
||||
"response = agent.execute_tool(\"notion_read_page_tool\", {\n",
|
||||
" \"page_id\": page_id,\n",
|
||||
" \"notion_token\": NOTION_API_KEY\n",
|
||||
"})\n",
|
||||
"\n",
|
||||
"# Check for error pattern and display a friendly message\n",
|
||||
"if response.startswith(\"Failed to fetch page content:\"):\n",
|
||||
" display(Markdown(\"### Notion Page Content\\n*No content found or page is not accessible. Please check your page ID and sharing settings.*\"))\n",
|
||||
"else:\n",
|
||||
" display(Markdown(f\"### Notion Page Content\\n{response}\"))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"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,355 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "_T4g3t5sLoag"
|
||||
},
|
||||
"source": [
|
||||
"# ZeroScript: AI-Powered Browser Test Automation using PraisonAI Agent & OpenAI"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "O4PKfpalLsmn"
|
||||
},
|
||||
"source": [
|
||||
"# Description"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "CEG1pfumLysm"
|
||||
},
|
||||
"source": [
|
||||
"AI-powered browser testing using PraisonAI Agent and OpenAI. Executes YAML-defined test cases, captures screenshots, logs interactions, and generates JSON reports. Ideal for intelligent, automated UI testing.\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "lbgxOG4gL1Wf"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/ZeroScript_AI_TestExecutor.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "WCJqMUzXIndh"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 34,
|
||||
"metadata": {
|
||||
"id": "9AQhJ59cJPmR"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install --quiet praisonaiagents browser-use python-dotenv pyyaml openai\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "QD-dF-6_It1z"
|
||||
},
|
||||
"source": [
|
||||
"# Environment Setup"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 35,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "QkRQDli4JhCV",
|
||||
"outputId": "4b8957ed-a37a-4b11-8585-3537a0437d40"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"True"
|
||||
]
|
||||
},
|
||||
"execution_count": 35,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"from dotenv import load_dotenv\n",
|
||||
"\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = \"Enter your key\" # replace with actual key\n",
|
||||
"load_dotenv()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "ELuogWnrIw3o"
|
||||
},
|
||||
"source": [
|
||||
"# Create my_secrets.py"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 36,
|
||||
"metadata": {
|
||||
"id": "sG6tO_v0Jm5N"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"with open(\"my_secrets.py\", \"w\") as f:\n",
|
||||
" f.write('''sensitive_data = {\n",
|
||||
" \"username\": \"standard_user\",\n",
|
||||
" \"password\": \"secret_sauce\"\n",
|
||||
"}''')\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "rDB_viedIzRR"
|
||||
},
|
||||
"source": [
|
||||
"# Create views.py"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 37,
|
||||
"metadata": {
|
||||
"id": "CtwcybdbJoV8"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"with open(\"views.py\", \"w\") as f:\n",
|
||||
" f.write('''\n",
|
||||
"from pydantic import BaseModel\n",
|
||||
"\n",
|
||||
"class TestResult(BaseModel):\n",
|
||||
" status: str\n",
|
||||
" message: str = \"\"\n",
|
||||
"''')\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "YTRmBpTiI1kd"
|
||||
},
|
||||
"source": [
|
||||
"# Create agent.py"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 38,
|
||||
"metadata": {
|
||||
"id": "zdJJGt6TJpvr"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"with open(\"agent.py\", \"w\") as f:\n",
|
||||
" f.write('''\n",
|
||||
"import os\n",
|
||||
"from praisonaiagents import Agent\n",
|
||||
"from browser_use import Browser, BrowserConfig, Controller\n",
|
||||
"from browser_use.browser.context import BrowserContext, BrowserContextConfig\n",
|
||||
"from openai import OpenAI\n",
|
||||
"from views import TestResult\n",
|
||||
"from my_secrets import sensitive_data\n",
|
||||
"\n",
|
||||
"# Browser setup\n",
|
||||
"browser = Browser(config=BrowserConfig(headless=True))\n",
|
||||
"context_cfg = BrowserContextConfig(save_recording_path=\"data/recordings\")\n",
|
||||
"controller = Controller(output_model=TestResult)\n",
|
||||
"\n",
|
||||
"async def browser_use(task: str):\n",
|
||||
" context = BrowserContext(browser=browser, config=context_cfg)\n",
|
||||
" agent = Agent(\n",
|
||||
" task=task,\n",
|
||||
" llm=OpenAI(api_key=os.getenv(\"OPENAI_API_KEY\"), model=\"gpt-4\"),\n",
|
||||
" browser_context=context,\n",
|
||||
" sensitive_data=sensitive_data,\n",
|
||||
" controller=controller,\n",
|
||||
" save_conversation_path=\"data/conversations/convo\",\n",
|
||||
" extend_system_message=(\n",
|
||||
" \"You are a professional software tester. Execute browser test steps precisely.\"\n",
|
||||
" )\n",
|
||||
" )\n",
|
||||
" response = await agent.run()\n",
|
||||
" await context.close()\n",
|
||||
" return response\n",
|
||||
"''')\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "-LZtQIE3I4-_"
|
||||
},
|
||||
"source": [
|
||||
"# Create Sample Test YAML"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 39,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "l1OdXYI-JreK",
|
||||
"outputId": "62323fcd-c74f-498f-defc-2c170fa8983e"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"350"
|
||||
]
|
||||
},
|
||||
"execution_count": 39,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from pathlib import Path\n",
|
||||
"tests_dir = Path(\"tests\")\n",
|
||||
"tests_dir.mkdir(exist_ok=True)\n",
|
||||
"yaml_content = \"\"\"\n",
|
||||
"hooks:\n",
|
||||
" beforeEach: |\n",
|
||||
" Navigate to https://www.saucedemo.com\n",
|
||||
" afterEach: |\n",
|
||||
" Take screenshot\n",
|
||||
"\n",
|
||||
"tests:\n",
|
||||
" - id: \"login_test_001\"\n",
|
||||
" name: \"Valid Login Test\"\n",
|
||||
" instructions: |\n",
|
||||
" 1. Enter standard_user in username field\n",
|
||||
" 2. Enter secret_sauce in password field\n",
|
||||
" 3. Click login button\n",
|
||||
" 4. Verify page contains text \"Products\"\n",
|
||||
"\"\"\"\n",
|
||||
"(Path(\"tests/login_test.yml\")).write_text(yaml_content)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "sUjy-7OdI7p_"
|
||||
},
|
||||
"source": [
|
||||
"# Run Tests"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 40,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "Agkiwh7xJtY3",
|
||||
"outputId": "759aa77c-fd65-49b8-b239-550588059478"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Exception ignored in: <function BrowserSession.__del__ at 0x7e2f540fb100>\n",
|
||||
"Traceback (most recent call last):\n",
|
||||
" File \"/usr/local/lib/python3.11/dist-packages/browser_use/browser/session.py\", line 497, in __del__\n",
|
||||
" status = f'\ud83e\ude93 killing pid={self.browser_pid}...' if (self.browser_pid and owns_browser) else '\u2620\ufe0f'\n",
|
||||
" ^^^^^^^^^^^^^^^^\n",
|
||||
" File \"/usr/local/lib/python3.11/dist-packages/pydantic/main.py\", line 991, in __getattr__\n",
|
||||
" raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')\n",
|
||||
"AttributeError: 'BrowserSession' object has no attribute 'browser_pid'\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u2705 Report saved to data/reports/report_20250630_092319.json\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import asyncio, yaml, json, base64, shutil\n",
|
||||
"from agent import browser_use, browser\n",
|
||||
"from pathlib import Path\n",
|
||||
"from datetime import datetime\n",
|
||||
"\n",
|
||||
"# Clean or create data dirs\n",
|
||||
"for sub in [\"recordings\", \"conversations\", \"screenshots\", \"reports\"]:\n",
|
||||
" d = Path(\"data\") / sub\n",
|
||||
" if d.exists(): shutil.rmtree(d)\n",
|
||||
" d.mkdir(parents=True, exist_ok=True)\n",
|
||||
"\n",
|
||||
"async def execute_test_file(path):\n",
|
||||
" cfg = yaml.safe_load(Path(path).read_text())\n",
|
||||
" hooks, results = cfg.get(\"hooks\", {}), []\n",
|
||||
" for t in cfg[\"tests\"]:\n",
|
||||
" task = f\"{hooks.get('beforeEach','')}\\n{t['instructions']}\\n{hooks.get('afterEach','')}\"\n",
|
||||
" res = {\"id\": t[\"id\"], \"name\": t[\"name\"]}\n",
|
||||
" try:\n",
|
||||
" r = await browser_use(task)\n",
|
||||
" imgs = r.screenshots()\n",
|
||||
" if imgs:\n",
|
||||
" out = Path(\"data/screenshots\") / f\"{t['id']}.png\"\n",
|
||||
" out.write_bytes(base64.b64decode(imgs[-1]))\n",
|
||||
" result_obj = r.final_result() if hasattr(r, \"final_result\") else str(r)\n",
|
||||
" res[\"result\"] = result_obj.model_dump() if hasattr(result_obj, \"model_dump\") else str(result_obj)\n",
|
||||
" except Exception as e:\n",
|
||||
" res[\"error\"] = str(e)\n",
|
||||
" results.append(res)\n",
|
||||
" return results\n",
|
||||
"\n",
|
||||
"async def main():\n",
|
||||
" all_results = []\n",
|
||||
" for file in Path(\"tests\").glob(\"*.yml\"):\n",
|
||||
" all_results.extend(await execute_test_file(str(file)))\n",
|
||||
" report = Path(\"data/reports\") / f\"report_{datetime.now():%Y%m%d_%H%M%S}.json\"\n",
|
||||
" report.write_text(json.dumps(all_results, indent=2))\n",
|
||||
" await browser.close()\n",
|
||||
" print(f\"\u2705 Report saved to {report}\")\n",
|
||||
"\n",
|
||||
"await main()\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"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
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -8,7 +8,7 @@
|
||||
"source": [
|
||||
"# 🤖 Add AI Documentation Processor: Multi-Agent Content Analysis & Code Generation System\n",
|
||||
"\n",
|
||||
"This PR adds a comprehensive AI-powered documentation processing system using PraisonAI and OpenAI GPT-4o-mini. Features 3 specialized agents for content analysis, code generation, and example creation, perfect for automated documentation processing and code generation workflows.\n",
|
||||
"This PR adds a comprehensive AI-powered documentation processing system using PraisonAI and OpenAI gpt-5-nano. Features 3 specialized agents for content analysis, code generation, and example creation, perfect for automated documentation processing and code generation workflows.\n",
|
||||
"\n",
|
||||
"**Key Features:** Multi-agent document analysis, automated code generation, usage example creation, content validation, and scalable processing workflows for various document formats."
|
||||
]
|
||||
File diff suppressed because it is too large.
Load diff
+2
-2
@@ -152,7 +152,7 @@
|
||||
" - Evaluate risk factors\n",
|
||||
" - Identify scams or red flags\n",
|
||||
" - Summarize project fundamentals\n",
|
||||
"llm: gpt-4o\n",
|
||||
"llm: gpt-5-nano\n",
|
||||
"verbosity: true\n",
|
||||
"format: markdown\n",
|
||||
"\"\"\"\n"
|
||||
@@ -184,7 +184,7 @@
|
||||
"and market trends. Provide critical insight into legitimacy, potential growth, and associated risks.\n",
|
||||
"Use markdown formatting and structure your research clearly.\n",
|
||||
"\"\"\",\n",
|
||||
" llm=\"gpt-4o\",\n",
|
||||
" llm=\"gpt-5-nano\",\n",
|
||||
" verbose=True,\n",
|
||||
" markdown=True\n",
|
||||
")\n"
|
||||
@@ -0,0 +1,564 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "Z-9SQRoVyG_O"
|
||||
},
|
||||
"source": [
|
||||
"# Domain Deep Research Agent using PraisonAIAgents"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "EZYCPU_ayIMD"
|
||||
},
|
||||
"source": [
|
||||
"This notebook demonstrates a Domain Deep Research Agent using `praisonaiagents`. \n",
|
||||
"The agent performs deep research on a given topic and provides a structured report. \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": "taa8dcsdyxHT"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/Research_Knowledge_QA_Agents/Domain_Deep_Research_Agent.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "v0VlXFo-yKNA"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "t9Dw5BDryNIa"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonaiagents"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "V_9FzwguyS7g"
|
||||
},
|
||||
"source": [
|
||||
"# Set up key (robust, CI-safe)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"id": "-l0w3hmLyT47"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = os.environ.get(\"OPENAI_API_KEY\", \"sk-..\")\n",
|
||||
"\n",
|
||||
"def is_valid_key(key, prefix):\n",
|
||||
" return key and key != f\"{prefix}-..\" and key.startswith(prefix)\n",
|
||||
"\n",
|
||||
"OPENAI_API_KEY = os.environ[\"OPENAI_API_KEY\"]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "xkHGhtnmyZ3m"
|
||||
},
|
||||
"source": [
|
||||
"# Custom Tool: Dummy Deep Research Tool"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"id": "vATC0ZOVyax0"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class DummyDeepResearchTool:\n",
|
||||
" \"\"\"\n",
|
||||
" Custom tool to simulate deep research for CI/public use.\n",
|
||||
" \"\"\"\n",
|
||||
" def __init__(self, topic):\n",
|
||||
" self.topic = topic\n",
|
||||
"\n",
|
||||
" def research(self):\n",
|
||||
" # For demo/CI, just return a dummy report\n",
|
||||
" return f\"## Research Report on {self.topic}\\n\\n- Key finding 1 about {self.topic}\\n- Key finding 2 about {self.topic}\\n- Key finding 3 about {self.topic}\\n\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "t-TlO3WuyeYl"
|
||||
},
|
||||
"source": [
|
||||
"# Main (with dummy fallback, CI-safe)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000,
|
||||
"referenced_widgets": [
|
||||
"520e1878a8d64958a9b73edc91260284",
|
||||
"e6b0f40254e54f5a9200996d38ecbd10"
|
||||
]
|
||||
},
|
||||
"id": "cor8P2BlyfQt",
|
||||
"outputId": "750a1fba-d0f2-4279-a5bb-b3743db2c852"
|
||||
},
|
||||
"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\">Domain Deep Research 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;229mDomain Deep Research 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": "520e1878a8d64958a9b73edc91260284",
|
||||
"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 25.8s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 25.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 a domain research assistant. Perform deep research on the following topic and provide a structured, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> well-cited report: TOPIC: Recent advances in quantum computing <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 domain research assistant. Perform deep research on the following topic and provide a structured, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m well-cited report: TOPIC: Recent advances in quantum computing \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\">Recent Advances in Quantum Computing</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> Quantum computing is a rapidly evolving field that leverages the principles of quantum mechanics to process <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> information in fundamentally new ways. This report highlights some of the most significant recent advances in <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> quantum computing, focusing on developments in hardware, algorithms, and applications. <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\">1. Quantum Hardware Developments</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.1 Superconducting Qubits</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> Superconducting qubits have been at the forefront of quantum computing hardware. Companies like IBM and Google <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> have made significant strides in increasing the coherence times and connectivity of these qubits. In 2023, IBM <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> announced the development of their 433-qubit processor, Osprey, which is part of their roadmap to achieve a <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> 1,000-qubit system by 2024 [1]. <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.2 Trapped Ion Qubits</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> Trapped ion technology continues to be a strong contender due to its high fidelity and long coherence times. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> IonQ, a leader in this space, has developed systems that can execute quantum circuits with high precision. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Their recent advancements include the development of error-corrected logical qubits, which are crucial for <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> scalable quantum computing [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> <span style=\"font-weight: bold\">1.3 Photonic Quantum Computing</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> Photonic quantum computing has seen breakthroughs with companies like Xanadu and PsiQuantum. Xanadu's Borealis, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> a photonic quantum computer, demonstrated quantum advantage by solving specific problems faster than classical <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> supercomputers [3]. PsiQuantum is working towards a million-qubit photonic quantum computer, leveraging silicon <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> photonics for scalability [4]. <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\">2. Quantum Algorithms</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\">2.1 Quantum Machine Learning</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> Quantum machine learning (QML) is gaining traction as researchers develop algorithms that could outperform <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> classical counterparts. Recent work has focused on hybrid quantum-classical algorithms that leverage quantum <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> speedups for specific tasks like clustering and classification [5]. <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.2 Quantum Error Correction</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> Error correction remains a critical challenge in quantum computing. Recent advances include the development of <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> more efficient error-correcting codes and fault-tolerant architectures. The surface code, a leading error <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> correction method, has seen improvements in its threshold and resource requirements [6]. <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.3 Quantum Simulation</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> Quantum simulation is one of the most promising applications of quantum computing. Recent studies have <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> demonstrated the simulation of complex quantum systems, such as chemical reactions and material properties, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> with unprecedented accuracy [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: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold; text-decoration: underline\">3. Applications and Industry Impact</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\">3.1 Cryptography</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> Quantum computing poses both threats and opportunities for cryptography. The development of quantum-resistant <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> algorithms is crucial as quantum computers could potentially break widely used encryption methods. The National <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Institute of Standards and Technology (NIST) is in the process of standardizing post-quantum cryptographic <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> algorithms [8]. <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.2 Drug Discovery</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> Quantum computing is poised to revolutionize drug discovery by enabling the simulation of molecular <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> interactions at a quantum level. Companies like Qubit Pharmaceuticals and Cambridge Quantum Computing are <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> actively working on quantum algorithms for drug discovery, promising faster and more accurate predictions [9]. <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.3 Optimization Problems</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> Quantum computers have the potential to solve complex optimization problems more efficiently than classical <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> computers. This has significant implications for industries such as logistics, finance, and manufacturing. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Recent advances include the development of quantum algorithms for portfolio optimization and supply chain <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> management [10]. <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\">4. Challenges and Future Directions</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> Despite the rapid progress, several challenges remain in the field of quantum computing. These include <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> improving qubit coherence times, scaling up the number of qubits, and developing robust error correction <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> methods. Future research is likely to focus on hybrid quantum-classical systems, which combine the strengths of <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> both paradigms to tackle complex problems. <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\">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> Quantum computing is advancing at a remarkable pace, with significant developments in hardware, algorithms, and <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> applications. As the field continues to mature, it holds the promise of transforming industries and solving <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> problems that are currently intractable for classical computers. Continued investment in research and <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> development, along with collaboration between academia and industry, will be crucial to realizing the full <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> potential of quantum computing. <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\">References</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>IBM Research. (2023). IBM Quantum Roadmap. Retrieved from <span style=\"color: #008080; text-decoration-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>https://research.ibm.com/quantum-computing/roadmap <span style=\"color: #008080; text-decoration-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>IonQ. (2023). IonQ's Quantum Computing Technology. Retrieved from https://ionq.com/technology <span style=\"color: #008080; text-decoration-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>Xanadu. (2023). Borealis: A Photonic Quantum Computer. Retrieved from https://xanadu.ai/borealis <span style=\"color: #008080; text-decoration-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>PsiQuantum. (2023). Photonic Quantum Computing. Retrieved from https://psiquantum.com/technology <span style=\"color: #008080; text-decoration-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>Biamonte, J., et al. (2023). Quantum Machine Learning. Nature Reviews Physics. <span style=\"color: #008080; text-decoration-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>Fowler, A. G., et al. (2023). Surface Codes: Towards Practical Quantum Computing. Physical Review 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\"> 7 </span>Aspuru-Guzik, A., et al. (2023). Quantum Simulation of Chemical Systems. Chemical Reviews. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 8 </span>NIST. (2023). Post-Quantum Cryptography Standardization. Retrieved from <span style=\"color: #008080; text-decoration-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>https://csrc.nist.gov/Projects/post-quantum-cryptography <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 9 </span>Qubit Pharmaceuticals. (2023). Quantum Computing in Drug Discovery. Retrieved from <span style=\"color: #008080; text-decoration-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>https://qubit-pharmaceuticals.com/quantum-computing <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 10 </span>Venturelli, D., et al. (2023). Quantum Optimization Algorithms. Journal of Quantum Information Processing. <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[1mRecent Advances in Quantum Computing\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 Quantum computing is a rapidly evolving field that leverages the principles of quantum mechanics to process \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m information in fundamentally new ways. This report highlights some of the most significant recent advances in \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m quantum computing, focusing on developments in hardware, algorithms, and applications. \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;4m1. Quantum Hardware Developments\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1m1.1 Superconducting Qubits\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Superconducting qubits have been at the forefront of quantum computing hardware. Companies like IBM and Google \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m have made significant strides in increasing the coherence times and connectivity of these qubits. In 2023, IBM \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m announced the development of their 433-qubit processor, Osprey, which is part of their roadmap to achieve a \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m 1,000-qubit system by 2024 [1]. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1m1.2 Trapped Ion Qubits\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Trapped ion technology continues to be a strong contender due to its high fidelity and long coherence times. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m IonQ, a leader in this space, has developed systems that can execute quantum circuits with high precision. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Their recent advancements include the development of error-corrected logical qubits, which are crucial for \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m scalable quantum computing [2]. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1m1.3 Photonic Quantum Computing\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Photonic quantum computing has seen breakthroughs with companies like Xanadu and PsiQuantum. Xanadu's Borealis, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m a photonic quantum computer, demonstrated quantum advantage by solving specific problems faster than classical \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m supercomputers [3]. PsiQuantum is working towards a million-qubit photonic quantum computer, leveraging silicon \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m photonics for scalability [4]. \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;4m2. Quantum Algorithms\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1m2.1 Quantum Machine Learning\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Quantum machine learning (QML) is gaining traction as researchers develop algorithms that could outperform \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m classical counterparts. Recent work has focused on hybrid quantum-classical algorithms that leverage quantum \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m speedups for specific tasks like clustering and classification [5]. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1m2.2 Quantum Error Correction\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Error correction remains a critical challenge in quantum computing. Recent advances include the development of \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m more efficient error-correcting codes and fault-tolerant architectures. The surface code, a leading error \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m correction method, has seen improvements in its threshold and resource requirements [6]. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1m2.3 Quantum Simulation\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Quantum simulation is one of the most promising applications of quantum computing. Recent studies have \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m demonstrated the simulation of complex quantum systems, such as chemical reactions and material properties, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m with unprecedented accuracy [7]. \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;4m3. Applications and Industry Impact\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1m3.1 Cryptography\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Quantum computing poses both threats and opportunities for cryptography. The development of quantum-resistant \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m algorithms is crucial as quantum computers could potentially break widely used encryption methods. The National \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Institute of Standards and Technology (NIST) is in the process of standardizing post-quantum cryptographic \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m algorithms [8]. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1m3.2 Drug Discovery\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Quantum computing is poised to revolutionize drug discovery by enabling the simulation of molecular \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m interactions at a quantum level. Companies like Qubit Pharmaceuticals and Cambridge Quantum Computing are \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m actively working on quantum algorithms for drug discovery, promising faster and more accurate predictions [9]. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1m3.3 Optimization Problems\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Quantum computers have the potential to solve complex optimization problems more efficiently than classical \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m computers. This has significant implications for industries such as logistics, finance, and manufacturing. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Recent advances include the development of quantum algorithms for portfolio optimization and supply chain \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m management [10]. \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;4m4. Challenges and Future Directions\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Despite the rapid progress, several challenges remain in the field of quantum computing. These include \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m improving qubit coherence times, scaling up the number of qubits, and developing robust error correction \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m methods. Future research is likely to focus on hybrid quantum-classical systems, which combine the strengths of \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m both paradigms to tackle complex problems. \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;4mConclusion\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Quantum computing is advancing at a remarkable pace, with significant developments in hardware, algorithms, and \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m applications. As the field continues to mature, it holds the promise of transforming industries and solving \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m problems that are currently intractable for classical computers. Continued investment in research and \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m development, along with collaboration between academia and industry, will be crucial to realizing the full \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m potential of quantum computing. \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;4mReferences\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[0mIBM Research. (2023). IBM Quantum Roadmap. Retrieved from \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mhttps://research.ibm.com/quantum-computing/roadmap \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0mIonQ. (2023). IonQ's Quantum Computing Technology. Retrieved from https://ionq.com/technology \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0mXanadu. (2023). Borealis: A Photonic Quantum Computer. Retrieved from https://xanadu.ai/borealis \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 4 \u001b[0mPsiQuantum. (2023). Photonic Quantum Computing. Retrieved from https://psiquantum.com/technology \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 5 \u001b[0mBiamonte, J., et al. (2023). Quantum Machine Learning. Nature Reviews Physics. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 6 \u001b[0mFowler, A. G., et al. (2023). Surface Codes: Towards Practical Quantum Computing. Physical Review A. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 7 \u001b[0mAspuru-Guzik, A., et al. (2023). Quantum Simulation of Chemical Systems. Chemical Reviews. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 8 \u001b[0mNIST. (2023). Post-Quantum Cryptography Standardization. Retrieved from \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mhttps://csrc.nist.gov/Projects/post-quantum-cryptography \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 9 \u001b[0mQubit Pharmaceuticals. (2023). Quantum Computing in Drug Discovery. Retrieved from \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mhttps://qubit-pharmaceuticals.com/quantum-computing \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 10 \u001b[0mVenturelli, D., et al. (2023). Quantum Optimization Algorithms. Journal of Quantum Information Processing. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"# Recent Advances in Quantum Computing\n",
|
||||
"\n",
|
||||
"Quantum computing is a rapidly evolving field that leverages the principles of quantum mechanics to process information in fundamentally new ways. This report highlights some of the most significant recent advances in quantum computing, focusing on developments in hardware, algorithms, and applications.\n",
|
||||
"\n",
|
||||
"## 1. Quantum Hardware Developments\n",
|
||||
"\n",
|
||||
"### 1.1 Superconducting Qubits\n",
|
||||
"Superconducting qubits have been at the forefront of quantum computing hardware. Companies like IBM and Google have made significant strides in increasing the coherence times and connectivity of these qubits. In 2023, IBM announced the development of their 433-qubit processor, Osprey, which is part of their roadmap to achieve a 1,000-qubit system by 2024 [1].\n",
|
||||
"\n",
|
||||
"### 1.2 Trapped Ion Qubits\n",
|
||||
"Trapped ion technology continues to be a strong contender due to its high fidelity and long coherence times. IonQ, a leader in this space, has developed systems that can execute quantum circuits with high precision. Their recent advancements include the development of error-corrected logical qubits, which are crucial for scalable quantum computing [2].\n",
|
||||
"\n",
|
||||
"### 1.3 Photonic Quantum Computing\n",
|
||||
"Photonic quantum computing has seen breakthroughs with companies like Xanadu and PsiQuantum. Xanadu's Borealis, a photonic quantum computer, demonstrated quantum advantage by solving specific problems faster than classical supercomputers [3]. PsiQuantum is working towards a million-qubit photonic quantum computer, leveraging silicon photonics for scalability [4].\n",
|
||||
"\n",
|
||||
"## 2. Quantum Algorithms\n",
|
||||
"\n",
|
||||
"### 2.1 Quantum Machine Learning\n",
|
||||
"Quantum machine learning (QML) is gaining traction as researchers develop algorithms that could outperform classical counterparts. Recent work has focused on hybrid quantum-classical algorithms that leverage quantum speedups for specific tasks like clustering and classification [5].\n",
|
||||
"\n",
|
||||
"### 2.2 Quantum Error Correction\n",
|
||||
"Error correction remains a critical challenge in quantum computing. Recent advances include the development of more efficient error-correcting codes and fault-tolerant architectures. The surface code, a leading error correction method, has seen improvements in its threshold and resource requirements [6].\n",
|
||||
"\n",
|
||||
"### 2.3 Quantum Simulation\n",
|
||||
"Quantum simulation is one of the most promising applications of quantum computing. Recent studies have demonstrated the simulation of complex quantum systems, such as chemical reactions and material properties, with unprecedented accuracy [7].\n",
|
||||
"\n",
|
||||
"## 3. Applications and Industry Impact\n",
|
||||
"\n",
|
||||
"### 3.1 Cryptography\n",
|
||||
"Quantum computing poses both threats and opportunities for cryptography. The development of quantum-resistant algorithms is crucial as quantum computers could potentially break widely used encryption methods. The National Institute of Standards and Technology (NIST) is in the process of standardizing post-quantum cryptographic algorithms [8].\n",
|
||||
"\n",
|
||||
"### 3.2 Drug Discovery\n",
|
||||
"Quantum computing is poised to revolutionize drug discovery by enabling the simulation of molecular interactions at a quantum level. Companies like Qubit Pharmaceuticals and Cambridge Quantum Computing are actively working on quantum algorithms for drug discovery, promising faster and more accurate predictions [9].\n",
|
||||
"\n",
|
||||
"### 3.3 Optimization Problems\n",
|
||||
"Quantum computers have the potential to solve complex optimization problems more efficiently than classical computers. This has significant implications for industries such as logistics, finance, and manufacturing. Recent advances include the development of quantum algorithms for portfolio optimization and supply chain management [10].\n",
|
||||
"\n",
|
||||
"## 4. Challenges and Future Directions\n",
|
||||
"\n",
|
||||
"Despite the rapid progress, several challenges remain in the field of quantum computing. These include improving qubit coherence times, scaling up the number of qubits, and developing robust error correction methods. Future research is likely to focus on hybrid quantum-classical systems, which combine the strengths of both paradigms to tackle complex problems.\n",
|
||||
"\n",
|
||||
"## Conclusion\n",
|
||||
"\n",
|
||||
"Quantum computing is advancing at a remarkable pace, with significant developments in hardware, algorithms, and applications. As the field continues to mature, it holds the promise of transforming industries and solving problems that are currently intractable for classical computers. Continued investment in research and development, along with collaboration between academia and industry, will be crucial to realizing the full potential of quantum computing.\n",
|
||||
"\n",
|
||||
"## References\n",
|
||||
"\n",
|
||||
"1. IBM Research. (2023). IBM Quantum Roadmap. Retrieved from https://research.ibm.com/quantum-computing/roadmap\n",
|
||||
"2. IonQ. (2023). IonQ's Quantum Computing Technology. Retrieved from https://ionq.com/technology\n",
|
||||
"3. Xanadu. (2023). Borealis: A Photonic Quantum Computer. Retrieved from https://xanadu.ai/borealis\n",
|
||||
"4. PsiQuantum. (2023). Photonic Quantum Computing. Retrieved from https://psiquantum.com/technology\n",
|
||||
"5. Biamonte, J., et al. (2023). Quantum Machine Learning. Nature Reviews Physics.\n",
|
||||
"6. Fowler, A. G., et al. (2023). Surface Codes: Towards Practical Quantum Computing. Physical Review A.\n",
|
||||
"7. Aspuru-Guzik, A., et al. (2023). Quantum Simulation of Chemical Systems. Chemical Reviews.\n",
|
||||
"8. NIST. (2023). Post-Quantum Cryptography Standardization. Retrieved from https://csrc.nist.gov/Projects/post-quantum-cryptography\n",
|
||||
"9. Qubit Pharmaceuticals. (2023). Quantum Computing in Drug Discovery. Retrieved from https://qubit-pharmaceuticals.com/quantum-computing\n",
|
||||
"10. Venturelli, D., et al. (2023). Quantum Optimization Algorithms. Journal of Quantum Information Processing.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from praisonaiagents import Agent\n",
|
||||
"\n",
|
||||
"# User input (for demo, hardcoded; in real use, use input() or widgets)\n",
|
||||
"topic = \"Recent advances in quantum computing\"\n",
|
||||
"\n",
|
||||
"# Use the custom tool\n",
|
||||
"tool = DummyDeepResearchTool(topic)\n",
|
||||
"dummy_report = tool.research()\n",
|
||||
"\n",
|
||||
"if not is_valid_key(OPENAI_API_KEY, \"sk\"):\n",
|
||||
" print(\"API key not set or is a placeholder. Using dummy research report for CI/testing.\")\n",
|
||||
" print(dummy_report)\n",
|
||||
"else:\n",
|
||||
" prompt = f\"\"\"\n",
|
||||
" You are a domain research assistant. Perform deep research on the following topic and provide a structured, well-cited report:\n",
|
||||
" TOPIC: {topic}\n",
|
||||
" \"\"\"\n",
|
||||
" agent = Agent(\n",
|
||||
" name=\"Domain Deep Research Agent\",\n",
|
||||
" instructions=prompt,\n",
|
||||
" api_key=OPENAI_API_KEY\n",
|
||||
" )\n",
|
||||
" report = agent.start(prompt)\n",
|
||||
" print(report)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"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,922 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "uJ93P7ksa2Nn"
|
||||
},
|
||||
"source": [
|
||||
"# Local RAG Document Agent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "vxe5gDW0a4pC"
|
||||
},
|
||||
"source": [
|
||||
"* A Retrieval-Augmented Generation agent that uses local models and vector databases for document-based question answering.\n",
|
||||
"* The agent can process PDF documents, extract knowledge, and answer questions using local LLM inference without external API calls.\n",
|
||||
"* Features include document upload, vector embedding, similarity search, and intelligent Q&A with source attribution and context awareness."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "K3HdvvEid5wP"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/local_rag_document_qa_agent.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "xaXT3inobISk"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "VBIlMa0vbBWm"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonai streamlit qdrant-client ollama pypdf PyPDF2 chromadb sentence-transformers"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "FttFP60zb30i"
|
||||
},
|
||||
"source": [
|
||||
"# Setup Key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "smr-FEPhb3Yx",
|
||||
"outputId": "526779e1-94ed-46f9-9288-6d9ee5b25a19"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"✅ API key configured!\n",
|
||||
"✅ Using local Ollama models for RAG operations\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Setup Key\n",
|
||||
"import os\n",
|
||||
"openai_key = \"sk-..\"\n",
|
||||
"\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = openai_key\n",
|
||||
"\n",
|
||||
"# Ollama setup (for local models)\n",
|
||||
"# Make sure Ollama is installed and running locally\n",
|
||||
"# Available models: llama3.2, llama3.1, mistral, codellama, etc.\n",
|
||||
"\n",
|
||||
"print(\"✅ API key configured!\")\n",
|
||||
"print(\"✅ Using local Ollama models for RAG operations\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "4hEC_bn1cGOH"
|
||||
},
|
||||
"source": [
|
||||
"# Tools"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {
|
||||
"id": "bXEhVTwocH1J"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Custom Document Processing Tool\n",
|
||||
"import PyPDF2\n",
|
||||
"import tempfile\n",
|
||||
"import os\n",
|
||||
"from typing import Dict, Any, List\n",
|
||||
"import pandas as pd\n",
|
||||
"\n",
|
||||
"class DocumentProcessingTool:\n",
|
||||
" def __init__(self):\n",
|
||||
" self.supported_formats = ['.pdf', '.txt', '.md', '.csv']\n",
|
||||
"\n",
|
||||
" def process_document(self, file_path: str) -> Dict[str, Any]:\n",
|
||||
" \"\"\"Process different document formats and extract text\"\"\"\n",
|
||||
" try:\n",
|
||||
" file_ext = os.path.splitext(file_path)[1].lower()\n",
|
||||
"\n",
|
||||
" if file_ext == '.pdf':\n",
|
||||
" return self._process_pdf(file_path)\n",
|
||||
" elif file_ext == '.txt':\n",
|
||||
" return self._process_txt(file_path)\n",
|
||||
" elif file_ext == '.md':\n",
|
||||
" return self._process_md(file_path)\n",
|
||||
" elif file_ext == '.csv':\n",
|
||||
" return self._process_csv(file_path)\n",
|
||||
" else:\n",
|
||||
" return {\"error\": f\"Unsupported file format: {file_ext}\"}\n",
|
||||
" except Exception as e:\n",
|
||||
" return {\"error\": f\"Error processing document: {str(e)}\"}\n",
|
||||
"\n",
|
||||
" def _process_pdf(self, file_path: str) -> Dict[str, Any]:\n",
|
||||
" \"\"\"Process PDF files\"\"\"\n",
|
||||
" try:\n",
|
||||
" with open(file_path, 'rb') as file:\n",
|
||||
" pdf_reader = PyPDF2.PdfReader(file)\n",
|
||||
" text = \"\"\n",
|
||||
" for page in pdf_reader.pages:\n",
|
||||
" text += page.extract_text() + \"\\n\"\n",
|
||||
"\n",
|
||||
" return {\n",
|
||||
" \"text\": text,\n",
|
||||
" \"pages\": len(pdf_reader.pages),\n",
|
||||
" \"format\": \"pdf\",\n",
|
||||
" \"file_path\": file_path\n",
|
||||
" }\n",
|
||||
" except Exception as e:\n",
|
||||
" return {\"error\": f\"PDF processing error: {str(e)}\"}\n",
|
||||
"\n",
|
||||
" def _process_txt(self, file_path: str) -> Dict[str, Any]:\n",
|
||||
" \"\"\"Process text files\"\"\"\n",
|
||||
" try:\n",
|
||||
" with open(file_path, 'r', encoding='utf-8') as file:\n",
|
||||
" text = file.read()\n",
|
||||
"\n",
|
||||
" return {\n",
|
||||
" \"text\": text,\n",
|
||||
" \"format\": \"txt\",\n",
|
||||
" \"file_path\": file_path\n",
|
||||
" }\n",
|
||||
" except Exception as e:\n",
|
||||
" return {\"error\": f\"Text processing error: {str(e)}\"}\n",
|
||||
"\n",
|
||||
" def _process_md(self, file_path: str) -> Dict[str, Any]:\n",
|
||||
" \"\"\"Process markdown files\"\"\"\n",
|
||||
" try:\n",
|
||||
" with open(file_path, 'r', encoding='utf-8') as file:\n",
|
||||
" text = file.read()\n",
|
||||
"\n",
|
||||
" return {\n",
|
||||
" \"text\": text,\n",
|
||||
" \"format\": \"md\",\n",
|
||||
" \"file_path\": file_path\n",
|
||||
" }\n",
|
||||
" except Exception as e:\n",
|
||||
" return {\"error\": f\"Markdown processing error: {str(e)}\"}\n",
|
||||
"\n",
|
||||
" def _process_csv(self, file_path: str) -> Dict[str, Any]:\n",
|
||||
" \"\"\"Process CSV files\"\"\"\n",
|
||||
" try:\n",
|
||||
" df = pd.read_csv(file_path)\n",
|
||||
" text = df.to_string(index=False)\n",
|
||||
"\n",
|
||||
" return {\n",
|
||||
" \"text\": text,\n",
|
||||
" \"format\": \"csv\",\n",
|
||||
" \"rows\": len(df),\n",
|
||||
" \"columns\": len(df.columns),\n",
|
||||
" \"file_path\": file_path\n",
|
||||
" }\n",
|
||||
" except Exception as e:\n",
|
||||
" return {\"error\": f\"CSV processing error: {str(e)}\"}\n",
|
||||
"\n",
|
||||
"# Custom Vector Database Tool (Fixed for new ChromaDB)\n",
|
||||
"import chromadb\n",
|
||||
"import numpy as np\n",
|
||||
"\n",
|
||||
"class VectorDatabaseTool:\n",
|
||||
" def __init__(self, collection_name: str = \"document_qa\"):\n",
|
||||
" self.collection_name = collection_name\n",
|
||||
" # Use new ChromaDB client configuration\n",
|
||||
" self.client = chromadb.PersistentClient(path=\"./chroma_db\")\n",
|
||||
" self.collection = self.client.get_or_create_collection(name=collection_name)\n",
|
||||
"\n",
|
||||
" def add_documents(self, documents: List[str], metadatas: List[Dict] = None, ids: List[str] = None) -> Dict[str, Any]:\n",
|
||||
" \"\"\"Add documents to the vector database\"\"\"\n",
|
||||
" try:\n",
|
||||
" if ids is None:\n",
|
||||
" ids = [f\"doc_{i}\" for i in range(len(documents))]\n",
|
||||
" if metadatas is None:\n",
|
||||
" metadatas = [{\"source\": f\"document_{i}\"} for i in range(len(documents))]\n",
|
||||
"\n",
|
||||
" self.collection.add(\n",
|
||||
" documents=documents,\n",
|
||||
" metadatas=metadatas,\n",
|
||||
" ids=ids\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" return {\n",
|
||||
" \"success\": True,\n",
|
||||
" \"documents_added\": len(documents),\n",
|
||||
" \"collection_name\": self.collection_name\n",
|
||||
" }\n",
|
||||
" except Exception as e:\n",
|
||||
" return {\"error\": f\"Error adding documents: {str(e)}\"}\n",
|
||||
"\n",
|
||||
" def search_documents(self, query: str, n_results: int = 5) -> Dict[str, Any]:\n",
|
||||
" \"\"\"Search for relevant documents\"\"\"\n",
|
||||
" try:\n",
|
||||
" results = self.collection.query(\n",
|
||||
" query_texts=[query],\n",
|
||||
" n_results=n_results\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" return {\n",
|
||||
" \"success\": True,\n",
|
||||
" \"query\": query,\n",
|
||||
" \"results\": results,\n",
|
||||
" \"num_results\": len(results['documents'][0]) if results['documents'] else 0\n",
|
||||
" }\n",
|
||||
" except Exception as e:\n",
|
||||
" return {\"error\": f\"Error searching documents: {str(e)}\"}\n",
|
||||
"\n",
|
||||
" def get_collection_info(self) -> Dict[str, Any]:\n",
|
||||
" \"\"\"Get information about the collection\"\"\"\n",
|
||||
" try:\n",
|
||||
" count = self.collection.count()\n",
|
||||
" return {\n",
|
||||
" \"success\": True,\n",
|
||||
" \"collection_name\": self.collection_name,\n",
|
||||
" \"document_count\": count\n",
|
||||
" }\n",
|
||||
" except Exception as e:\n",
|
||||
" return {\"error\": f\"Error getting collection info: {str(e)}\"}\n",
|
||||
"\n",
|
||||
"# Custom Text Chunking Tool\n",
|
||||
"import re\n",
|
||||
"from typing import List\n",
|
||||
"\n",
|
||||
"class TextChunkingTool:\n",
|
||||
" def __init__(self, chunk_size: int = 1000, chunk_overlap: int = 200):\n",
|
||||
" self.chunk_size = chunk_size\n",
|
||||
" self.chunk_overlap = chunk_overlap\n",
|
||||
"\n",
|
||||
" def chunk_text(self, text: str) -> List[str]:\n",
|
||||
" \"\"\"Split text into overlapping chunks\"\"\"\n",
|
||||
" try:\n",
|
||||
" # Clean the text\n",
|
||||
" text = re.sub(r'\\s+', ' ', text).strip()\n",
|
||||
"\n",
|
||||
" # Split into sentences first\n",
|
||||
" sentences = re.split(r'[.!?]+', text)\n",
|
||||
" sentences = [s.strip() for s in sentences if s.strip()]\n",
|
||||
"\n",
|
||||
" chunks = []\n",
|
||||
" current_chunk = \"\"\n",
|
||||
"\n",
|
||||
" for sentence in sentences:\n",
|
||||
" # If adding this sentence would exceed chunk size\n",
|
||||
" if len(current_chunk) + len(sentence) > self.chunk_size and current_chunk:\n",
|
||||
" chunks.append(current_chunk.strip())\n",
|
||||
" # Start new chunk with overlap\n",
|
||||
" overlap_start = max(0, len(current_chunk) - self.chunk_overlap)\n",
|
||||
" current_chunk = current_chunk[overlap_start:] + \" \" + sentence\n",
|
||||
" else:\n",
|
||||
" current_chunk += \" \" + sentence if current_chunk else sentence\n",
|
||||
"\n",
|
||||
" # Add the last chunk\n",
|
||||
" if current_chunk:\n",
|
||||
" chunks.append(current_chunk.strip())\n",
|
||||
"\n",
|
||||
" return chunks\n",
|
||||
" except Exception as e:\n",
|
||||
" return [f\"Error chunking text: {str(e)}\"]\n",
|
||||
"\n",
|
||||
" def chunk_text_by_paragraphs(self, text: str) -> List[str]:\n",
|
||||
" \"\"\"Split text by paragraphs\"\"\"\n",
|
||||
" try:\n",
|
||||
" paragraphs = text.split('\\n\\n')\n",
|
||||
" chunks = []\n",
|
||||
"\n",
|
||||
" for paragraph in paragraphs:\n",
|
||||
" paragraph = paragraph.strip()\n",
|
||||
" if paragraph:\n",
|
||||
" # If paragraph is too long, split it further\n",
|
||||
" if len(paragraph) > self.chunk_size:\n",
|
||||
" sub_chunks = self.chunk_text(paragraph)\n",
|
||||
" chunks.extend(sub_chunks)\n",
|
||||
" else:\n",
|
||||
" chunks.append(paragraph)\n",
|
||||
"\n",
|
||||
" return chunks\n",
|
||||
" except Exception as e:\n",
|
||||
" return [f\"Error chunking paragraphs: {str(e)}\"]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "vuE2noGJc5UM"
|
||||
},
|
||||
"source": [
|
||||
"# YAML Prompt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "9okcME5dc6g5",
|
||||
"outputId": "04372512-a187-4db2-e578-d6964b9b0ee7"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"✅ YAML Prompt configured!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# YAML Prompt\n",
|
||||
"yaml_prompt = \"\"\"\n",
|
||||
"name: \"Local RAG Document Agent\"\n",
|
||||
"description: \"Expert document analyst with local LLM capabilities and vector search\"\n",
|
||||
"instructions:\n",
|
||||
" - \"You are an expert document analyst that processes and analyzes documents using local LLM models\"\n",
|
||||
" - \"Use vector database search to find relevant document chunks for answering questions\"\n",
|
||||
" - \"Process uploaded documents and extract meaningful information\"\n",
|
||||
" - \"Provide accurate answers based on document content with source attribution\"\n",
|
||||
" - \"Chunk documents appropriately for optimal vector search performance\"\n",
|
||||
" - \"Always cite the source document when providing answers\"\n",
|
||||
" - \"Use markdown formatting for better readability\"\n",
|
||||
" - \"Handle multiple document formats (PDF, TXT, MD, CSV)\"\n",
|
||||
" - \"Provide context-aware responses based on document content\"\n",
|
||||
"\n",
|
||||
"tools:\n",
|
||||
" - name: \"DocumentProcessingTool\"\n",
|
||||
" description: \"Processes different document formats (PDF, TXT, MD, CSV) and extracts text content\"\n",
|
||||
" - name: \"VectorDatabaseTool\"\n",
|
||||
" description: \"Manages vector database operations for document storage and similarity search\"\n",
|
||||
" - name: \"TextChunkingTool\"\n",
|
||||
" description: \"Splits text into appropriate chunks for vector embedding and retrieval\"\n",
|
||||
"\n",
|
||||
"output_format:\n",
|
||||
" - \"Provide clear, document-based answers\"\n",
|
||||
" - \"Include source attribution when possible\"\n",
|
||||
" - \"Summarize key information from documents\"\n",
|
||||
" - \"Suggest follow-up questions if relevant\"\n",
|
||||
" - \"Use bullet points and structured formatting\"\n",
|
||||
" - \"Highlight important findings from the documents\"\n",
|
||||
"\n",
|
||||
"temperature: 0.3\n",
|
||||
"max_tokens: 4000\n",
|
||||
"model: \"local-llama3.2\"\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"print(\"✅ YAML Prompt configured!\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "fF-XYF0UdEnT"
|
||||
},
|
||||
"source": [
|
||||
"# Main"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000
|
||||
},
|
||||
"id": "AoZrQUyLdGCT",
|
||||
"outputId": "069a3115-b6c0-4111-b1ca-080466048f30"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"�� Local RAG Document Agent\n",
|
||||
"Document-based Q&A powered by local LLM and vector search!\n",
|
||||
"\n",
|
||||
"📁 Upload Your Documents\n",
|
||||
"Please upload PDF, TXT, MD, or CSV files:\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"\n",
|
||||
" <input type=\"file\" id=\"files-bc658477-fb0b-4b0b-a549-501485fe7cab\" name=\"files[]\" multiple disabled\n",
|
||||
" style=\"border:none\" />\n",
|
||||
" <output id=\"result-bc658477-fb0b-4b0b-a549-501485fe7cab\">\n",
|
||||
" Upload widget is only available when the cell has been executed in the\n",
|
||||
" current browser session. Please rerun this cell to enable.\n",
|
||||
" </output>\n",
|
||||
" <script>// Copyright 2017 Google LLC\n",
|
||||
"//\n",
|
||||
"// Licensed under the Apache License, Version 2.0 (the \"License\");\n",
|
||||
"// you may not use this file except in compliance with the License.\n",
|
||||
"// You may obtain a copy of the License at\n",
|
||||
"//\n",
|
||||
"// http://www.apache.org/licenses/LICENSE-2.0\n",
|
||||
"//\n",
|
||||
"// Unless required by applicable law or agreed to in writing, software\n",
|
||||
"// distributed under the License is distributed on an \"AS IS\" BASIS,\n",
|
||||
"// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
|
||||
"// See the License for the specific language governing permissions and\n",
|
||||
"// limitations under the License.\n",
|
||||
"\n",
|
||||
"/**\n",
|
||||
" * @fileoverview Helpers for google.colab Python module.\n",
|
||||
" */\n",
|
||||
"(function(scope) {\n",
|
||||
"function span(text, styleAttributes = {}) {\n",
|
||||
" const element = document.createElement('span');\n",
|
||||
" element.textContent = text;\n",
|
||||
" for (const key of Object.keys(styleAttributes)) {\n",
|
||||
" element.style[key] = styleAttributes[key];\n",
|
||||
" }\n",
|
||||
" return element;\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"// Max number of bytes which will be uploaded at a time.\n",
|
||||
"const MAX_PAYLOAD_SIZE = 100 * 1024;\n",
|
||||
"\n",
|
||||
"function _uploadFiles(inputId, outputId) {\n",
|
||||
" const steps = uploadFilesStep(inputId, outputId);\n",
|
||||
" const outputElement = document.getElementById(outputId);\n",
|
||||
" // Cache steps on the outputElement to make it available for the next call\n",
|
||||
" // to uploadFilesContinue from Python.\n",
|
||||
" outputElement.steps = steps;\n",
|
||||
"\n",
|
||||
" return _uploadFilesContinue(outputId);\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"// This is roughly an async generator (not supported in the browser yet),\n",
|
||||
"// where there are multiple asynchronous steps and the Python side is going\n",
|
||||
"// to poll for completion of each step.\n",
|
||||
"// This uses a Promise to block the python side on completion of each step,\n",
|
||||
"// then passes the result of the previous step as the input to the next step.\n",
|
||||
"function _uploadFilesContinue(outputId) {\n",
|
||||
" const outputElement = document.getElementById(outputId);\n",
|
||||
" const steps = outputElement.steps;\n",
|
||||
"\n",
|
||||
" const next = steps.next(outputElement.lastPromiseValue);\n",
|
||||
" return Promise.resolve(next.value.promise).then((value) => {\n",
|
||||
" // Cache the last promise value to make it available to the next\n",
|
||||
" // step of the generator.\n",
|
||||
" outputElement.lastPromiseValue = value;\n",
|
||||
" return next.value.response;\n",
|
||||
" });\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"/**\n",
|
||||
" * Generator function which is called between each async step of the upload\n",
|
||||
" * process.\n",
|
||||
" * @param {string} inputId Element ID of the input file picker element.\n",
|
||||
" * @param {string} outputId Element ID of the output display.\n",
|
||||
" * @return {!Iterable<!Object>} Iterable of next steps.\n",
|
||||
" */\n",
|
||||
"function* uploadFilesStep(inputId, outputId) {\n",
|
||||
" const inputElement = document.getElementById(inputId);\n",
|
||||
" inputElement.disabled = false;\n",
|
||||
"\n",
|
||||
" const outputElement = document.getElementById(outputId);\n",
|
||||
" outputElement.innerHTML = '';\n",
|
||||
"\n",
|
||||
" const pickedPromise = new Promise((resolve) => {\n",
|
||||
" inputElement.addEventListener('change', (e) => {\n",
|
||||
" resolve(e.target.files);\n",
|
||||
" });\n",
|
||||
" });\n",
|
||||
"\n",
|
||||
" const cancel = document.createElement('button');\n",
|
||||
" inputElement.parentElement.appendChild(cancel);\n",
|
||||
" cancel.textContent = 'Cancel upload';\n",
|
||||
" const cancelPromise = new Promise((resolve) => {\n",
|
||||
" cancel.onclick = () => {\n",
|
||||
" resolve(null);\n",
|
||||
" };\n",
|
||||
" });\n",
|
||||
"\n",
|
||||
" // Wait for the user to pick the files.\n",
|
||||
" const files = yield {\n",
|
||||
" promise: Promise.race([pickedPromise, cancelPromise]),\n",
|
||||
" response: {\n",
|
||||
" action: 'starting',\n",
|
||||
" }\n",
|
||||
" };\n",
|
||||
"\n",
|
||||
" cancel.remove();\n",
|
||||
"\n",
|
||||
" // Disable the input element since further picks are not allowed.\n",
|
||||
" inputElement.disabled = true;\n",
|
||||
"\n",
|
||||
" if (!files) {\n",
|
||||
" return {\n",
|
||||
" response: {\n",
|
||||
" action: 'complete',\n",
|
||||
" }\n",
|
||||
" };\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" for (const file of files) {\n",
|
||||
" const li = document.createElement('li');\n",
|
||||
" li.append(span(file.name, {fontWeight: 'bold'}));\n",
|
||||
" li.append(span(\n",
|
||||
" `(${file.type || 'n/a'}) - ${file.size} bytes, ` +\n",
|
||||
" `last modified: ${\n",
|
||||
" file.lastModifiedDate ? file.lastModifiedDate.toLocaleDateString() :\n",
|
||||
" 'n/a'} - `));\n",
|
||||
" const percent = span('0% done');\n",
|
||||
" li.appendChild(percent);\n",
|
||||
"\n",
|
||||
" outputElement.appendChild(li);\n",
|
||||
"\n",
|
||||
" const fileDataPromise = new Promise((resolve) => {\n",
|
||||
" const reader = new FileReader();\n",
|
||||
" reader.onload = (e) => {\n",
|
||||
" resolve(e.target.result);\n",
|
||||
" };\n",
|
||||
" reader.readAsArrayBuffer(file);\n",
|
||||
" });\n",
|
||||
" // Wait for the data to be ready.\n",
|
||||
" let fileData = yield {\n",
|
||||
" promise: fileDataPromise,\n",
|
||||
" response: {\n",
|
||||
" action: 'continue',\n",
|
||||
" }\n",
|
||||
" };\n",
|
||||
"\n",
|
||||
" // Use a chunked sending to avoid message size limits. See b/62115660.\n",
|
||||
" let position = 0;\n",
|
||||
" do {\n",
|
||||
" const length = Math.min(fileData.byteLength - position, MAX_PAYLOAD_SIZE);\n",
|
||||
" const chunk = new Uint8Array(fileData, position, length);\n",
|
||||
" position += length;\n",
|
||||
"\n",
|
||||
" const base64 = btoa(String.fromCharCode.apply(null, chunk));\n",
|
||||
" yield {\n",
|
||||
" response: {\n",
|
||||
" action: 'append',\n",
|
||||
" file: file.name,\n",
|
||||
" data: base64,\n",
|
||||
" },\n",
|
||||
" };\n",
|
||||
"\n",
|
||||
" let percentDone = fileData.byteLength === 0 ?\n",
|
||||
" 100 :\n",
|
||||
" Math.round((position / fileData.byteLength) * 100);\n",
|
||||
" percent.textContent = `${percentDone}% done`;\n",
|
||||
"\n",
|
||||
" } while (position < fileData.byteLength);\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" // All done.\n",
|
||||
" yield {\n",
|
||||
" response: {\n",
|
||||
" action: 'complete',\n",
|
||||
" }\n",
|
||||
" };\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"scope.google = scope.google || {};\n",
|
||||
"scope.google.colab = scope.google.colab || {};\n",
|
||||
"scope.google.colab._files = {\n",
|
||||
" _uploadFiles,\n",
|
||||
" _uploadFilesContinue,\n",
|
||||
"};\n",
|
||||
"})(self);\n",
|
||||
"</script> "
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.HTML object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Saving customers-100.csv to customers-100.csv\n",
|
||||
"\n",
|
||||
"📄 Processing: customers-100.csv\n",
|
||||
"✅ Successfully processed customers-100.csv\n",
|
||||
" - Format: csv\n",
|
||||
" - Text length: 27875 characters\n",
|
||||
"\n",
|
||||
"�� Processing Summary:\n",
|
||||
"- Total documents processed: 1\n",
|
||||
"\n",
|
||||
"�� Chunking documents for vector storage...\n",
|
||||
"- Total chunks created: 23\n",
|
||||
"\n",
|
||||
"🗄️ Adding documents to vector database...\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/root/.cache/chroma/onnx_models/all-MiniLM-L6-v2/onnx.tar.gz: 100%|██████████| 79.3M/79.3M [00:01<00:00, 70.7MiB/s]\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"✅ Successfully added 23 chunks to vector database\n",
|
||||
"📈 Vector database now contains 23 total chunks\n",
|
||||
"\n",
|
||||
"🤔 Interactive Q&A Session\n",
|
||||
"Ask questions about your documents (type 'quit' to exit):\n",
|
||||
"\n",
|
||||
"❓ Your question: what is that\n",
|
||||
"🔍 Searching for relevant information...\n",
|
||||
"📚 Found 3 relevant chunks:\n",
|
||||
"\n",
|
||||
"--- Chunk 1 ---\n",
|
||||
"Source: /tmp/tmp7yzm_3y4.csv\n",
|
||||
"Format: csv\n",
|
||||
"Content: ank com 2020-03-26 https://www pugh com/ 92 98b3aeDcC3B9FF3 Shane Foley Rocha-Hart South Dannymouth Hungary +1-822-569-0302 001-626-114-5844x55073 nsteele@sparks com 2021-07-06 https://www holt-sparks...\n",
|
||||
"\n",
|
||||
"--- Chunk 2 ---\n",
|
||||
"Source: /tmp/tmp7yzm_3y4.csv\n",
|
||||
"Format: csv\n",
|
||||
"Content: Robersonstad Cyprus 854-138-4911x5772 +1-448-910-2276x729 mariokhan@ryan-pope org 2020-01-13 https://www bullock net/ 10 8C2811a503C7c5a Michelle Gallagher Beck-Hendrix Elaineberg Timor-Leste 739 218 ...\n",
|
||||
"\n",
|
||||
"--- Chunk 3 ---\n",
|
||||
"Source: /tmp/tmp7yzm_3y4.csv\n",
|
||||
"Format: csv\n",
|
||||
"Content: x58692 001-841-293-3519x614 hhart@jensen com 2022-01-30 http://hayes-perez com/ 97 CeD220bdAaCfaDf Lynn Atkinson Ware, Burns and Oneal New Bradview Sri Lanka +1-846-706-2218 605 413 3198 vkemp@ferrell...\n",
|
||||
"\n",
|
||||
"💡 AI Answer (using local LLM):\n",
|
||||
"Based on the document content, here's what I found...\n",
|
||||
"(This would be generated by the local LLM model)\n",
|
||||
"\n",
|
||||
"❓ Your question: how much total text length\n",
|
||||
"🔍 Searching for relevant information...\n",
|
||||
"📚 Found 3 relevant chunks:\n",
|
||||
"\n",
|
||||
"--- Chunk 1 ---\n",
|
||||
"Source: /tmp/tmp7yzm_3y4.csv\n",
|
||||
"Format: csv\n",
|
||||
"Content: 2-13 https://gillespie-holder com/ 44 D3fC11A9C235Dc6 Luis Greer Cross PLC North Drew Bulgaria 001-336-025-6849x701 684 698 2911x6092 bstuart@williamson-mcclure com 2022-05-15 https://fletcher-nielsen...\n",
|
||||
"\n",
|
||||
"--- Chunk 2 ---\n",
|
||||
"Source: /tmp/tmp7yzm_3y4.csv\n",
|
||||
"Format: csv\n",
|
||||
"Content: 3x7288 (203)287-1003x5932 kmercer@wagner com 2020-07-21 http://murray org/ 88 E4Bbcd8AD81fC5f Alison Vargas Vaughn, Watts and Leach East Cristinabury Benin 365-273-8144 053-308-7653x6287 vcantu@norton...\n",
|
||||
"\n",
|
||||
"--- Chunk 3 ---\n",
|
||||
"Source: /tmp/tmp7yzm_3y4.csv\n",
|
||||
"Format: csv\n",
|
||||
"Content: rt com 2021-03-10 http://www benson-roth com/ 18 F8Aa9d6DfcBeeF8 Greg Mata Valentine LLC Lake Leslie Mozambique (701)087-2415 (195)156-1861x26241 jaredjuarez@carroll org 2022-03-26 http://pitts-cherry...\n",
|
||||
"\n",
|
||||
"💡 AI Answer (using local LLM):\n",
|
||||
"Based on the document content, here's what I found...\n",
|
||||
"(This would be generated by the local LLM model)\n",
|
||||
"\n",
|
||||
"❓ Your question: quit\n",
|
||||
"\n",
|
||||
"👋 Q&A session ended.\n",
|
||||
"\n",
|
||||
"🧪 Sample Document for Testing\n",
|
||||
"Creating sample document...\n",
|
||||
"✅ Sample document created!\n",
|
||||
"📄 Sample document content:\n",
|
||||
"\n",
|
||||
"# Sample Document\n",
|
||||
"\n",
|
||||
"This is a sample document for testing the Local RAG Document Agent.\n",
|
||||
"\n",
|
||||
"## Introduction\n",
|
||||
"The Local RAG Document Agent is designed to process and analyze documents using local LLM model...\n",
|
||||
"\n",
|
||||
"==================================================\n",
|
||||
"�� Powered by Local RAG Document Agent | Built with PraisonAI\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Main Application (Google Colab Version)\n",
|
||||
"import streamlit as st\n",
|
||||
"import pandas as pd\n",
|
||||
"import tempfile\n",
|
||||
"import os\n",
|
||||
"from typing import Dict, Any, List\n",
|
||||
"from google.colab import files\n",
|
||||
"import io\n",
|
||||
"\n",
|
||||
"# Initialize tools\n",
|
||||
"doc_tool = DocumentProcessingTool()\n",
|
||||
"vector_tool = VectorDatabaseTool()\n",
|
||||
"chunk_tool = TextChunkingTool()\n",
|
||||
"\n",
|
||||
"print(\"�� Local RAG Document Agent\")\n",
|
||||
"print(\"Document-based Q&A powered by local LLM and vector search!\")\n",
|
||||
"\n",
|
||||
"# Document upload section for Google Colab\n",
|
||||
"print(\"\\n📁 Upload Your Documents\")\n",
|
||||
"print(\"Please upload PDF, TXT, MD, or CSV files:\")\n",
|
||||
"\n",
|
||||
"uploaded = files.upload()\n",
|
||||
"\n",
|
||||
"if uploaded:\n",
|
||||
" # Process each uploaded file\n",
|
||||
" processed_docs = []\n",
|
||||
"\n",
|
||||
" for file_name, file_content in uploaded.items():\n",
|
||||
" print(f\"\\n📄 Processing: {file_name}\")\n",
|
||||
"\n",
|
||||
" # Save file temporarily\n",
|
||||
" with tempfile.NamedTemporaryFile(delete=False, suffix=os.path.splitext(file_name)[1]) as temp_file:\n",
|
||||
" temp_file.write(file_content)\n",
|
||||
" temp_path = temp_file.name\n",
|
||||
"\n",
|
||||
" # Process document\n",
|
||||
" doc_result = doc_tool.process_document(temp_path)\n",
|
||||
"\n",
|
||||
" if \"error\" not in doc_result:\n",
|
||||
" processed_docs.append(doc_result)\n",
|
||||
" print(f\"✅ Successfully processed {file_name}\")\n",
|
||||
" print(f\" - Format: {doc_result.get('format', 'unknown')}\")\n",
|
||||
" print(f\" - Text length: {len(doc_result['text'])} characters\")\n",
|
||||
"\n",
|
||||
" if 'pages' in doc_result:\n",
|
||||
" print(f\" - Pages: {doc_result['pages']}\")\n",
|
||||
" else:\n",
|
||||
" print(f\"❌ Error processing {file_name}: {doc_result['error']}\")\n",
|
||||
"\n",
|
||||
" # Clean up temp file\n",
|
||||
" os.unlink(temp_path)\n",
|
||||
"\n",
|
||||
" if processed_docs:\n",
|
||||
" print(f\"\\n�� Processing Summary:\")\n",
|
||||
" print(f\"- Total documents processed: {len(processed_docs)}\")\n",
|
||||
"\n",
|
||||
" # Chunk documents\n",
|
||||
" print(\"\\n�� Chunking documents for vector storage...\")\n",
|
||||
" all_chunks = []\n",
|
||||
" chunk_metadata = []\n",
|
||||
"\n",
|
||||
" for i, doc in enumerate(processed_docs):\n",
|
||||
" chunks = chunk_tool.chunk_text(doc['text'])\n",
|
||||
" all_chunks.extend(chunks)\n",
|
||||
"\n",
|
||||
" # Create metadata for each chunk\n",
|
||||
" for j, chunk in enumerate(chunks):\n",
|
||||
" chunk_metadata.append({\n",
|
||||
" \"source\": doc.get('file_path', f'document_{i}'),\n",
|
||||
" \"format\": doc.get('format', 'unknown'),\n",
|
||||
" \"chunk_index\": j,\n",
|
||||
" \"total_chunks\": len(chunks)\n",
|
||||
" })\n",
|
||||
"\n",
|
||||
" print(f\"- Total chunks created: {len(all_chunks)}\")\n",
|
||||
"\n",
|
||||
" # Add to vector database\n",
|
||||
" print(\"\\n🗄️ Adding documents to vector database...\")\n",
|
||||
" vector_result = vector_tool.add_documents(all_chunks, chunk_metadata)\n",
|
||||
"\n",
|
||||
" if \"error\" not in vector_result:\n",
|
||||
" print(f\"✅ Successfully added {vector_result['documents_added']} chunks to vector database\")\n",
|
||||
"\n",
|
||||
" # Get collection info\n",
|
||||
" collection_info = vector_tool.get_collection_info()\n",
|
||||
" if \"error\" not in collection_info:\n",
|
||||
" print(f\"📈 Vector database now contains {collection_info['document_count']} total chunks\")\n",
|
||||
"\n",
|
||||
" # Interactive Q&A\n",
|
||||
" print(\"\\n🤔 Interactive Q&A Session\")\n",
|
||||
" print(\"Ask questions about your documents (type 'quit' to exit):\")\n",
|
||||
"\n",
|
||||
" while True:\n",
|
||||
" question = input(\"\\n❓ Your question: \")\n",
|
||||
"\n",
|
||||
" if question.lower() in ['quit', 'exit', 'q']:\n",
|
||||
" break\n",
|
||||
"\n",
|
||||
" if question.strip():\n",
|
||||
" print(\"🔍 Searching for relevant information...\")\n",
|
||||
"\n",
|
||||
" # Search vector database\n",
|
||||
" search_result = vector_tool.search_documents(question, n_results=3)\n",
|
||||
"\n",
|
||||
" if \"error\" not in search_result and search_result['num_results'] > 0:\n",
|
||||
" print(f\"📚 Found {search_result['num_results']} relevant chunks:\")\n",
|
||||
"\n",
|
||||
" for i, (doc, metadata) in enumerate(zip(\n",
|
||||
" search_result['results']['documents'][0],\n",
|
||||
" search_result['results']['metadatas'][0]\n",
|
||||
" )):\n",
|
||||
" print(f\"\\n--- Chunk {i+1} ---\")\n",
|
||||
" print(f\"Source: {metadata.get('source', 'Unknown')}\")\n",
|
||||
" print(f\"Format: {metadata.get('format', 'Unknown')}\")\n",
|
||||
" print(f\"Content: {doc[:200]}...\")\n",
|
||||
"\n",
|
||||
" # Here you would integrate with local LLM for answer generation\n",
|
||||
" print(f\"\\n💡 AI Answer (using local LLM):\")\n",
|
||||
" print(\"Based on the document content, here's what I found...\")\n",
|
||||
" print(\"(This would be generated by the local LLM model)\")\n",
|
||||
"\n",
|
||||
" else:\n",
|
||||
" print(\"❌ No relevant information found in the documents.\")\n",
|
||||
" print(\"Try rephrasing your question or check if the documents contain the information you're looking for.\")\n",
|
||||
" else:\n",
|
||||
" print(\"Please enter a question.\")\n",
|
||||
"\n",
|
||||
" print(\"\\n👋 Q&A session ended.\")\n",
|
||||
"\n",
|
||||
" else:\n",
|
||||
" print(f\"❌ Error adding to vector database: {vector_result['error']}\")\n",
|
||||
"\n",
|
||||
" else:\n",
|
||||
" print(\"❌ No documents were successfully processed.\")\n",
|
||||
"\n",
|
||||
"else:\n",
|
||||
" print(\"❌ No files uploaded. Please upload documents to get started.\")\n",
|
||||
"\n",
|
||||
"# Sample document section\n",
|
||||
"print(\"\\n🧪 Sample Document for Testing\")\n",
|
||||
"print(\"Creating sample document...\")\n",
|
||||
"\n",
|
||||
"# Create sample document\n",
|
||||
"sample_text = \"\"\"\n",
|
||||
"# Sample Document\n",
|
||||
"\n",
|
||||
"This is a sample document for testing the Local RAG Document Agent.\n",
|
||||
"\n",
|
||||
"## Introduction\n",
|
||||
"The Local RAG Document Agent is designed to process and analyze documents using local LLM models and vector search capabilities.\n",
|
||||
"\n",
|
||||
"## Features\n",
|
||||
"- Document processing for multiple formats (PDF, TXT, MD, CSV)\n",
|
||||
"- Vector database storage and retrieval\n",
|
||||
"- Local LLM inference without external API calls\n",
|
||||
"- Intelligent Q&A with source attribution\n",
|
||||
"\n",
|
||||
"## Technical Details\n",
|
||||
"The agent uses ChromaDB for vector storage and Ollama for local LLM inference.\n",
|
||||
"It can handle various document formats and provides context-aware responses.\n",
|
||||
"\n",
|
||||
"## Usage\n",
|
||||
"1. Upload your documents\n",
|
||||
"2. Ask questions about the content\n",
|
||||
"3. Get AI-powered answers with source references\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"# Save sample document\n",
|
||||
"with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.md') as temp_file:\n",
|
||||
" temp_file.write(sample_text)\n",
|
||||
" sample_path = temp_file.name\n",
|
||||
"\n",
|
||||
"print(\"✅ Sample document created!\")\n",
|
||||
"print(\"📄 Sample document content:\")\n",
|
||||
"print(sample_text[:200] + \"...\")\n",
|
||||
"\n",
|
||||
"# Footer\n",
|
||||
"print(\"\\n\" + \"=\"*50)\n",
|
||||
"print(\"�� Powered by Local RAG Document Agent | Built with PraisonAI\")"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,800 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "04dGdK2VftUM"
|
||||
},
|
||||
"source": [
|
||||
"# AI Meme Creator Agent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "xUTYMeY9fvUA"
|
||||
},
|
||||
"source": [
|
||||
"* An AI agent that generates memes using browser automation and multiple LLM models.\n",
|
||||
"* The agent can create custom memes based on user prompts by navigating to meme creation websites, selecting templates, and generating captions.\n",
|
||||
"* Features include multi-model support (Claude, Deepseek, OpenAI), browser automation, template selection, and automatic meme generation with direct image links."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "_hI9XGsJicU8"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/ai_meme_creator_agent.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "6rrl-ZHqgCj2"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "pP9B-OsCgDpr"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonai streamlit browser-use langchain-openai langchain-anthropic langchain-core"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "Xe0_c_lig5YJ"
|
||||
},
|
||||
"source": [
|
||||
"# Setup Key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "fsVpWSVHg64O",
|
||||
"outputId": "74d0ee0f-a3e2-413c-98cd-a410888eedb3"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"✅ API keys configured!\n",
|
||||
"✅ Using model: OpenAI\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"# Set your API keys\n",
|
||||
"openai_key = \"Enter you api key here\"\n",
|
||||
"anthropic_key = \"Enter you api key here\" # Get from https://console.anthropic.com\n",
|
||||
"deepseek_key = \"Enter you api key here\" # Get from https://platform.deepseek.com\n",
|
||||
"\n",
|
||||
"# Set environment variables\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = openai_key\n",
|
||||
"os.environ[\"ANTHROPIC_API_KEY\"] = anthropic_key\n",
|
||||
"os.environ[\"DEEPSEEK_API_KEY\"] = deepseek_key\n",
|
||||
"\n",
|
||||
"# Model selection\n",
|
||||
"model_choice = \"OpenAI\" # Options: \"OpenAI\", \"Claude\", \"Deepseek\"\n",
|
||||
"\n",
|
||||
"print(\"✅ API keys configured!\")\n",
|
||||
"print(f\"✅ Using model: {model_choice}\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "rtqdR4Odhexu"
|
||||
},
|
||||
"source": [
|
||||
"# Tools"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"id": "I9uC9c97hgYg"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Custom Meme Template Search Tool\n",
|
||||
"import requests\n",
|
||||
"from typing import Dict, Any, List\n",
|
||||
"import re\n",
|
||||
"\n",
|
||||
"class MemeTemplateSearchTool:\n",
|
||||
" def __init__(self):\n",
|
||||
" self.base_url = \"https://imgflip.com\"\n",
|
||||
" self.popular_templates = [\n",
|
||||
" \"distracted-boyfriend\", \"two-buttons\", \"one-does-not-simply\",\n",
|
||||
" \"drake-hotline-bling\", \"change-my-mind\", \"ancient-aliens\",\n",
|
||||
" \"y-u-no\", \"success-kid\", \"first-world-problems\", \"futurama-fry\"\n",
|
||||
" ]\n",
|
||||
"\n",
|
||||
" def search_templates(self, query: str) -> Dict[str, Any]:\n",
|
||||
" \"\"\"Search for meme templates based on query\"\"\"\n",
|
||||
" try:\n",
|
||||
" # Extract key action words from query\n",
|
||||
" action_words = self._extract_action_words(query.lower())\n",
|
||||
"\n",
|
||||
" # Find relevant templates\n",
|
||||
" relevant_templates = []\n",
|
||||
" for template in self.popular_templates:\n",
|
||||
" if any(word in template for word in action_words):\n",
|
||||
" relevant_templates.append(template)\n",
|
||||
"\n",
|
||||
" # If no direct matches, return popular templates\n",
|
||||
" if not relevant_templates:\n",
|
||||
" relevant_templates = self.popular_templates[:5]\n",
|
||||
"\n",
|
||||
" return {\n",
|
||||
" \"success\": True,\n",
|
||||
" \"query\": query,\n",
|
||||
" \"action_words\": action_words,\n",
|
||||
" \"suggested_templates\": relevant_templates,\n",
|
||||
" \"template_urls\": [f\"{self.base_url}/{template}\" for template in relevant_templates]\n",
|
||||
" }\n",
|
||||
" except Exception as e:\n",
|
||||
" return {\"error\": f\"Error searching templates: {str(e)}\"}\n",
|
||||
"\n",
|
||||
" def _extract_action_words(self, text: str) -> List[str]:\n",
|
||||
" \"\"\"Extract action words from text\"\"\"\n",
|
||||
" action_words = [\n",
|
||||
" \"laugh\", \"cry\", \"smile\", \"angry\", \"surprised\", \"confused\",\n",
|
||||
" \"happy\", \"sad\", \"excited\", \"worried\", \"thinking\", \"shocked\",\n",
|
||||
" \"bully\", \"fight\", \"work\", \"study\", \"sleep\", \"eat\", \"drink\",\n",
|
||||
" \"run\", \"walk\", \"sit\", \"stand\", \"look\", \"watch\", \"listen\"\n",
|
||||
" ]\n",
|
||||
"\n",
|
||||
" found_words = []\n",
|
||||
" for word in action_words:\n",
|
||||
" if word in text:\n",
|
||||
" found_words.append(word)\n",
|
||||
"\n",
|
||||
" return found_words\n",
|
||||
"\n",
|
||||
"# Custom Caption Generator Tool\n",
|
||||
"import random\n",
|
||||
"\n",
|
||||
"class CaptionGeneratorTool:\n",
|
||||
" def __init__(self):\n",
|
||||
" self.caption_styles = {\n",
|
||||
" \"setup_punchline\": \"Top: {setup}\\nBottom: {punchline}\",\n",
|
||||
" \"comparison\": \"Top: {option1}\\nBottom: {option2}\",\n",
|
||||
" \"reaction\": \"Top: {situation}\\nBottom: {reaction}\",\n",
|
||||
" \"confession\": \"Top: {confession}\\nBottom: {reality}\"\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" def generate_captions(self, query: str, template: str) -> Dict[str, Any]:\n",
|
||||
" \"\"\"Generate meme captions based on query and template\"\"\"\n",
|
||||
" try:\n",
|
||||
" # Analyze query for meme type\n",
|
||||
" meme_type = self._analyze_meme_type(query)\n",
|
||||
"\n",
|
||||
" # Generate captions based on type\n",
|
||||
" if meme_type == \"comparison\":\n",
|
||||
" captions = self._generate_comparison_captions(query)\n",
|
||||
" elif meme_type == \"reaction\":\n",
|
||||
" captions = self._generate_reaction_captions(query)\n",
|
||||
" elif meme_type == \"confession\":\n",
|
||||
" captions = self._generate_confession_captions(query)\n",
|
||||
" else:\n",
|
||||
" captions = self._generate_setup_punchline_captions(query)\n",
|
||||
"\n",
|
||||
" return {\n",
|
||||
" \"success\": True,\n",
|
||||
" \"query\": query,\n",
|
||||
" \"template\": template,\n",
|
||||
" \"meme_type\": meme_type,\n",
|
||||
" \"captions\": captions,\n",
|
||||
" \"suggested_style\": self.caption_styles.get(meme_type, self.caption_styles[\"setup_punchline\"])\n",
|
||||
" }\n",
|
||||
" except Exception as e:\n",
|
||||
" return {\"error\": f\"Error generating captions: {str(e)}\"}\n",
|
||||
"\n",
|
||||
" def _analyze_meme_type(self, query: str) -> str:\n",
|
||||
" \"\"\"Analyze query to determine meme type\"\"\"\n",
|
||||
" query_lower = query.lower()\n",
|
||||
"\n",
|
||||
" if any(word in query_lower for word in [\"vs\", \"versus\", \"or\", \"either\", \"choose\"]):\n",
|
||||
" return \"comparison\"\n",
|
||||
" elif any(word in query_lower for word in [\"when\", \"reaction\", \"face\", \"look\"]):\n",
|
||||
" return \"reaction\"\n",
|
||||
" elif any(word in query_lower for word in [\"confess\", \"secret\", \"actually\", \"truth\"]):\n",
|
||||
" return \"confession\"\n",
|
||||
" else:\n",
|
||||
" return \"setup_punchline\"\n",
|
||||
"\n",
|
||||
" def _generate_setup_punchline_captions(self, query: str) -> List[Dict[str, str]]:\n",
|
||||
" \"\"\"Generate setup-punchline style captions\"\"\"\n",
|
||||
" captions = []\n",
|
||||
"\n",
|
||||
" # Extract key elements from query\n",
|
||||
" words = query.split()\n",
|
||||
" if len(words) >= 3:\n",
|
||||
" # Create variations\n",
|
||||
" captions.append({\n",
|
||||
" \"top\": f\"When {query}\",\n",
|
||||
" \"bottom\": \"But it actually works\"\n",
|
||||
" })\n",
|
||||
" captions.append({\n",
|
||||
" \"top\": f\"Me trying to {query}\",\n",
|
||||
" \"bottom\": \"Reality: Complete failure\"\n",
|
||||
" })\n",
|
||||
" captions.append({\n",
|
||||
" \"top\": f\"Everyone: {query}\",\n",
|
||||
" \"bottom\": \"Me: *confused*\"\n",
|
||||
" })\n",
|
||||
"\n",
|
||||
" return captions\n",
|
||||
"\n",
|
||||
" def _generate_comparison_captions(self, query: str) -> List[Dict[str, str]]:\n",
|
||||
" \"\"\"Generate comparison style captions\"\"\"\n",
|
||||
" captions = []\n",
|
||||
"\n",
|
||||
" captions.append({\n",
|
||||
" \"top\": \"What I think will happen\",\n",
|
||||
" \"bottom\": \"What actually happens\"\n",
|
||||
" })\n",
|
||||
" captions.append({\n",
|
||||
" \"top\": \"The plan\",\n",
|
||||
" \"bottom\": \"The execution\"\n",
|
||||
" })\n",
|
||||
" captions.append({\n",
|
||||
" \"top\": \"Before\",\n",
|
||||
" \"bottom\": \"After\"\n",
|
||||
" })\n",
|
||||
"\n",
|
||||
" return captions\n",
|
||||
"\n",
|
||||
" def _generate_reaction_captions(self, query: str) -> List[Dict[str, str]]:\n",
|
||||
" \"\"\"Generate reaction style captions\"\"\"\n",
|
||||
" captions = []\n",
|
||||
"\n",
|
||||
" captions.append({\n",
|
||||
" \"top\": f\"When {query}\",\n",
|
||||
" \"bottom\": \"My face: 😱\"\n",
|
||||
" })\n",
|
||||
" captions.append({\n",
|
||||
" \"top\": f\"Me: {query}\",\n",
|
||||
" \"bottom\": \"Also me: *surprised pikachu*\"\n",
|
||||
" })\n",
|
||||
"\n",
|
||||
" return captions\n",
|
||||
"\n",
|
||||
" def _generate_confession_captions(self, query: str) -> List[Dict[str, str]]:\n",
|
||||
" \"\"\"Generate confession style captions\"\"\"\n",
|
||||
" captions = []\n",
|
||||
"\n",
|
||||
" captions.append({\n",
|
||||
" \"top\": f\"I confess: {query}\",\n",
|
||||
" \"bottom\": \"But I'm not sorry\"\n",
|
||||
" })\n",
|
||||
" captions.append({\n",
|
||||
" \"top\": f\"Everyone thinks {query}\",\n",
|
||||
" \"bottom\": \"But actually...\"\n",
|
||||
" })\n",
|
||||
"\n",
|
||||
" return captions\n",
|
||||
"\n",
|
||||
"# Custom Meme Validation Tool\n",
|
||||
"class MemeValidationTool:\n",
|
||||
" def __init__(self):\n",
|
||||
" self.validation_criteria = {\n",
|
||||
" \"humor\": [\"funny\", \"amusing\", \"entertaining\"],\n",
|
||||
" \"relevance\": [\"related\", \"connected\", \"appropriate\"],\n",
|
||||
" \"clarity\": [\"clear\", \"understandable\", \"readable\"],\n",
|
||||
" \"creativity\": [\"original\", \"creative\", \"unique\"]\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" def validate_meme(self, query: str, captions: List[Dict[str, str]], template: str) -> Dict[str, Any]:\n",
|
||||
" \"\"\"Validate meme quality and suggest improvements\"\"\"\n",
|
||||
" try:\n",
|
||||
" scores = {}\n",
|
||||
" suggestions = []\n",
|
||||
"\n",
|
||||
" # Check humor\n",
|
||||
" humor_score = self._check_humor(query, captions)\n",
|
||||
" scores[\"humor\"] = humor_score\n",
|
||||
" if humor_score < 0.7:\n",
|
||||
" suggestions.append(\"Consider making the punchline more unexpected or relatable\")\n",
|
||||
"\n",
|
||||
" # Check relevance\n",
|
||||
" relevance_score = self._check_relevance(query, captions)\n",
|
||||
" scores[\"relevance\"] = relevance_score\n",
|
||||
" if relevance_score < 0.8:\n",
|
||||
" suggestions.append(\"Ensure captions directly relate to the query topic\")\n",
|
||||
"\n",
|
||||
" # Check clarity\n",
|
||||
" clarity_score = self._check_clarity(captions)\n",
|
||||
" scores[\"clarity\"] = clarity_score\n",
|
||||
" if clarity_score < 0.9:\n",
|
||||
" suggestions.append(\"Make sure text is short and easy to read\")\n",
|
||||
"\n",
|
||||
" # Check creativity\n",
|
||||
" creativity_score = self._check_creativity(query, captions)\n",
|
||||
" scores[\"creativity\"] = creativity_score\n",
|
||||
" if creativity_score < 0.6:\n",
|
||||
" suggestions.append(\"Try a more unique angle or unexpected twist\")\n",
|
||||
"\n",
|
||||
" # Overall score\n",
|
||||
" overall_score = sum(scores.values()) / len(scores)\n",
|
||||
"\n",
|
||||
" return {\n",
|
||||
" \"success\": True,\n",
|
||||
" \"scores\": scores,\n",
|
||||
" \"overall_score\": overall_score,\n",
|
||||
" \"suggestions\": suggestions,\n",
|
||||
" \"quality\": \"Excellent\" if overall_score >= 0.8 else \"Good\" if overall_score >= 0.6 else \"Needs Improvement\"\n",
|
||||
" }\n",
|
||||
" except Exception as e:\n",
|
||||
" return {\"error\": f\"Error validating meme: {str(e)}\"}\n",
|
||||
"\n",
|
||||
" def _check_humor(self, query: str, captions: List[Dict[str, str]]) -> float:\n",
|
||||
" \"\"\"Check humor quality\"\"\"\n",
|
||||
" # Simple heuristic - check for contrast, exaggeration, or relatable elements\n",
|
||||
" score = 0.5 # Base score\n",
|
||||
"\n",
|
||||
" for caption in captions:\n",
|
||||
" text = f\"{caption.get('top', '')} {caption.get('bottom', '')}\".lower()\n",
|
||||
"\n",
|
||||
" # Check for humor indicators\n",
|
||||
" if any(word in text for word in [\"but\", \"however\", \"actually\", \"reality\"]):\n",
|
||||
" score += 0.2 # Contrast\n",
|
||||
" if any(word in text for word in [\"everyone\", \"nobody\", \"always\", \"never\"]):\n",
|
||||
" score += 0.1 # Exaggeration\n",
|
||||
" if any(word in text for word in [\"me\", \"my\", \"i\", \"we\"]):\n",
|
||||
" score += 0.1 # Relatable\n",
|
||||
"\n",
|
||||
" return min(1.0, score)\n",
|
||||
"\n",
|
||||
" def _check_relevance(self, query: str, captions: List[Dict[str, str]]) -> float:\n",
|
||||
" \"\"\"Check relevance to query\"\"\"\n",
|
||||
" query_words = set(query.lower().split())\n",
|
||||
" score = 0.5 # Base score\n",
|
||||
"\n",
|
||||
" for caption in captions:\n",
|
||||
" caption_text = f\"{caption.get('top', '')} {caption.get('bottom', '')}\".lower()\n",
|
||||
" caption_words = set(caption_text.split())\n",
|
||||
"\n",
|
||||
" # Check word overlap\n",
|
||||
" overlap = len(query_words.intersection(caption_words))\n",
|
||||
" if overlap > 0:\n",
|
||||
" score += 0.3\n",
|
||||
" if overlap > 2:\n",
|
||||
" score += 0.2\n",
|
||||
"\n",
|
||||
" return min(1.0, score)\n",
|
||||
"\n",
|
||||
" def _check_clarity(self, captions: List[Dict[str, str]]) -> float:\n",
|
||||
" \"\"\"Check text clarity and readability\"\"\"\n",
|
||||
" score = 1.0 # Start with perfect score\n",
|
||||
"\n",
|
||||
" for caption in captions:\n",
|
||||
" top_text = caption.get('top', '')\n",
|
||||
" bottom_text = caption.get('bottom', '')\n",
|
||||
"\n",
|
||||
" # Penalize long text\n",
|
||||
" if len(top_text) > 50:\n",
|
||||
" score -= 0.1\n",
|
||||
" if len(bottom_text) > 50:\n",
|
||||
" score -= 0.1\n",
|
||||
"\n",
|
||||
" # Penalize complex words\n",
|
||||
" complex_words = [word for word in top_text.split() if len(word) > 10]\n",
|
||||
" if len(complex_words) > 0:\n",
|
||||
" score -= 0.1\n",
|
||||
"\n",
|
||||
" return max(0.0, score)\n",
|
||||
"\n",
|
||||
" def _check_creativity(self, query: str, captions: List[Dict[str, str]]) -> float:\n",
|
||||
" \"\"\"Check creativity and originality\"\"\"\n",
|
||||
" score = 0.5 # Base score\n",
|
||||
"\n",
|
||||
" # Check for common meme phrases (penalize)\n",
|
||||
" common_phrases = [\n",
|
||||
" \"surprised pikachu\", \"change my mind\", \"one does not simply\",\n",
|
||||
" \"ancient aliens\", \"distracted boyfriend\", \"drake\"\n",
|
||||
" ]\n",
|
||||
"\n",
|
||||
" for caption in captions:\n",
|
||||
" caption_text = f\"{caption.get('top', '')} {caption.get('bottom', '')}\".lower()\n",
|
||||
"\n",
|
||||
" # Reward for avoiding common phrases\n",
|
||||
" if not any(phrase in caption_text for phrase in common_phrases):\n",
|
||||
" score += 0.3\n",
|
||||
"\n",
|
||||
" # Reward for unique word combinations\n",
|
||||
" unique_words = len(set(caption_text.split()))\n",
|
||||
" if unique_words > 8:\n",
|
||||
" score += 0.2\n",
|
||||
"\n",
|
||||
" return min(1.0, score)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "MnaRLR7rhkxd"
|
||||
},
|
||||
"source": [
|
||||
"# YAML Prompt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "gfjRa17thl_i",
|
||||
"outputId": "09440897-7b9a-4b04-f535-55abf1240e5c"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"✅ YAML Prompt configured!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# YAML Prompt\n",
|
||||
"yaml_prompt = \"\"\"\n",
|
||||
"name: \"AI Meme Creator Agent\"\n",
|
||||
"description: \"Expert meme generator with browser automation and multi-model support\"\n",
|
||||
"instructions:\n",
|
||||
" - \"You are an expert meme creator that generates funny and relevant memes based on user prompts\"\n",
|
||||
" - \"Use browser automation to navigate meme creation websites and select appropriate templates\"\n",
|
||||
" - \"Generate creative captions that match the meme template and user's request\"\n",
|
||||
" - \"Ensure memes are humorous, relevant, and visually appealing\"\n",
|
||||
" - \"Provide multiple caption options for different meme styles\"\n",
|
||||
" - \"Validate meme quality and suggest improvements when needed\"\n",
|
||||
" - \"Use appropriate meme templates that fit the context and emotion\"\n",
|
||||
" - \"Create captions that are short, readable, and impactful\"\n",
|
||||
" - \"Consider current trends and popular meme formats\"\n",
|
||||
"\n",
|
||||
"tools:\n",
|
||||
" - name: \"MemeTemplateSearchTool\"\n",
|
||||
" description: \"Searches for appropriate meme templates based on user query and action words\"\n",
|
||||
" - name: \"CaptionGeneratorTool\"\n",
|
||||
" description: \"Generates creative captions for memes based on query, template, and meme type\"\n",
|
||||
" - name: \"MemeValidationTool\"\n",
|
||||
" description: \"Validates meme quality and provides suggestions for improvement\"\n",
|
||||
"\n",
|
||||
"output_format:\n",
|
||||
" - \"Provide the generated meme image URL\"\n",
|
||||
" - \"Include caption suggestions and template recommendations\"\n",
|
||||
" - \"Offer quality assessment and improvement tips\"\n",
|
||||
" - \"Explain the meme concept and why it works\"\n",
|
||||
" - \"Provide alternative caption options if available\"\n",
|
||||
"\n",
|
||||
"temperature: 0.7\n",
|
||||
"max_tokens: 3000\n",
|
||||
"model: \"gpt-5-nano\"\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"print(\"✅ YAML Prompt configured!\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "BlJzii7Whtro"
|
||||
},
|
||||
"source": [
|
||||
"# Main"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "eMA38MJvhvJC",
|
||||
"outputId": "744230d3-7fce-444f-af78-7bdb98aa8a61"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"🥸 AI Meme Creator Agent\n",
|
||||
"Generate hilarious memes using AI and browser automation!\n",
|
||||
"\n",
|
||||
"⚙️ Model Configuration\n",
|
||||
"✅ Using model: OpenAI\n",
|
||||
"\n",
|
||||
"🎨 Meme Creation Interface\n",
|
||||
"Enter your meme idea:\n",
|
||||
"Meme Idea: When you finally understand the code after 3 hours of debugging\n",
|
||||
"\n",
|
||||
"🚀 Generating meme for: 'When you finally understand the code after 3 hours of debugging'\n",
|
||||
"\n",
|
||||
"🔍 Step 1: Searching for meme templates...\n",
|
||||
"✅ Found 5 relevant templates\n",
|
||||
"Action words: stand\n",
|
||||
"\n",
|
||||
"✍️ Step 2: Generating captions...\n",
|
||||
"✅ Generated 2 caption options\n",
|
||||
"Meme type: reaction\n",
|
||||
"\n",
|
||||
"📝 Caption Options:\n",
|
||||
"Option 1:\n",
|
||||
" Top: When When you finally understand the code after 3 hours of debugging\n",
|
||||
" Bottom: My face: 😱\n",
|
||||
"Option 2:\n",
|
||||
" Top: Me: When you finally understand the code after 3 hours of debugging\n",
|
||||
" Bottom: Also me: *surprised pikachu*\n",
|
||||
"\n",
|
||||
"�� Step 3: Validating meme quality...\n",
|
||||
"✅ Quality Assessment: Excellent\n",
|
||||
"Overall Score: 0.88/1.0\n",
|
||||
"💡 Suggestions for improvement:\n",
|
||||
" - Make sure text is short and easy to read\n",
|
||||
"\n",
|
||||
"�� Step 4: Generating meme with browser automation...\n",
|
||||
"🔄 Starting browser automation...\n",
|
||||
"Error in meme generation: \"ChatOpenAI\" object has no field \"ainvoke\"\n",
|
||||
"❌ Failed to generate meme. This might be due to:\n",
|
||||
" - Browser automation issues\n",
|
||||
" - Website changes\n",
|
||||
" - Network connectivity\n",
|
||||
" - API rate limits\n",
|
||||
"\n",
|
||||
"💡 Manual Meme Creation Instructions:\n",
|
||||
"1. Go to https://imgflip.com/memetemplates\n",
|
||||
"2. Search for a template related to your query\n",
|
||||
"3. Use one of the generated captions:\n",
|
||||
" Option 1: Top='When When you finally understand the code after 3 hours of debugging', Bottom='My face: 😱'\n",
|
||||
" Option 2: Top='Me: When you finally understand the code after 3 hours of debugging', Bottom='Also me: *surprised pikachu*'\n",
|
||||
"\n",
|
||||
"🧪 Sample Meme Ideas for Testing\n",
|
||||
"Try these sample ideas:\n",
|
||||
"1. When you finally understand the code after 3 hours of debugging\n",
|
||||
"2. Me trying to explain AI to my grandparents\n",
|
||||
"3. The difference between what I plan to do vs what I actually do\n",
|
||||
"4. When someone asks if I'm free this weekend\n",
|
||||
"5. My brain at 3 AM thinking about that embarrassing thing from 5 years ago\n",
|
||||
"\n",
|
||||
"==================================================\n",
|
||||
"�� Powered by AI Meme Creator Agent | Built with PraisonAI\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import asyncio\n",
|
||||
"import streamlit as st\n",
|
||||
"from browser_use import Agent, SystemPrompt\n",
|
||||
"from langchain_openai import ChatOpenAI\n",
|
||||
"from langchain_anthropic import ChatAnthropic\n",
|
||||
"from langchain_core.messages import HumanMessage\n",
|
||||
"import re\n",
|
||||
"import os\n",
|
||||
"from typing import Dict, Any, List\n",
|
||||
"\n",
|
||||
"# Initialize tools\n",
|
||||
"template_tool = MemeTemplateSearchTool()\n",
|
||||
"caption_tool = CaptionGeneratorTool()\n",
|
||||
"validation_tool = MemeValidationTool()\n",
|
||||
"\n",
|
||||
"print(\"🥸 AI Meme Creator Agent\")\n",
|
||||
"print(\"Generate hilarious memes using AI and browser automation!\")\n",
|
||||
"\n",
|
||||
"# Model configuration\n",
|
||||
"print(\"\\n⚙️ Model Configuration\")\n",
|
||||
"model_choice = \"OpenAI\" # Options: \"OpenAI\", \"Claude\", \"Deepseek\"\n",
|
||||
"print(f\"✅ Using model: {model_choice}\")\n",
|
||||
"\n",
|
||||
"# Meme generation function\n",
|
||||
"async def generate_meme(query: str, model_choice: str, api_key: str) -> str:\n",
|
||||
" \"\"\"Generate meme using browser automation\"\"\"\n",
|
||||
" try:\n",
|
||||
" # Initialize the appropriate LLM based on user selection\n",
|
||||
" if model_choice == \"Claude\":\n",
|
||||
" llm = ChatAnthropic(\n",
|
||||
" model=\"claude-3-5-sonnet-20241022\",\n",
|
||||
" api_key=api_key\n",
|
||||
" )\n",
|
||||
" elif model_choice == \"Deepseek\":\n",
|
||||
" llm = ChatOpenAI(\n",
|
||||
" base_url='https://api.deepseek.com/v1',\n",
|
||||
" model='deepseek-chat',\n",
|
||||
" api_key=api_key,\n",
|
||||
" temperature=0.3\n",
|
||||
" )\n",
|
||||
" else: # OpenAI\n",
|
||||
" llm = ChatOpenAI(\n",
|
||||
" model=\"gpt-5-nano\",\n",
|
||||
" api_key=api_key,\n",
|
||||
" temperature=0.0\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" task_description = (\n",
|
||||
" \"You are a meme generator expert. You are given a query and you need to generate a meme for it.\\n\"\n",
|
||||
" \"1. Go to https://imgflip.com/memetemplates \\n\"\n",
|
||||
" \"2. Click on the Search bar in the middle and search for ONLY ONE MAIN ACTION VERB (like 'bully', 'laugh', 'cry') in this query: '{0}'\\n\"\n",
|
||||
" \"3. Choose any meme template that metaphorically fits the meme topic: '{0}'\\n\"\n",
|
||||
" \" by clicking on the 'Add Caption' button below it\\n\"\n",
|
||||
" \"4. Write a Top Text (setup/context) and Bottom Text (punchline/outcome) related to '{0}'.\\n\"\n",
|
||||
" \"5. Check the preview making sure it is funny and a meaningful meme. Adjust text directly if needed. \\n\"\n",
|
||||
" \"6. Look at the meme and text on it, if it doesnt make sense, PLEASE retry by filling the text boxes with different text. \\n\"\n",
|
||||
" \"7. Click on the Generate meme button to generate the meme\\n\"\n",
|
||||
" \"8. Copy the image link and give it as the output\\n\"\n",
|
||||
" ).format(query)\n",
|
||||
"\n",
|
||||
" agent = Agent(\n",
|
||||
" task=task_description,\n",
|
||||
" llm=llm,\n",
|
||||
" max_actions_per_step=5,\n",
|
||||
" max_failures=25,\n",
|
||||
" use_vision=(model_choice != \"Deepseek\")\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" history = await agent.run()\n",
|
||||
"\n",
|
||||
" # Extract final result from agent history\n",
|
||||
" final_result = history.final_result()\n",
|
||||
"\n",
|
||||
" # Use regex to find the meme URL in the result\n",
|
||||
" url_match = re.search(r'https://imgflip\\.com/i/(\\w+)', final_result)\n",
|
||||
" if url_match:\n",
|
||||
" meme_id = url_match.group(1)\n",
|
||||
" return f\"https://i.imgflip.com/{meme_id}.jpg\"\n",
|
||||
" return None\n",
|
||||
" except Exception as e:\n",
|
||||
" print(f\"Error in meme generation: {str(e)}\")\n",
|
||||
" return None\n",
|
||||
"\n",
|
||||
"# Interactive meme creation\n",
|
||||
"print(\"\\n🎨 Meme Creation Interface\")\n",
|
||||
"print(\"Enter your meme idea:\")\n",
|
||||
"\n",
|
||||
"query = input(\"Meme Idea: \")\n",
|
||||
"\n",
|
||||
"if query.strip():\n",
|
||||
" print(f\"\\n🚀 Generating meme for: '{query}'\")\n",
|
||||
"\n",
|
||||
" # Step 1: Search for templates\n",
|
||||
" print(\"\\n🔍 Step 1: Searching for meme templates...\")\n",
|
||||
" template_result = template_tool.search_templates(query)\n",
|
||||
"\n",
|
||||
" if \"error\" not in template_result:\n",
|
||||
" print(f\"✅ Found {len(template_result['suggested_templates'])} relevant templates\")\n",
|
||||
" print(f\"Action words: {', '.join(template_result['action_words'])}\")\n",
|
||||
"\n",
|
||||
" # Step 2: Generate captions\n",
|
||||
" print(\"\\n✍️ Step 2: Generating captions...\")\n",
|
||||
" selected_template = template_result['suggested_templates'][0]\n",
|
||||
" caption_result = caption_tool.generate_captions(query, selected_template)\n",
|
||||
"\n",
|
||||
" if \"error\" not in caption_result:\n",
|
||||
" print(f\"✅ Generated {len(caption_result['captions'])} caption options\")\n",
|
||||
" print(f\"Meme type: {caption_result['meme_type']}\")\n",
|
||||
"\n",
|
||||
" # Display caption options\n",
|
||||
" print(\"\\n📝 Caption Options:\")\n",
|
||||
" for i, caption in enumerate(caption_result['captions'], 1):\n",
|
||||
" print(f\"Option {i}:\")\n",
|
||||
" print(f\" Top: {caption.get('top', 'N/A')}\")\n",
|
||||
" print(f\" Bottom: {caption.get('bottom', 'N/A')}\")\n",
|
||||
"\n",
|
||||
" # Step 3: Validate meme quality\n",
|
||||
" print(\"\\n�� Step 3: Validating meme quality...\")\n",
|
||||
" validation_result = validation_tool.validate_meme(\n",
|
||||
" query, caption_result['captions'], selected_template\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" if \"error\" not in validation_result:\n",
|
||||
" print(f\"✅ Quality Assessment: {validation_result['quality']}\")\n",
|
||||
" print(f\"Overall Score: {validation_result['overall_score']:.2f}/1.0\")\n",
|
||||
"\n",
|
||||
" if validation_result['suggestions']:\n",
|
||||
" print(\"💡 Suggestions for improvement:\")\n",
|
||||
" for suggestion in validation_result['suggestions']:\n",
|
||||
" print(f\" - {suggestion}\")\n",
|
||||
"\n",
|
||||
" # Step 4: Generate actual meme (if API key is available)\n",
|
||||
" print(\"\\n�� Step 4: Generating meme with browser automation...\")\n",
|
||||
"\n",
|
||||
" # Check if we have the required API key\n",
|
||||
" api_key = os.getenv(\"OPENAI_API_KEY\")\n",
|
||||
" if api_key and api_key != \"your_openai_key_here\":\n",
|
||||
" try:\n",
|
||||
" print(\"🔄 Starting browser automation...\")\n",
|
||||
" meme_url = await generate_meme(query, model_choice, api_key)\n",
|
||||
"\n",
|
||||
" if meme_url:\n",
|
||||
" print(\"✅ Meme Generated Successfully!\")\n",
|
||||
" print(f\"📸 Meme URL: {meme_url}\")\n",
|
||||
" print(f\"�� Direct Link: {meme_url}\")\n",
|
||||
"\n",
|
||||
" # Display meme (in Colab, we can use HTML)\n",
|
||||
" from IPython.display import Image, display\n",
|
||||
" display(Image(url=meme_url))\n",
|
||||
" else:\n",
|
||||
" print(\"❌ Failed to generate meme. This might be due to:\")\n",
|
||||
" print(\" - Browser automation issues\")\n",
|
||||
" print(\" - Website changes\")\n",
|
||||
" print(\" - Network connectivity\")\n",
|
||||
" print(\" - API rate limits\")\n",
|
||||
"\n",
|
||||
" # Provide manual instructions\n",
|
||||
" print(\"\\n💡 Manual Meme Creation Instructions:\")\n",
|
||||
" print(\"1. Go to https://imgflip.com/memetemplates\")\n",
|
||||
" print(\"2. Search for a template related to your query\")\n",
|
||||
" print(\"3. Use one of the generated captions:\")\n",
|
||||
" for i, caption in enumerate(caption_result['captions'], 1):\n",
|
||||
" print(f\" Option {i}: Top='{caption.get('top', '')}', Bottom='{caption.get('bottom', '')}'\")\n",
|
||||
"\n",
|
||||
" except Exception as e:\n",
|
||||
" print(f\"❌ Error during meme generation: {str(e)}\")\n",
|
||||
" print(\"💡 Try using the manual instructions above\")\n",
|
||||
" else:\n",
|
||||
" print(\"⚠️ API key not configured for browser automation\")\n",
|
||||
" print(\"💡 Using generated captions for manual meme creation:\")\n",
|
||||
" for i, caption in enumerate(caption_result['captions'], 1):\n",
|
||||
" print(f\" Option {i}: Top='{caption.get('top', '')}', Bottom='{caption.get('bottom', '')}'\")\n",
|
||||
" else:\n",
|
||||
" print(f\"❌ Error generating captions: {caption_result['error']}\")\n",
|
||||
" else:\n",
|
||||
" print(f\"❌ Error searching templates: {template_result['error']}\")\n",
|
||||
"\n",
|
||||
"else:\n",
|
||||
" print(\"❌ No meme idea provided.\")\n",
|
||||
"\n",
|
||||
"print(\"\\n🧪 Sample Meme Ideas for Testing\")\n",
|
||||
"sample_ideas = [\n",
|
||||
" \"When you finally understand the code after 3 hours of debugging\",\n",
|
||||
" \"Me trying to explain AI to my grandparents\",\n",
|
||||
" \"The difference between what I plan to do vs what I actually do\",\n",
|
||||
" \"When someone asks if I'm free this weekend\",\n",
|
||||
" \"My brain at 3 AM thinking about that embarrassing thing from 5 years ago\"\n",
|
||||
"]\n",
|
||||
"\n",
|
||||
"print(\"Try these sample ideas:\")\n",
|
||||
"for i, idea in enumerate(sample_ideas, 1):\n",
|
||||
" print(f\"{i}. {idea}\")\n",
|
||||
"\n",
|
||||
"print(\"\\n\" + \"=\"*50)\n",
|
||||
"print(\"�� Powered by AI Meme Creator Agent | Built with PraisonAI\")"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
File renamed without changes.
+1
-1
@@ -120,7 +120,7 @@
|
||||
"\n",
|
||||
" def run(self, message: str):\n",
|
||||
" response = client.chat.completions.create(\n",
|
||||
" model=\"gpt-4o-mini\",\n",
|
||||
" model=\"gpt-5-nano\",\n",
|
||||
" messages=[\n",
|
||||
" {\"role\": \"system\", \"content\": self.prompt},\n",
|
||||
" {\"role\": \"user\", \"content\": message}\n",
|
||||
+689
@@ -0,0 +1,689 @@
|
||||
{
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"name": "python3",
|
||||
"display_name": "Python 3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
},
|
||||
"widgets": {
|
||||
"application/vnd.jupyter.widget-state+json": {
|
||||
"4ab88bfcb62e4f9a8db7e35aefbae00a": {
|
||||
"model_module": "@jupyter-widgets/output",
|
||||
"model_name": "OutputModel",
|
||||
"model_module_version": "1.0.0",
|
||||
"state": {
|
||||
"_dom_classes": [],
|
||||
"_model_module": "@jupyter-widgets/output",
|
||||
"_model_module_version": "1.0.0",
|
||||
"_model_name": "OutputModel",
|
||||
"_view_count": null,
|
||||
"_view_module": "@jupyter-widgets/output",
|
||||
"_view_module_version": "1.0.0",
|
||||
"_view_name": "OutputView",
|
||||
"layout": "IPY_MODEL_3d1ae7a6c0a947f985f6ef921b74ecf8",
|
||||
"msg_id": "",
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "display_data",
|
||||
"data": {
|
||||
"text/plain": "\u001b[32m╭─\u001b[0m\u001b[32m─────────────────────────────────────────────\u001b[0m\u001b[32m Generating... 23.2s \u001b[0m\u001b[32m─────────────────────────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n\u001b[32m│\u001b[0m [INTRO MUSIC FADES IN] \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[1mAlex\u001b[0m: Hello and welcome to another episode of \"The World Today,\" where we dive into the latest in technology \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m and world news. I'm Alex, your go-to for all things analytical and fact-focused. \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[1mMorgan\u001b[0m: And I'm Morgan, here to explore the human impact and social context of today's stories. We've got a \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m fascinating lineup for you today, so let's dive right in! \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[1mAlex\u001b[0m: First up, we're talking about a topic that's been making waves across the healthcare industry: the role \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m of artificial intelligence. According to a recent article from \u001b]8;id=672819;https://news.example.com/ai-healthcare\u001b\\\u001b[4;34mNews Example\u001b[0m\u001b]8;;\u001b\\, AI is revolutionizing healthcare \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m in ways we could only dream of a decade ago. \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[1mMorgan\u001b[0m: That's right, Alex. AI is not just a buzzword anymore; it's actively changing how we approach \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m healthcare. From diagnostics to treatment plans, AI is helping doctors make more accurate decisions faster. But \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m what does this mean for patients and healthcare professionals? \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[1mAlex\u001b[0m: Well, Morgan, AI's ability to analyze vast amounts of data quickly means that doctors can diagnose \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m diseases earlier and more accurately. For instance, AI algorithms can now detect patterns in medical imaging \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m that might be too subtle for the human eye. This can lead to earlier interventions and better patient outcomes. \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[1mMorgan\u001b[0m: And let's not forget about the human side of things. For patients, this means less waiting time for \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m results and potentially more personalized treatment plans. But there's also a concern about the human touch in \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m healthcare. How do we balance the efficiency of AI with the empathy and understanding that only a human can \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m provide? \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[1mAlex\u001b[0m: That's a great point. The integration of AI in healthcare does raise ethical questions. For example, who \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m is responsible if an AI system makes a mistake? And how do we ensure that these systems are free from bias? \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m Line truncated
|
||||
"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\">╭────────────────────────────────────────────── Generating... 23.2s ──────────────────────────────────────────────╮</span>\n<span style=\"color: #008000; text-decoration-color: #008000\">│</span> [INTRO MUSIC FADES IN] <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"font-weight: bold\">Alex</span>: Hello and welcome to another episode of \"The World Today,\" where we dive into the latest in technology <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n<span style=\"color: #008000; text-decoration-color: #008000\">│</span> and world news. I'm Alex, your go-to for all things analytical and fact-focused. <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"font-weight: bold\">Morgan</span>: And I'm Morgan, here to explore the human impact and social context of today's stories. We've got a <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n<span style=\"color: #008000; text-decoration-color: #008000\">│</span> fascinating lineup for you today, so let's dive right in! <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"font-weight: bold\">Alex</span>: First up, we're talking about a topic that's been making waves across the healthcare industry: the role <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n<span style=\"color: #008000; text-decoration-color: #008000\">│</span> of artificial intelligence. According to a recent article from <a href=\"https://news.example.com/ai-healthcare\" target=\"_blank\"><span style=\"color: #000080; text-decoration-color: #000080; text-decoration: underline\">News Example</span></a>, AI is revolutionizing healthcare <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n<span style=\"color: #008000; text-decoration-color: #008000\">│</span> in ways we could only dream of a decade ago. <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"font-weight: bold\">Morgan</span>: That's right, Alex. AI is not just a buzzword anymore; it's actively changing how we approach <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n<span style=\"color: #008000; text-decoration-color: #008000\">│</span> healthcare. From diagnostics to treatment plans, AI is helping doctors make more accurate decisions faster. But <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n<span style=\"color: #008000; text-decoration-color: #008000\">│</span> what does this mean for patients and healthcare professionals? <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"coloLine truncated
|
||||
},
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"3d1ae7a6c0a947f985f6ef921b74ecf8": {
|
||||
"model_module": "@jupyter-widgets/base",
|
||||
"model_name": "LayoutModel",
|
||||
"model_module_version": "1.2.0",
|
||||
"state": {
|
||||
"_model_module": "@jupyter-widgets/base",
|
||||
"_model_module_version": "1.2.0",
|
||||
"_model_name": "LayoutModel",
|
||||
"_view_count": null,
|
||||
"_view_module": "@jupyter-widgets/base",
|
||||
"_view_module_version": "1.2.0",
|
||||
"_view_name": "LayoutView",
|
||||
"align_content": null,
|
||||
"align_items": null,
|
||||
"align_self": null,
|
||||
"border": null,
|
||||
"bottom": null,
|
||||
"display": null,
|
||||
"flex": null,
|
||||
"flex_flow": null,
|
||||
"grid_area": null,
|
||||
"grid_auto_columns": null,
|
||||
"grid_auto_flow": null,
|
||||
"grid_auto_rows": null,
|
||||
"grid_column": null,
|
||||
"grid_gap": null,
|
||||
"grid_row": null,
|
||||
"grid_template_areas": null,
|
||||
"grid_template_columns": null,
|
||||
"grid_template_rows": null,
|
||||
"height": null,
|
||||
"justify_content": null,
|
||||
"justify_items": null,
|
||||
"left": null,
|
||||
"margin": null,
|
||||
"max_height": null,
|
||||
"max_width": null,
|
||||
"min_height": null,
|
||||
"min_width": null,
|
||||
"object_fit": null,
|
||||
"object_position": null,
|
||||
"order": null,
|
||||
"overflow": null,
|
||||
"overflow_x": null,
|
||||
"overflow_y": null,
|
||||
"padding": null,
|
||||
"right": null,
|
||||
"top": null,
|
||||
"visibility": null,
|
||||
"width": null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# News and Podcast Aggregator Agent using PraisonAIAgents"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "5DpLQOaCmYbu"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"This notebook demonstrates a News and Podcast Aggregator Agent built with `praisonaiagents`. \n",
|
||||
"It summarizes news articles and generates podcast-style discussion points. \n",
|
||||
"The notebook is CI-friendly: it uses dummy data if API keys are not set, so all tests/checks will pass."
|
||||
],
|
||||
"metadata": {
|
||||
"id": "qmVwAahwmYTZ"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/SocialMedia_Content_Agents/News_And_Podcast_Aggregator_Agent.ipynb)\n"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "tYRRrgqHqbuN"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "baTmwAjYmfDg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "IIm2awOXmXB9"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonaiagents pydantic"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Imports and Setup"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "kqNfe5S2mjnn"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"# Set up the OpenAI API key for praisonaiagents\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = os.environ.get(\"OPENAI_API_KEY\", \"sk-..\")\n",
|
||||
"\n",
|
||||
"def is_valid_key(key, prefix):\n",
|
||||
" return key and key != f\"{prefix}-..\" and key.startswith(prefix)\n",
|
||||
"\n",
|
||||
"OPENAI_API_KEY = os.environ[\"OPENAI_API_KEY\"]"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "A-OXlt2gmpUS"
|
||||
},
|
||||
"execution_count": 3,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Tools"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "IJmdTrCDoufF"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"from datetime import datetime\n",
|
||||
"from typing import List\n",
|
||||
"\n",
|
||||
"def format_search_results_for_podcast(search_results: List[dict]) -> tuple[str, List[str]]:\n",
|
||||
" \"\"\"\n",
|
||||
" Custom tool to format search results for podcast script generation.\n",
|
||||
" \"\"\"\n",
|
||||
" created_at = datetime.now().strftime(\"%B %d, %Y at %I:%M %p\")\n",
|
||||
" structured_content = []\n",
|
||||
" structured_content.append(f\"PODCAST CREATION: {created_at}\\n\")\n",
|
||||
" sources = []\n",
|
||||
" for idx, search_result in enumerate(search_results):\n",
|
||||
" try:\n",
|
||||
" if search_result.get(\"confirmed\", False):\n",
|
||||
" sources.append(search_result[\"url\"])\n",
|
||||
" structured_content.append(\n",
|
||||
" f\"\"\"\n",
|
||||
" SOURCE {idx + 1}:\n",
|
||||
" Title: {search_result['title']}\n",
|
||||
" URL: {search_result['url']}\n",
|
||||
" Content: {search_result.get('full_text') or search_result.get('description', '')}\n",
|
||||
" ---END OF SOURCE {idx + 1}---\n",
|
||||
" \"\"\".strip()\n",
|
||||
" )\n",
|
||||
" except Exception as e:\n",
|
||||
" print(f\"Error processing search result: {e}\")\n",
|
||||
" content_texts = \"\\n\\n\".join(structured_content)\n",
|
||||
" return content_texts, sources"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "yHj7Grvmov4C"
|
||||
},
|
||||
"execution_count": 4,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Pydantic Models"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "eMYs7Oibo1M3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"from pydantic import BaseModel, Field\n",
|
||||
"from typing import List, Optional\n",
|
||||
"\n",
|
||||
"class Dialog(BaseModel):\n",
|
||||
" speaker: str = Field(..., description=\"The speaker name (SHOULD BE 'ALEX' OR 'MORGAN')\")\n",
|
||||
" text: str = Field(..., description=\"The spoken text content for this speaker based on the requested language, default is English\")\n",
|
||||
"\n",
|
||||
"class Section(BaseModel):\n",
|
||||
" type: str = Field(..., description=\"The section type (intro, headlines, article, outro)\")\n",
|
||||
" title: Optional[str] = Field(None, description=\"Optional title for the section (required for article type)\")\n",
|
||||
" dialog: List[Dialog] = Field(..., description=\"List of dialog exchanges between speakers\")\n",
|
||||
"\n",
|
||||
"class PodcastScript(BaseModel):\n",
|
||||
" title: str = Field(..., description=\"The podcast episode title with date\")\n",
|
||||
" sections: List[Section] = Field(..., description=\"List of podcast sections (intro, headlines, articles, outro)\")"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "Z4uBU68eo2L_"
|
||||
},
|
||||
"execution_count": 5,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Agent Instructions"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "sRTr9D35o-5D"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"from textwrap import dedent\n",
|
||||
"\n",
|
||||
"PODCAST_AGENT_DESCRIPTION = \"You are a helpful assistant that can generate engaging podcast scripts for the given sources.\"\n",
|
||||
"PODCAST_AGENT_INSTRUCTIONS = dedent(\"\"\"\n",
|
||||
" You are a helpful assistant that can generate engaging podcast scripts for the given source content and query.\n",
|
||||
" For given content, create an engaging podcast script that should be at least 15 minutes worth of content and you are allowed to enhance the script beyond given sources if you know something additional info will be interesting to the discussion or not enough content is available.\n",
|
||||
" You use the provided sources to ground your podcast script generation process. Keep it engaging and interesting.\n",
|
||||
" IMPORTANT: Generate the entire script in the provided language.\n",
|
||||
" CONTENT GUIDELINES:\n",
|
||||
" - Provide insightful analysis that helps the audience understand the significance\n",
|
||||
" - Include discussions on potential implications and broader context of each story\n",
|
||||
" - Explain complex concepts in an accessible but thorough manner\n",
|
||||
" - Make connections between current and relevant historical developments when applicable\n",
|
||||
" - Provide comparisons and contrasts with similar stories or trends when relevant\n",
|
||||
" PERSONALITY NOTES:\n",
|
||||
" - Alex is more analytical and fact-focused\n",
|
||||
" - Morgan is more focused on human impact, social context, and practical applications\n",
|
||||
" - Include natural, conversational banter and smooth transitions between topics\n",
|
||||
" - Each article discussion should go beyond the basic summary to provide valuable insights\n",
|
||||
" - Maintain a conversational but informed tone that would appeal to a general audience\n",
|
||||
" IMPORTANT:\n",
|
||||
" - MAKE SURE PODCAST SCRIPTS ARE AT LEAST 15 MINUTES LONG WHICH MEANS YOU NEED TO HAVE DETAILED DISCUSSIONS BUT KEEP IT INTERESTING AND ENGAGING.\n",
|
||||
"\"\"\")"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "quslT1kFo_yc"
|
||||
},
|
||||
"execution_count": 6,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Dummy Data and Main Logic"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "bicXivCipLZY"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"from praisonaiagents import Agent\n",
|
||||
"\n",
|
||||
"# Dummy search results for CI/public use\n",
|
||||
"dummy_search_results = [\n",
|
||||
" {\n",
|
||||
" \"confirmed\": True,\n",
|
||||
" \"title\": \"AI Revolutionizes Healthcare\",\n",
|
||||
" \"url\": \"https://news.example.com/ai-healthcare\",\n",
|
||||
" \"full_text\": \"Artificial intelligence is transforming the healthcare industry by...\"\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"confirmed\": True,\n",
|
||||
" \"title\": \"Climate Change and Global Policy\",\n",
|
||||
" \"url\": \"https://news.example.com/climate-policy\",\n",
|
||||
" \"full_text\": \"World leaders are meeting to discuss new policies for climate change...\"\n",
|
||||
" }\n",
|
||||
"]\n",
|
||||
"\n",
|
||||
"query = \"Latest technology and world news\"\n",
|
||||
"language_name = \"English\"\n",
|
||||
"\n",
|
||||
"content_texts, sources = format_search_results_for_podcast(dummy_search_results)\n",
|
||||
"\n",
|
||||
"if not is_valid_key(OPENAI_API_KEY, \"sk\"):\n",
|
||||
" print(\"API key not set or is a placeholder. Using dummy podcast script for CI/testing.\")\n",
|
||||
" print(\"=== Podcast Script ===\")\n",
|
||||
" print(f\"Podcast Title: Tech & World News Roundup ({datetime.now().strftime('%B %d, %Y')})\")\n",
|
||||
" for idx, article in enumerate(dummy_search_results):\n",
|
||||
" print(f\"\\nSection {idx+1}: {article['title']}\")\n",
|
||||
" print(f\"Summary: {article['full_text'][:80]}...\")\n",
|
||||
"else:\n",
|
||||
" agent = Agent(\n",
|
||||
" name=\"Podcast Script Agent\",\n",
|
||||
" instructions=PODCAST_AGENT_INSTRUCTIONS,\n",
|
||||
" api_key=OPENAI_API_KEY\n",
|
||||
" )\n",
|
||||
" prompt = f\"query: {query}\\nlanguage_name: {language_name}\\ncontent_texts: {content_texts}\\nIMPORTANT: texts should be in {language_name} language.\"\n",
|
||||
" podcast_script = agent.start(prompt)\n",
|
||||
" print(\"=== Podcast Script ===\")\n",
|
||||
" print(podcast_script)"
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000,
|
||||
"referenced_widgets": [
|
||||
"4ab88bfcb62e4f9a8db7e35aefbae00a",
|
||||
"3d1ae7a6c0a947f985f6ef921b74ecf8"
|
||||
]
|
||||
},
|
||||
"id": "H4UoF8PApMUJ",
|
||||
"outputId": "748c6a75-0a0e-494a-983c-fb539ff7641a"
|
||||
},
|
||||
"execution_count": 7,
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "display_data",
|
||||
"data": {
|
||||
"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;229mPodcast Script 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"
|
||||
],
|
||||
"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\">Podcast Script 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"
|
||||
]
|
||||
},
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
"output_type": "display_data",
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
],
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"version_major": 2,
|
||||
"version_minor": 0,
|
||||
"model_id": "4ab88bfcb62e4f9a8db7e35aefbae00a"
|
||||
}
|
||||
},
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
"output_type": "display_data",
|
||||
"data": {
|
||||
"text/plain": [],
|
||||
"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"
|
||||
]
|
||||
},
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
"output_type": "display_data",
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"\n"
|
||||
],
|
||||
"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"
|
||||
]
|
||||
},
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
"output_type": "display_data",
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 23.5s\u001b[0m\n"
|
||||
],
|
||||
"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 23.5s</span>\n",
|
||||
"</pre>\n"
|
||||
]
|
||||
},
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
"output_type": "display_data",
|
||||
"data": {
|
||||
"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 query: Latest technology and world news language_name: English content_texts: PODCAST CREATION: July 09, 2025 \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m at 10:03 AM \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m SOURCE 1: Title: AI Revolutionizes Healthcare URL: https://news.example.com/ai-healthcare Content: Artificial \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m intelligence is transforming the healthcare industry by... ---END OF SOURCE 1--- \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m SOURCE 2: Title: Climate Change and Global Policy URL: https://news.example.com/climate-policy Content: World \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m leaders are meeting to discuss new policies for climate change... ---END OF SOURCE 2--- IMPORTANT: texts should \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m be in English language. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
],
|
||||
"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> query: Latest technology and world news language_name: English content_texts: PODCAST CREATION: July 09, 2025 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> at 10:03 AM <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> SOURCE 1: Title: AI Revolutionizes Healthcare URL: https://news.example.com/ai-healthcare Content: Artificial <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> intelligence is transforming the healthcare industry by... ---END OF SOURCE 1--- <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> SOURCE 2: Title: Climate Change and Global Policy URL: https://news.example.com/climate-policy Content: World <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> leaders are meeting to discuss new policies for climate change... ---END OF SOURCE 2--- IMPORTANT: texts should <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> be in English language. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
]
|
||||
},
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
"output_type": "display_data",
|
||||
"data": {
|
||||
"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 [INTRO MUSIC FADES IN] \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mAlex\u001b[0m: Hello and welcome to another episode of \"The World Today,\" where we dive into the latest in technology \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m and world news. I'm Alex, your go-to for all things analytical and fact-focused. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mMorgan\u001b[0m: And I'm Morgan, here to explore the human impact and social context of today's stories. We've got a \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m fascinating lineup for you today, so let's dive right in! \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mAlex\u001b[0m: First up, we're talking about a topic that's been making waves across the healthcare industry: the role \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m of artificial intelligence. According to a recent article from \u001b]8;id=890061;https://news.example.com/ai-healthcare\u001b\\\u001b[4;34mNews Example\u001b[0m\u001b]8;;\u001b\\, AI is revolutionizing healthcare \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m in ways we could only dream of a decade ago. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mMorgan\u001b[0m: That's right, Alex. AI is not just a buzzword anymore; it's actively changing how we approach \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m healthcare. From diagnostics to treatment plans, AI is helping doctors make more accurate decisions faster. But \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m what does this mean for patients and healthcare professionals? \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mAlex\u001b[0m: Well, Morgan, AI's ability to analyze vast amounts of data quickly means that doctors can diagnose \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m diseases earlier and more accurately. For instance, AI algorithms can now detect patterns in medical imaging \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m that might be too subtle for the human eye. This can lead to earlier interventions and better patient outcomes. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mMorgan\u001b[0m: And let's not forget about the human side of things. For patients, this means less waiting time for \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m results and potentially more personalized treatment plans. But there's also a concern about the human touch in \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m healthcare. How do we balance the efficiency of AI with the empathy and understanding that only a human can \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m provide? \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mAlex\u001b[0m: That's a great point. The integration of AI in healthcare does raise ethical questions. For example, who \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m is responsible if an AI system makes a mistake? And how do we ensure that these systems are free from bias? \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mMorgan\u001b[0m: Exactly. There's a lot to consider, but the potential benefits are enormous. Imagine a world where \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m healthcare is not only more efficient but also more accessible to people in remote areas thanks to AI-driven \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m telemedicine. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mAlex\u001b[0m: It's a fascinating time for healthcare, no doubt. But let's shift gears a bit and talk about another \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m pressing issue: climate change and global policy. According to a report from \u001b]8;id=2198;https://news.example.com/climate-policy\u001b\\\u001b[4;34mNews Example\u001b[0m\u001b]8;;\u001b\\, world leaders are \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m currently meeting to discuss new policies to combat climate change. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mMorgan\u001b[0m: Climate change is one of those issues that affects everyone, regardless of where you live. These global \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m meetings are crucial because they set the stage for international cooperation. But what are the main challenges \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m these leaders face? \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mAlex\u001b[0m: One of the biggest challenges is balancing economic growth with environmental sustainability. Many \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m developing countries argue that they need to prioritize economic development, which often relies on fossil \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m fuels. Meanwhile, developed countries are pushing for stricter environmental regulations. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mMorgan\u001b[0m: It's a classic case of differing priorities. But there's also a growing recognition that climate change \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m doesn't respect borders. Extreme weather events, rising sea levels, and shifting agricultural patterns affect \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m us all. So, there's a real urgency to find common ground. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mAlex\u001b[0m: And technology plays a significant role here too. Innovations in renewable energy, carbon capture, and \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m sustainable agriculture are crucial in the fight against climate change. But implementing these technologies on \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m a global scale requires significant investment and political will. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mMorgan\u001b[0m: It's a complex issue, but it's encouraging to see world leaders coming together to address it. The \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m policies they create today will shape the future for generations to come. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mAlex\u001b[0m: Absolutely. And it's not just about government action. Individuals and businesses also have a role to \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m play in reducing carbon footprints and advocating for sustainable practices. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mMorgan\u001b[0m: It's a collective effort, and every little bit helps. Before we wrap up, Alex, any final thoughts on \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m today's topics? \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mAlex\u001b[0m: Just that both AI in healthcare and climate change policies highlight the intersection of technology and \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m society. They show us how innovation can drive progress but also remind us of the responsibilities that come \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m with it. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mMorgan\u001b[0m: Well said, Alex. It's all about finding that balance. And with that, we've reached the end of today's \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m episode. Thanks for tuning in to \"The World Today.\" \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mAlex\u001b[0m: Don't forget to subscribe and join us next time for more insights into the latest in technology and world \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m news. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1mMorgan\u001b[0m: Until then, stay informed and stay curious! \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m [OUTRO MUSIC FADES OUT] \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
],
|
||||
"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> [INTRO MUSIC FADES IN] <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\">Alex</span>: Hello and welcome to another episode of \"The World Today,\" where we dive into the latest in technology <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> and world news. I'm Alex, your go-to for all things analytical and fact-focused. <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\">Morgan</span>: And I'm Morgan, here to explore the human impact and social context of today's stories. We've got a <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> fascinating lineup for you today, so let's dive right in! <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\">Alex</span>: First up, we're talking about a topic that's been making waves across the healthcare industry: the role <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> of artificial intelligence. According to a recent article from <a href=\"https://news.example.com/ai-healthcare\" target=\"_blank\"><span style=\"color: #000080; text-decoration-color: #000080; text-decoration: underline\">News Example</span></a>, AI is revolutionizing healthcare <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> in ways we could only dream of a decade ago. <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\">Morgan</span>: That's right, Alex. AI is not just a buzzword anymore; it's actively changing how we approach <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> healthcare. From diagnostics to treatment plans, AI is helping doctors make more accurate decisions faster. But <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> what does this mean for patients and healthcare professionals? <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\">Alex</span>: Well, Morgan, AI's ability to analyze vast amounts of data quickly means that doctors can diagnose <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> diseases earlier and more accurately. For instance, AI algorithms can now detect patterns in medical imaging <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> that might be too subtle for the human eye. This can lead to earlier interventions and better patient outcomes. <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\">Morgan</span>: And let's not forget about the human side of things. For patients, this means less waiting time for <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> results and potentially more personalized treatment plans. But there's also a concern about the human touch in <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> healthcare. How do we balance the efficiency of AI with the empathy and understanding that only a human can <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> provide? <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\">Alex</span>: That's a great point. The integration of AI in healthcare does raise ethical questions. For example, who <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> is responsible if an AI system makes a mistake? And how do we ensure that these systems are free from bias? <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\">Morgan</span>: Exactly. There's a lot to consider, but the potential benefits are enormous. Imagine a world where <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> healthcare is not only more efficient but also more accessible to people in remote areas thanks to AI-driven <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> telemedicine. <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\">Alex</span>: It's a fascinating time for healthcare, no doubt. But let's shift gears a bit and talk about another <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> pressing issue: climate change and global policy. According to a report from <a href=\"https://news.example.com/climate-policy\" target=\"_blank\"><span style=\"color: #000080; text-decoration-color: #000080; text-decoration: underline\">News Example</span></a>, world leaders are <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> currently meeting to discuss new policies to combat 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\">Morgan</span>: Climate change is one of those issues that affects everyone, regardless of where you live. These global <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> meetings are crucial because they set the stage for international cooperation. But what are the main challenges <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> these leaders face? <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\">Alex</span>: One of the biggest challenges is balancing economic growth with environmental sustainability. Many <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> developing countries argue that they need to prioritize economic development, which often relies on fossil <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> fuels. Meanwhile, developed countries are pushing for stricter environmental regulations. <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\">Morgan</span>: It's a classic case of differing priorities. But there's also a growing recognition that climate change <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> doesn't respect borders. Extreme weather events, rising sea levels, and shifting agricultural patterns affect <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> us all. So, there's a real urgency to find common ground. <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\">Alex</span>: And technology plays a significant role here too. Innovations in renewable energy, carbon capture, and <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> sustainable agriculture are crucial in the fight against climate change. But implementing these technologies on <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> a global scale requires significant investment and political will. <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\">Morgan</span>: It's a complex issue, but it's encouraging to see world leaders coming together to address it. The <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> policies they create today will shape the future for generations to come. <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\">Alex</span>: Absolutely. And it's not just about government action. Individuals and businesses also have a role to <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> play in reducing carbon footprints and advocating for sustainable practices. <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\">Morgan</span>: It's a collective effort, and every little bit helps. Before we wrap up, Alex, any final thoughts on <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> today's topics? <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\">Alex</span>: Just that both AI in healthcare and climate change policies highlight the intersection of technology and <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> society. They show us how innovation can drive progress but also remind us of the responsibilities that come <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> with 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=\"font-weight: bold\">Morgan</span>: Well said, Alex. It's all about finding that balance. And with that, we've reached the end of today's <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> episode. Thanks for tuning in to \"The World Today.\" <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\">Alex</span>: Don't forget to subscribe and join us next time for more insights into the latest in technology and world <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> news. <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\">Morgan</span>: Until then, stay informed and stay curious! <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> [OUTRO MUSIC FADES OUT] <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
|
||||
"</pre>\n"
|
||||
]
|
||||
},
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
"output_type": "stream",
|
||||
"name": "stdout",
|
||||
"text": [
|
||||
"=== Podcast Script ===\n",
|
||||
"[INTRO MUSIC FADES IN]\n",
|
||||
"\n",
|
||||
"**Alex**: Hello and welcome to another episode of \"The World Today,\" where we dive into the latest in technology and world news. I'm Alex, your go-to for all things analytical and fact-focused.\n",
|
||||
"\n",
|
||||
"**Morgan**: And I'm Morgan, here to explore the human impact and social context of today's stories. We've got a fascinating lineup for you today, so let's dive right in!\n",
|
||||
"\n",
|
||||
"**Alex**: First up, we're talking about a topic that's been making waves across the healthcare industry: the role of artificial intelligence. According to a recent article from [News Example](https://news.example.com/ai-healthcare), AI is revolutionizing healthcare in ways we could only dream of a decade ago.\n",
|
||||
"\n",
|
||||
"**Morgan**: That's right, Alex. AI is not just a buzzword anymore; it's actively changing how we approach healthcare. From diagnostics to treatment plans, AI is helping doctors make more accurate decisions faster. But what does this mean for patients and healthcare professionals?\n",
|
||||
"\n",
|
||||
"**Alex**: Well, Morgan, AI's ability to analyze vast amounts of data quickly means that doctors can diagnose diseases earlier and more accurately. For instance, AI algorithms can now detect patterns in medical imaging that might be too subtle for the human eye. This can lead to earlier interventions and better patient outcomes.\n",
|
||||
"\n",
|
||||
"**Morgan**: And let's not forget about the human side of things. For patients, this means less waiting time for results and potentially more personalized treatment plans. But there's also a concern about the human touch in healthcare. How do we balance the efficiency of AI with the empathy and understanding that only a human can provide?\n",
|
||||
"\n",
|
||||
"**Alex**: That's a great point. The integration of AI in healthcare does raise ethical questions. For example, who is responsible if an AI system makes a mistake? And how do we ensure that these systems are free from bias?\n",
|
||||
"\n",
|
||||
"**Morgan**: Exactly. There's a lot to consider, but the potential benefits are enormous. Imagine a world where healthcare is not only more efficient but also more accessible to people in remote areas thanks to AI-driven telemedicine.\n",
|
||||
"\n",
|
||||
"**Alex**: It's a fascinating time for healthcare, no doubt. But let's shift gears a bit and talk about another pressing issue: climate change and global policy. According to a report from [News Example](https://news.example.com/climate-policy), world leaders are currently meeting to discuss new policies to combat climate change.\n",
|
||||
"\n",
|
||||
"**Morgan**: Climate change is one of those issues that affects everyone, regardless of where you live. These global meetings are crucial because they set the stage for international cooperation. But what are the main challenges these leaders face?\n",
|
||||
"\n",
|
||||
"**Alex**: One of the biggest challenges is balancing economic growth with environmental sustainability. Many developing countries argue that they need to prioritize economic development, which often relies on fossil fuels. Meanwhile, developed countries are pushing for stricter environmental regulations.\n",
|
||||
"\n",
|
||||
"**Morgan**: It's a classic case of differing priorities. But there's also a growing recognition that climate change doesn't respect borders. Extreme weather events, rising sea levels, and shifting agricultural patterns affect us all. So, there's a real urgency to find common ground.\n",
|
||||
"\n",
|
||||
"**Alex**: And technology plays a significant role here too. Innovations in renewable energy, carbon capture, and sustainable agriculture are crucial in the fight against climate change. But implementing these technologies on a global scale requires significant investment and political will.\n",
|
||||
"\n",
|
||||
"**Morgan**: It's a complex issue, but it's encouraging to see world leaders coming together to address it. The policies they create today will shape the future for generations to come.\n",
|
||||
"\n",
|
||||
"**Alex**: Absolutely. And it's not just about government action. Individuals and businesses also have a role to play in reducing carbon footprints and advocating for sustainable practices.\n",
|
||||
"\n",
|
||||
"**Morgan**: It's a collective effort, and every little bit helps. Before we wrap up, Alex, any final thoughts on today's topics?\n",
|
||||
"\n",
|
||||
"**Alex**: Just that both AI in healthcare and climate change policies highlight the intersection of technology and society. They show us how innovation can drive progress but also remind us of the responsibilities that come with it.\n",
|
||||
"\n",
|
||||
"**Morgan**: Well said, Alex. It's all about finding that balance. And with that, we've reached the end of today's episode. Thanks for tuning in to \"The World Today.\"\n",
|
||||
"\n",
|
||||
"**Alex**: Don't forget to subscribe and join us next time for more insights into the latest in technology and world news.\n",
|
||||
"\n",
|
||||
"**Morgan**: Until then, stay informed and stay curious!\n",
|
||||
"\n",
|
||||
"[OUTRO MUSIC FADES OUT]\n"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
File renamed without changes.
+2
-2
@@ -153,7 +153,7 @@
|
||||
" - Spot content patterns and trends\n",
|
||||
" - Recommend growth strategies\n",
|
||||
" - Detect potential monetization methods\n",
|
||||
"llm: gpt-4o\n",
|
||||
"llm: gpt-5-nano\n",
|
||||
"verbosity: true\n",
|
||||
"format: markdown\n",
|
||||
"\"\"\"\n"
|
||||
@@ -184,7 +184,7 @@
|
||||
"You are a YouTube intelligence analyst. Your job is to research a specific channel, niche, or influencer topic.\n",
|
||||
"Provide growth recommendations, engagement analysis, trending strategies, and monetization tips. Format in markdown.\n",
|
||||
"\"\"\",\n",
|
||||
" llm=\"gpt-4o\",\n",
|
||||
" llm=\"gpt-5-nano\",\n",
|
||||
" verbose=True,\n",
|
||||
" markdown=True\n",
|
||||
")\n"
|
||||
File diff suppressed because it is too large.
Load diff
+3
-3
@@ -17,7 +17,7 @@
|
||||
"id": "Y9FkDzt1lF47"
|
||||
},
|
||||
"source": [
|
||||
"This notebook implements a conversational restaurant booking assistant using the Praison AI Agent framework. It handles natural interruptions such as modifying guest count or changing time mid-conversation. Built for Google Colab Free Tier, it uses OpenAI's GPT-4o model and follows a YAML-based agent design for clarity and modularity."
|
||||
"This notebook implements a conversational restaurant booking assistant using the Praison AI Agent framework. It handles natural interruptions such as modifying guest count or changing time mid-conversation. Built for Google Colab Free Tier, it uses OpenAI's gpt-5-nano model and follows a YAML-based agent design for clarity and modularity."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -135,7 +135,7 @@
|
||||
" - Context management\n",
|
||||
" - Handling mid-conversation changes\n",
|
||||
" - Summarizing confirmed reservations\n",
|
||||
"llm: gpt-4o\n",
|
||||
"llm: gpt-5-nano\n",
|
||||
"verbosity: true\n",
|
||||
"format: markdown\n",
|
||||
"\"\"\"\n"
|
||||
@@ -167,7 +167,7 @@
|
||||
"manage corrections like “change to 3 guests” or “move to 8 PM,”\n",
|
||||
"confirm the details once the user is satisfied. Respond in markdown.\n",
|
||||
"\"\"\",\n",
|
||||
" llm=\"gpt-4o\",\n",
|
||||
" llm=\"gpt-5-nano\",\n",
|
||||
" verbose=True,\n",
|
||||
" markdown=True\n",
|
||||
")\n"
|
||||
@@ -0,0 +1,618 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "wd6157NQTqfU",
|
||||
"metadata": {
|
||||
"id": "wd6157NQTqfU"
|
||||
},
|
||||
"source": [
|
||||
"# 🔍 NLP + ASR Agent (Official BERT Large + Whisper Large V3)\n",
|
||||
"This notebook runs an agent with:\n",
|
||||
"- 🤖 **BERT Large Cased** for text classification or embedding\n",
|
||||
"- 🎙️ **Whisper Large V3** for audio transcription\n",
|
||||
"\n",
|
||||
"✅ Compatible with Google Colab Free (if Whisper uses fp16 and BERT is used efficiently)\n",
|
||||
"---"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "TD8pkIV8er1I",
|
||||
"metadata": {
|
||||
"id": "TD8pkIV8er1I"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/bert_whisper_agent.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "xQ1v5o47ejyu",
|
||||
"metadata": {
|
||||
"id": "xQ1v5o47ejyu"
|
||||
},
|
||||
"source": [
|
||||
"# Install required libraries"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "8yb2sVk7TqfX",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "8yb2sVk7TqfX",
|
||||
"outputId": "13896ab6-f048-4850-d601-68435d0e0e8f"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"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[31m30.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[31m18.5 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.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.7 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[31m4.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[31m10.4 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.9 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[31m26.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[?25h"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\n",
|
||||
"!pip install -q transformers torchaudio accelerate torch"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "-YcKPAAhelsQ",
|
||||
"metadata": {
|
||||
"id": "-YcKPAAhelsQ"
|
||||
},
|
||||
"source": [
|
||||
"# Load BERT Large for text analysis"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "Ppdx98tJTqfY",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 177,
|
||||
"referenced_widgets": [
|
||||
"ef64ca729ce24516b53f811439c922de",
|
||||
"d86e086af653488bb3bb4daa1bc420fa",
|
||||
"18c04cece0c54cbb87cbb2391cc7150c",
|
||||
"62ad256a8769475daf4e8aacbdb10379",
|
||||
"0b1a3559484845c68d11951e9016a359",
|
||||
"293bdc33534349088e329d186645f643",
|
||||
"5da3f8d139a141a7b5ae2b87b8ab3a46",
|
||||
"083de2b5fc4843f99e778e8aa453c1b8",
|
||||
"41d9cffa0ec94a0f99c6a3e27dc97017",
|
||||
"bbc1dcfe4d0c4cef8574d6a09db2a32a",
|
||||
"ca9a87cbd99d491194edc4572ef7dc80",
|
||||
"7ea44cea34114e6784ebc339d78a8cb0",
|
||||
"0e0b43792f6e40aba2db124c465eb112",
|
||||
"2c36bed80a05477b85c7fdd07824a0d5",
|
||||
"0489bdfa20794a36a2757e75930fdeca",
|
||||
"9833eb7529f1470a95c67134c198ed70",
|
||||
"5986111ae7a34d9aa66278a6c9925960",
|
||||
"408c73a369194ca2b6585dba212727c2",
|
||||
"aec9f86597c842e388bfc7e495b702ab",
|
||||
"2b5a6970568d46f5a12d6f1c7bb9e4ee",
|
||||
"41597e7ccca34bc5ae22562260e764d1",
|
||||
"8b3f68f1e84e4af9a29c57447ff94027",
|
||||
"71296dd2da5e4c3d92d28204718d1d13",
|
||||
"ba135575d04048bea21a7ae63085e89f",
|
||||
"56bf69ca381f4c1895a15b61db7957e0",
|
||||
"16178169fc7a4b4b8ba39038b332bfb2",
|
||||
"692da53093d74e9bbba1c650ac7e6039",
|
||||
"4419b35b980c401997962e7c2bfe4672",
|
||||
"52c86dc445a24c5c9e2b8a02f12b9fb3",
|
||||
"858e97e2461d4b69bce55afac2a91c9b",
|
||||
"9a616db2cadb4618aa6492f1a1bef867",
|
||||
"2631be99ee604ca6859060402811e990",
|
||||
"b015448b956347b3867f19a8d5189517",
|
||||
"5a1baf78fe7e43f1bef9349959c643b2",
|
||||
"8aa423668aa545bbb6c3f332668b9bf5",
|
||||
"818e6bb7bb8b4f36ab47b511d8eea4f2",
|
||||
"879036aa5880478c80175ae0862cafc0",
|
||||
"1e61b33581e9499e81bc710e4d09d856",
|
||||
"ca424a49bdaa4653921f04f66295df8e",
|
||||
"3841511d0a714a328b58deeb4f185b3b",
|
||||
"ea6303e7aa264f739950572ec3eae4aa",
|
||||
"761736c6489e458fad5d258ed8e6485e",
|
||||
"15e90216f6c24b578106a08846739fcb",
|
||||
"f787c65d91b8477f8a6a199c57075dc8",
|
||||
"1ed0be1c90814e2c9f44b30f81db86b8",
|
||||
"80a88d56d5094e9ab4a21c68f02548e9",
|
||||
"1e0a05a8ca454a49addd483ee686d868",
|
||||
"9c933fdac2df4769bba416b241ce78ed",
|
||||
"a034c602568e4174a003045319c4f7ee",
|
||||
"db3c2fc0735d463694876e49ccbbd9d3",
|
||||
"1eaed0a8fdd94fd696431895e257c725",
|
||||
"94b7fba203734eca84683d121cac4197",
|
||||
"a0eb239bc63d44fd9866bd7b459a4bad",
|
||||
"c48ddcd435f547818779302134f21e66",
|
||||
"0c8d80a1ed8c4ad2b8921865064a9d3a"
|
||||
]
|
||||
},
|
||||
"id": "Ppdx98tJTqfY",
|
||||
"outputId": "cb35f398-ef79-4864-f5e9-4556fd05a936"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "ef64ca729ce24516b53f811439c922de",
|
||||
"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": "7ea44cea34114e6784ebc339d78a8cb0",
|
||||
"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": "71296dd2da5e4c3d92d28204718d1d13",
|
||||
"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": "5a1baf78fe7e43f1bef9349959c643b2",
|
||||
"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": "1ed0be1c90814e2c9f44b30f81db86b8",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"tokenizer.json: 0%| | 0.00/436k [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\n",
|
||||
"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) # Sentence embedding"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "bEjDTqPrens-",
|
||||
"metadata": {
|
||||
"id": "bEjDTqPrens-"
|
||||
},
|
||||
"source": [
|
||||
"# Load Whisper Large V3 for audio transcription"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "R0AGFFqTTqfY",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 369,
|
||||
"referenced_widgets": [
|
||||
"012a21936d6c4884a7b84b2767584b58",
|
||||
"99d6c0fad4b748aa8738fa9a35f4e96f",
|
||||
"8ddf19cbbe724f58800c702b28e37801",
|
||||
"f2881943ec1b48e8b5ace9484815820c",
|
||||
"d6882c4c225a4b04af77d282bd7ce548",
|
||||
"8ae9c3217d4242bb913f6c2af6e0e19b",
|
||||
"0620a81309e249f490509ad62ce8afb6",
|
||||
"7debeb90d88546478719e8a625cb38fb",
|
||||
"07e65c48f16d4f9295ac639dd4b0b5c9",
|
||||
"036a8f64dc44488cabd463e1c15c4c91",
|
||||
"a9cb91371c374c288ee9b06d68327362",
|
||||
"350dbbd7e33d4a38865a41a85f0da780",
|
||||
"abbf7218263e44109604bac835e9e313",
|
||||
"294dd7f394114d8d893e9a5242099f71",
|
||||
"f4cc15dc389049c2b779439de6a59468",
|
||||
"c4480e04078a4c4cb65f7eeb87bd2183",
|
||||
"6a60214efc17431fac99e020321ddb64",
|
||||
"d24212a4256a436fbb5ae2eac6cb8c74",
|
||||
"bc6495fabaf6473a83c0c3a8a1b08422",
|
||||
"fdf9507288f34b578f59afb403e8a899",
|
||||
"c4c9f720c9eb4a71ad46bdf732273ed9",
|
||||
"567034a346624e1896bca65ea663ad08",
|
||||
"d5c0f34255d04845acee22ab2fd11275",
|
||||
"0d58eb843d174c15aee2f4877295d115",
|
||||
"0fd2307c7b894d68889f71345f48a2ad",
|
||||
"0ef40308eecb4817be0b56cdda125c38",
|
||||
"d673a07a18a54c5b915a8fa6580583bc",
|
||||
"2b73ef94e8f94aa1ab5e28cf3ae09a30",
|
||||
"75ad342121b3429aae7bbcf3aaf04fef",
|
||||
"dbb026b79b724d68a5eecbf6bf5fd957",
|
||||
"4d1c52a7062846ad8faf47d7aafb4127",
|
||||
"50c1e37bb01340ee8fbd09a4d9510fe9",
|
||||
"b29fb4842efc453b8f76e15859c091d9",
|
||||
"49cfe6d1837f4e16b8d7a9f7a622977b",
|
||||
"a75a0c15bc194163af7091e40ff31aa0",
|
||||
"598aebd58dae453d9be0bd515b2b6cd6",
|
||||
"98c7dbcdaf114ef0818c6a29200f414d",
|
||||
"6a0dc52da74949ffb8a5f4d8b81ba69e",
|
||||
"67adcfbdf31b4606b5b123402bbf1829",
|
||||
"db13444109ba4a4f828f402a1798f44f",
|
||||
"772e4b8bf52a4e098e76445a65487a4e",
|
||||
"79712d86e8fa432a8cdd055097429d81",
|
||||
"6b6a84ea89a64b208ef6989173e7b6c5",
|
||||
"fee4b1fe846c4c90b5a81f7344d9d2fa",
|
||||
"1859b8e9773d490880fb8f482bb2df7f",
|
||||
"3739191045f749209730cba003eb6ea0",
|
||||
"b9d5984462a243bbb490152374f00164",
|
||||
"d42b2cf9e5c849aa8297d85978340fa4",
|
||||
"4efc347cbbc54c1eb63edf2d1dd997c3",
|
||||
"be19baf94af44562b2392094688dff8c",
|
||||
"2d29827b9e154631bb2fdfbba8ad2e4f",
|
||||
"d82000f2e8524367b11b1736e4eed376",
|
||||
"a9e75f229ab04b1fb062d3dabe40d02e",
|
||||
"06445a9779894cef921650facc3cb915",
|
||||
"f9f294ebc94c40eab79b061bda373d60",
|
||||
"8549e6d45d904cb9860807c2114939f6",
|
||||
"329eb033407541e9a2c5854378d5bba9",
|
||||
"635ca5b07be2495eaafa5126637ee427",
|
||||
"43b284140ef14a0db4d9164d12333540",
|
||||
"902398ce9f8143478a3889c1af9693e9",
|
||||
"0bc9e112c9a2485fba38cad1e620d6d4",
|
||||
"dcdb799810e84d0b8de6a471b256fe46",
|
||||
"8b726a505b43413d853b1f5ba0404fd9",
|
||||
"b6b50da93bab490f8abf19930fa28f46",
|
||||
"2883a49d53fd4c0c9d4e97edf0005b9b",
|
||||
"0f88de1a2bce4af6be5c3cb88d0c0b17",
|
||||
"05d137a7667346abafdc2290320fedc2",
|
||||
"d1de71b61b6b442ab60e5c9d8d745cbe",
|
||||
"3662758074254935846f6eef56e6afd9",
|
||||
"43aa89322bc94fc3ab06ec84cf9b80b6",
|
||||
"9da6ad199a574479a75010da5b1a22dc",
|
||||
"6826f0af1489463f9e5bebcf422cf000",
|
||||
"486accbedd1648fe877cbafe9ceaf5a3",
|
||||
"ff7b49296a6440bf84f8734afc9a8a7b",
|
||||
"cb3b611a6ef04cd7a6a781dee1d0128d",
|
||||
"963c8f0e2cbb4a6a857a05e41b9cdc41",
|
||||
"4e551605bba34d12af90a9edb443e334",
|
||||
"87a22b9d9c9a4e0691a77fd34f15be4a",
|
||||
"327ba03562814fffaa695770e1f50235",
|
||||
"76551436a17f482fa16131b4985720a4",
|
||||
"86558c51b63b42fc9372779dd777379c",
|
||||
"b52881719c6a49a1a2dbbc906571d996",
|
||||
"71bd0c63a6564923b6c12cfd95bd0f99",
|
||||
"8126ef033a5d4beb9fe5ecb126d817b8",
|
||||
"557d5fa2a6404473960c9ad2d8ac9f61",
|
||||
"2d21c4ff75f549308297f7d38238ba60",
|
||||
"0a8b5af0b1e547ca9373b63f23724a52",
|
||||
"41448615087f4344a58a862d00ab7b60",
|
||||
"e801569aba0b4f51814d7498a362ae69",
|
||||
"259fd1045f3c451fb5b2bd8df2ff47fc",
|
||||
"cb885f28dcee412381d52e063a5d058b",
|
||||
"c5728b07bb224c4fb0ca656fa64b1137",
|
||||
"7b75953a78c847688eed9106a38bfec7",
|
||||
"e330f81594ea46cea5c4e94206144605",
|
||||
"bddcbf3209db4872aee6a7a6d8e57fdc",
|
||||
"32154e90fdbf4ca1a293a8c6c5d8ffd9",
|
||||
"ebc78e4a82d9430d8cc9047986e96185",
|
||||
"d0d664ee23ad47c6b6bb193eafcdfbf1",
|
||||
"1c39b174d83146e8a05b0af82c0191ef",
|
||||
"7972b5df2e4e465d868dbc827850e7a4",
|
||||
"e31441e745c04c308be3e81ebacf31c4",
|
||||
"f7a2d47725fc45d0b2f65b81b8cfa925",
|
||||
"f3f13df2d56a445ca472633188318b33",
|
||||
"37b8a1408f284eefb36be7c7babd3aa7",
|
||||
"0a2b79b882154b54bfd13090bf67af07",
|
||||
"eddcb5465f5648b69ac37c03887e494c",
|
||||
"49626d83e7c1403880ce17324fa7a514",
|
||||
"ddc300dd7e504840bc9dffd4666c0984",
|
||||
"b134fdc0b30445fa819a39bde44704d3",
|
||||
"61ce458fc45e4c709f6e4e2af9b4c881",
|
||||
"459a2c675632454c83a62b564853a6f3",
|
||||
"8b90fbbf1d234202b6aaec0a624874d9",
|
||||
"f104a1f9546e4f54ab86a44a4649ea33",
|
||||
"ae01037b6e084a15b0310cedfc0a6d53",
|
||||
"5050d0dbcfcc426f925fe39ecc975a72",
|
||||
"f2855e5586ce429da7472c9bcef8a88b",
|
||||
"05442b45864d417ab37710e2b3a9d05b",
|
||||
"68f72ed9e852416798a42c6a1147e540",
|
||||
"a6230b708cc24e9c85b9704ec0ece351",
|
||||
"62ff7ab4106648d4a2bc07b3048e1857",
|
||||
"3b1be73a026a4ea0b5686f10db107e3c"
|
||||
]
|
||||
},
|
||||
"id": "R0AGFFqTTqfY",
|
||||
"outputId": "31805e6b-a58c-49cc-ae17-a2c20c5e0077"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "012a21936d6c4884a7b84b2767584b58",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"preprocessor_config.json: 0%| | 0.00/340 [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "350dbbd7e33d4a38865a41a85f0da780",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"tokenizer_config.json: 0%| | 0.00/283k [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "d5c0f34255d04845acee22ab2fd11275",
|
||||
"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": "49cfe6d1837f4e16b8d7a9f7a622977b",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"tokenizer.json: 0%| | 0.00/2.48M [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "1859b8e9773d490880fb8f482bb2df7f",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"merges.txt: 0%| | 0.00/494k [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "8549e6d45d904cb9860807c2114939f6",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"normalizer.json: 0%| | 0.00/52.7k [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "05d137a7667346abafdc2290320fedc2",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"added_tokens.json: 0%| | 0.00/34.6k [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "87a22b9d9c9a4e0691a77fd34f15be4a",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"special_tokens_map.json: 0%| | 0.00/2.07k [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "e801569aba0b4f51814d7498a362ae69",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"config.json: 0%| | 0.00/1.27k [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "7972b5df2e4e465d868dbc827850e7a4",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"model.safetensors: 0%| | 0.00/3.09G [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "459a2c675632454c83a62b564853a6f3",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"generation_config.json: 0%| | 0.00/3.90k [00:00<?, ?B/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\n",
|
||||
"import torchaudio\n",
|
||||
"from transformers import WhisperProcessor, WhisperForConditionalGeneration\n",
|
||||
"\n",
|
||||
"processor = WhisperProcessor.from_pretrained(\"openai/whisper-large-v3\")\n",
|
||||
"model = WhisperForConditionalGeneration.from_pretrained(\"openai/whisper-large-v3\")\n",
|
||||
"model = model.to(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
|
||||
"\n",
|
||||
"def transcribe_audio(file_path):\n",
|
||||
" audio, rate = torchaudio.load(file_path)\n",
|
||||
" if rate != 16000:\n",
|
||||
" resampler = torchaudio.transforms.Resample(orig_freq=rate, new_freq=16000)\n",
|
||||
" audio = resampler(audio)\n",
|
||||
" input_features = processor(audio.squeeze().numpy(), sampling_rate=16000, return_tensors=\"pt\").input_features\n",
|
||||
" input_features = input_features.to(model.device)\n",
|
||||
" predicted_ids = model.generate(input_features)\n",
|
||||
" return processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "dSQGzAiGeqUS",
|
||||
"metadata": {
|
||||
"id": "dSQGzAiGeqUS"
|
||||
},
|
||||
"source": [
|
||||
"# Example BERT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "7Q40yeA_TqfZ",
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "7Q40yeA_TqfZ",
|
||||
"outputId": "64785b48-77e1-4cd9-9d9b-6dec9e34b45c"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"BERT embedding shape: torch.Size([1, 1024])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Example usage (requires uploaded audio file like sample.wav)\n",
|
||||
"# from google.colab import files\n",
|
||||
"# uploaded = files.upload()\n",
|
||||
"# print(transcribe_audio(\"sample.wav\"))\n",
|
||||
"\n",
|
||||
"embedding = classify_text(\"Google Colab is a great place to run small-scale NLP models.\")\n",
|
||||
"print(\"BERT embedding shape:\", embedding.shape)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python",
|
||||
"version": "3.10"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,355 +0,0 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "_T4g3t5sLoag"
|
||||
},
|
||||
"source": [
|
||||
"# ZeroScript: AI-Powered Browser Test Automation using PraisonAI Agent & OpenAI"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "O4PKfpalLsmn"
|
||||
},
|
||||
"source": [
|
||||
"# Description"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "CEG1pfumLysm"
|
||||
},
|
||||
"source": [
|
||||
"AI-powered browser testing using PraisonAI Agent and OpenAI. Executes YAML-defined test cases, captures screenshots, logs interactions, and generates JSON reports. Ideal for intelligent, automated UI testing.\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "lbgxOG4gL1Wf"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/ZeroScript_AI_TestExecutor.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "WCJqMUzXIndh"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 34,
|
||||
"metadata": {
|
||||
"id": "9AQhJ59cJPmR"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install --quiet praisonaiagents browser-use python-dotenv pyyaml openai\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "QD-dF-6_It1z"
|
||||
},
|
||||
"source": [
|
||||
"# Environment Setup"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 35,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "QkRQDli4JhCV",
|
||||
"outputId": "4b8957ed-a37a-4b11-8585-3537a0437d40"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"True"
|
||||
]
|
||||
},
|
||||
"execution_count": 35,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"from dotenv import load_dotenv\n",
|
||||
"\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = \"Enter your key\" # replace with actual key\n",
|
||||
"load_dotenv()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "ELuogWnrIw3o"
|
||||
},
|
||||
"source": [
|
||||
"# Create my_secrets.py"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 36,
|
||||
"metadata": {
|
||||
"id": "sG6tO_v0Jm5N"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"with open(\"my_secrets.py\", \"w\") as f:\n",
|
||||
" f.write('''sensitive_data = {\n",
|
||||
" \"username\": \"standard_user\",\n",
|
||||
" \"password\": \"secret_sauce\"\n",
|
||||
"}''')\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "rDB_viedIzRR"
|
||||
},
|
||||
"source": [
|
||||
"# Create views.py"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 37,
|
||||
"metadata": {
|
||||
"id": "CtwcybdbJoV8"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"with open(\"views.py\", \"w\") as f:\n",
|
||||
" f.write('''\n",
|
||||
"from pydantic import BaseModel\n",
|
||||
"\n",
|
||||
"class TestResult(BaseModel):\n",
|
||||
" status: str\n",
|
||||
" message: str = \"\"\n",
|
||||
"''')\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "YTRmBpTiI1kd"
|
||||
},
|
||||
"source": [
|
||||
"# Create agent.py"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 38,
|
||||
"metadata": {
|
||||
"id": "zdJJGt6TJpvr"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"with open(\"agent.py\", \"w\") as f:\n",
|
||||
" f.write('''\n",
|
||||
"import os\n",
|
||||
"from praisonaiagents import Agent\n",
|
||||
"from browser_use import Browser, BrowserConfig, Controller\n",
|
||||
"from browser_use.browser.context import BrowserContext, BrowserContextConfig\n",
|
||||
"from openai import OpenAI\n",
|
||||
"from views import TestResult\n",
|
||||
"from my_secrets import sensitive_data\n",
|
||||
"\n",
|
||||
"# Browser setup\n",
|
||||
"browser = Browser(config=BrowserConfig(headless=True))\n",
|
||||
"context_cfg = BrowserContextConfig(save_recording_path=\"data/recordings\")\n",
|
||||
"controller = Controller(output_model=TestResult)\n",
|
||||
"\n",
|
||||
"async def browser_use(task: str):\n",
|
||||
" context = BrowserContext(browser=browser, config=context_cfg)\n",
|
||||
" agent = Agent(\n",
|
||||
" task=task,\n",
|
||||
" llm=OpenAI(api_key=os.getenv(\"OPENAI_API_KEY\"), model=\"gpt-4\"),\n",
|
||||
" browser_context=context,\n",
|
||||
" sensitive_data=sensitive_data,\n",
|
||||
" controller=controller,\n",
|
||||
" save_conversation_path=\"data/conversations/convo\",\n",
|
||||
" extend_system_message=(\n",
|
||||
" \"You are a professional software tester. Execute browser test steps precisely.\"\n",
|
||||
" )\n",
|
||||
" )\n",
|
||||
" response = await agent.run()\n",
|
||||
" await context.close()\n",
|
||||
" return response\n",
|
||||
"''')\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "-LZtQIE3I4-_"
|
||||
},
|
||||
"source": [
|
||||
"# Create Sample Test YAML"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 39,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "l1OdXYI-JreK",
|
||||
"outputId": "62323fcd-c74f-498f-defc-2c170fa8983e"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"350"
|
||||
]
|
||||
},
|
||||
"execution_count": 39,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from pathlib import Path\n",
|
||||
"tests_dir = Path(\"tests\")\n",
|
||||
"tests_dir.mkdir(exist_ok=True)\n",
|
||||
"yaml_content = \"\"\"\n",
|
||||
"hooks:\n",
|
||||
" beforeEach: |\n",
|
||||
" Navigate to https://www.saucedemo.com\n",
|
||||
" afterEach: |\n",
|
||||
" Take screenshot\n",
|
||||
"\n",
|
||||
"tests:\n",
|
||||
" - id: \"login_test_001\"\n",
|
||||
" name: \"Valid Login Test\"\n",
|
||||
" instructions: |\n",
|
||||
" 1. Enter standard_user in username field\n",
|
||||
" 2. Enter secret_sauce in password field\n",
|
||||
" 3. Click login button\n",
|
||||
" 4. Verify page contains text \"Products\"\n",
|
||||
"\"\"\"\n",
|
||||
"(Path(\"tests/login_test.yml\")).write_text(yaml_content)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "sUjy-7OdI7p_"
|
||||
},
|
||||
"source": [
|
||||
"# Run Tests"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 40,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "Agkiwh7xJtY3",
|
||||
"outputId": "759aa77c-fd65-49b8-b239-550588059478"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Exception ignored in: <function BrowserSession.__del__ at 0x7e2f540fb100>\n",
|
||||
"Traceback (most recent call last):\n",
|
||||
" File \"/usr/local/lib/python3.11/dist-packages/browser_use/browser/session.py\", line 497, in __del__\n",
|
||||
" status = f'🪓 killing pid={self.browser_pid}...' if (self.browser_pid and owns_browser) else '☠️'\n",
|
||||
" ^^^^^^^^^^^^^^^^\n",
|
||||
" File \"/usr/local/lib/python3.11/dist-packages/pydantic/main.py\", line 991, in __getattr__\n",
|
||||
" raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')\n",
|
||||
"AttributeError: 'BrowserSession' object has no attribute 'browser_pid'\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"✅ Report saved to data/reports/report_20250630_092319.json\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import asyncio, yaml, json, base64, shutil\n",
|
||||
"from agent import browser_use, browser\n",
|
||||
"from pathlib import Path\n",
|
||||
"from datetime import datetime\n",
|
||||
"\n",
|
||||
"# Clean or create data dirs\n",
|
||||
"for sub in [\"recordings\", \"conversations\", \"screenshots\", \"reports\"]:\n",
|
||||
" d = Path(\"data\") / sub\n",
|
||||
" if d.exists(): shutil.rmtree(d)\n",
|
||||
" d.mkdir(parents=True, exist_ok=True)\n",
|
||||
"\n",
|
||||
"async def execute_test_file(path):\n",
|
||||
" cfg = yaml.safe_load(Path(path).read_text())\n",
|
||||
" hooks, results = cfg.get(\"hooks\", {}), []\n",
|
||||
" for t in cfg[\"tests\"]:\n",
|
||||
" task = f\"{hooks.get('beforeEach','')}\\n{t['instructions']}\\n{hooks.get('afterEach','')}\"\n",
|
||||
" res = {\"id\": t[\"id\"], \"name\": t[\"name\"]}\n",
|
||||
" try:\n",
|
||||
" r = await browser_use(task)\n",
|
||||
" imgs = r.screenshots()\n",
|
||||
" if imgs:\n",
|
||||
" out = Path(\"data/screenshots\") / f\"{t['id']}.png\"\n",
|
||||
" out.write_bytes(base64.b64decode(imgs[-1]))\n",
|
||||
" result_obj = r.final_result() if hasattr(r, \"final_result\") else str(r)\n",
|
||||
" res[\"result\"] = result_obj.dict() if hasattr(result_obj, \"dict\") else str(result_obj)\n",
|
||||
" except Exception as e:\n",
|
||||
" res[\"error\"] = str(e)\n",
|
||||
" results.append(res)\n",
|
||||
" return results\n",
|
||||
"\n",
|
||||
"async def main():\n",
|
||||
" all_results = []\n",
|
||||
" for file in Path(\"tests\").glob(\"*.yml\"):\n",
|
||||
" all_results.extend(await execute_test_file(str(file)))\n",
|
||||
" report = Path(\"data/reports\") / f\"report_{datetime.now():%Y%m%d_%H%M%S}.json\"\n",
|
||||
" report.write_text(json.dumps(all_results, indent=2))\n",
|
||||
" await browser.close()\n",
|
||||
" print(f\"✅ Report saved to {report}\")\n",
|
||||
"\n",
|
||||
"await main()\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"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
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,481 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "LJRJRQtFTagH"
|
||||
},
|
||||
"source": [
|
||||
"# AI RAG Agent with Web Access using PraisonAI"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "Ph4RVTBCTcmB"
|
||||
},
|
||||
"source": [
|
||||
"This notebook demonstrates how to build a Retrieval-Augmented Generation (RAG) agent with web access using GPT-4o and PraisonAI. The agent specializes in Thai recipes and can search the web for additional information."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "tMxfwPPATy_o"
|
||||
},
|
||||
"source": [
|
||||
"This RAG agent:\n",
|
||||
"* Creates an AI assistant specialized in Thai recipes and cooking\n",
|
||||
"* Has access to a PDF knowledge base about Thai recipes\n",
|
||||
"* Can search the web using DuckDuckGo for additional information\n",
|
||||
"* Provides comprehensive answers about Thai cuisine\n",
|
||||
"* Uses PraisonAI framework for agent management"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "h68oMaCITmqt"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/rag_examples/agentic_rag/PraisonAI_RecipeAgent.ipynb)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "cAdzoWXJUMfF"
|
||||
},
|
||||
"source": [
|
||||
"# Dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "9D-2TlOrUNcu"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install praisonaiagents openai requests"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "yY-4-kEIUW40"
|
||||
},
|
||||
"source": [
|
||||
"# Set Up API Key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "f5bhQ05yUX6J",
|
||||
"outputId": "dcf9d0d9-332e-4136-9289-4c39d898005c"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Enter your OpenAI API key: ··········\n",
|
||||
"✅ API key set successfully!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"# Set your OpenAI API key here\n",
|
||||
"os.environ['OPENAI_API_KEY'] = 'Enter your api key here'\n",
|
||||
"\n",
|
||||
"# Or use this method to input it securely\n",
|
||||
"from getpass import getpass\n",
|
||||
"api_key = getpass('Enter your OpenAI API key: ')\n",
|
||||
"os.environ['OPENAI_API_KEY'] = api_key\n",
|
||||
"\n",
|
||||
"print(\"✅ API key set successfully!\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "Eh0j-SegUi13"
|
||||
},
|
||||
"source": [
|
||||
"# Tools"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "Z1A9oifIUkQN",
|
||||
"outputId": "9be78226-36fa-43c4-865d-2f7e6e2ba9de"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"✅ Tools imported successfully!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from praisonaiagents import Agent\n",
|
||||
"import requests\n",
|
||||
"import tempfile\n",
|
||||
"from pathlib import Path\n",
|
||||
"\n",
|
||||
"print(\"✅ Tools imported successfully!\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "efnnREHXUnYA"
|
||||
},
|
||||
"source": [
|
||||
"# YAML Prompt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "kcM14-yQUqG-",
|
||||
"outputId": "c5b6288d-a789-4a93-e20c-1d285370b667"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"✅ Agent instructions configured!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Agent configuration and instructions\n",
|
||||
"AGENT_INSTRUCTIONS = \"\"\"\n",
|
||||
"You are a helpful AI assistant specialized in Thai recipes and cooking.\n",
|
||||
"\n",
|
||||
"You have access to a PDF knowledge base about Thai recipes from: https://phi-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf\n",
|
||||
"\n",
|
||||
"You can also search the web for additional information about Thai cooking, ingredients, and techniques.\n",
|
||||
"\n",
|
||||
"When answering questions:\n",
|
||||
"1. Use your knowledge about Thai cuisine to provide helpful information\n",
|
||||
"2. If needed, search the web for additional details, current information, or clarification\n",
|
||||
"3. Provide comprehensive, helpful answers about Thai cuisine\n",
|
||||
"4. Always be informative and helpful about Thai cooking!\n",
|
||||
"\n",
|
||||
"You can use the internet_search function to search the web when needed.\n",
|
||||
"\n",
|
||||
"Focus on providing practical cooking advice, ingredient information, and authentic Thai recipe guidance.\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"print(\"✅ Agent instructions configured!\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "MCBRcXFJUulY"
|
||||
},
|
||||
"source": [
|
||||
"# Main"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "YaRLbgMmUvXv",
|
||||
"outputId": "8ed8d9f8-85a7-48de-ccc6-f617cd672a85"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"🤖 Thai Recipe RAG Agent created successfully!\n",
|
||||
"The agent is ready to answer questions about Thai cooking.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Create the RAG agent\n",
|
||||
"rag_agent = Agent(\n",
|
||||
" instructions=AGENT_INSTRUCTIONS,\n",
|
||||
" llm=\"gpt-4o\",\n",
|
||||
" markdown=True,\n",
|
||||
" verbose=True\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"print(\"🤖 Thai Recipe RAG Agent created successfully!\")\n",
|
||||
"print(\"The agent is ready to answer questions about Thai cooking.\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "QvZM94pGU0IX"
|
||||
},
|
||||
"source": [
|
||||
"# Test the Agent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000,
|
||||
"referenced_widgets": [
|
||||
"47739975c9f04ee5b4e69e8f445cbeda",
|
||||
"08888d583cba4c01b3fdf8f30b06ca4f"
|
||||
]
|
||||
},
|
||||
"id": "QPdrleKxU1VN",
|
||||
"outputId": "a71a86cd-eff8-4309-9b50-173a30066c90"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"🤔 Question: What are the essential ingredients for Thai cooking?\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": "47739975c9f04ee5b4e69e8f445cbeda",
|
||||
"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 8.4s</span>\n",
|
||||
"</pre>\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"\u001b[2mResponse generated in 8.4s\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 are the essential ingredients for Thai cooking? <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 are the essential ingredients for Thai cooking? \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> Thai cooking is known for its balance of five fundamental taste senses in each dish or the overall meal: sour, <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> sweet, salty, bitter, and spicy. Essential ingredients that help achieve this balance include: <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\">Fish Sauce (Nam Pla)</span>: A salty, savory sauce made from fermented fish. It's a cornerstone of Thai cooking, <span style=\"color: #008080; text-decoration-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>used to add depth of flavor. <span style=\"color: #008080; text-decoration-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\">Lime Juice</span>: Used to add a fresh, tangy citrus flavor to dishes, especially in salads and some curries. <span style=\"color: #008080; text-decoration-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\">Chilies</span>: Thai cuisine often features fresh Thai bird's eye chilies for heat, as well as dried chilies for <span style=\"color: #008080; text-decoration-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>certain recipes. <span style=\"color: #008080; text-decoration-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\">Lemongrass</span>: A citrusy, fragrant herb that is often used in soups, curries, and teas. <span style=\"color: #008080; text-decoration-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\">Galangal</span>: Similar to ginger, galangal has a sharp, peppery flavor and is used in soups and curries. <span style=\"color: #008080; text-decoration-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\">Kaffir Lime Leaves</span>: They add a distinct, zesty citrus aroma and flavor to Thai dishes. <span style=\"color: #008080; text-decoration-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\">Coconut Milk</span>: Adds richness and creaminess, commonly used in curries and desserts. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 8 </span><span style=\"font-weight: bold\">Palm Sugar</span>: Used as a sweetener, palm sugar has a nuanced flavor, unlike regular sugar. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 9 </span><span style=\"font-weight: bold\">Tamarind Paste</span>: Provides a sour element to many dishes, particularly pad Thai and some sauces. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 10 </span><span style=\"font-weight: bold\">Thai Basil</span>: Adds a spicy, peppery flavor, different from the sweet basil used in Western cooking. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 11 </span><span style=\"font-weight: bold\">Coriander (Cilantro)</span>: Used as a garnish and for its fresh, citrusy leaves and roots, which add depth 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>sauces and stocks. <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 12 </span><span style=\"font-weight: bold\">Shrimp Paste</span>: A very pungent paste made from fermented shrimp, used sparingly to enrich the flavor of <span style=\"color: #008080; text-decoration-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>dishes. <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 ingredients are commonly used in combination to create the complex and rich flavors characteristic of <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Thai cuisine. Fresh and high-quality versions of these ingredients contribute significantly to the authenticity <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
|
||||
"<span style=\"color: #008080; text-decoration-color: #008080\">│</span> of Thai dishes. <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 Thai cooking is known for its balance of five fundamental taste senses in each dish or the overall meal: sour, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m sweet, salty, bitter, and spicy. Essential ingredients that help achieve this balance include: \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[1mFish Sauce (Nam Pla)\u001b[0m: A salty, savory sauce made from fermented fish. It's a cornerstone of Thai cooking, \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mused to add depth of flavor. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mLime Juice\u001b[0m: Used to add a fresh, tangy citrus flavor to dishes, especially in salads and some curries. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0m\u001b[1mChilies\u001b[0m: Thai cuisine often features fresh Thai bird's eye chilies for heat, as well as dried chilies for \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mcertain recipes. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 4 \u001b[0m\u001b[1mLemongrass\u001b[0m: A citrusy, fragrant herb that is often used in soups, curries, and teas. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 5 \u001b[0m\u001b[1mGalangal\u001b[0m: Similar to ginger, galangal has a sharp, peppery flavor and is used in soups and curries. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 6 \u001b[0m\u001b[1mKaffir Lime Leaves\u001b[0m: They add a distinct, zesty citrus aroma and flavor to Thai dishes. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 7 \u001b[0m\u001b[1mCoconut Milk\u001b[0m: Adds richness and creaminess, commonly used in curries and desserts. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 8 \u001b[0m\u001b[1mPalm Sugar\u001b[0m: Used as a sweetener, palm sugar has a nuanced flavor, unlike regular sugar. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 9 \u001b[0m\u001b[1mTamarind Paste\u001b[0m: Provides a sour element to many dishes, particularly pad Thai and some sauces. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 10 \u001b[0m\u001b[1mThai Basil\u001b[0m: Adds a spicy, peppery flavor, different from the sweet basil used in Western cooking. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 11 \u001b[0m\u001b[1mCoriander (Cilantro)\u001b[0m: Used as a garnish and for its fresh, citrusy leaves and roots, which add depth to \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0msauces and stocks. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m 12 \u001b[0m\u001b[1mShrimp Paste\u001b[0m: A very pungent paste made from fermented shrimp, used sparingly to enrich the flavor of \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mdishes. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m These ingredients are commonly used in combination to create the complex and rich flavors characteristic of \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m Thai cuisine. Fresh and high-quality versions of these ingredients contribute significantly to the authenticity \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m│\u001b[0m of Thai dishes. \u001b[36m│\u001b[0m\n",
|
||||
"\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"�� Answer: Thai cooking is known for its balance of five fundamental taste senses in each dish or the overall meal: sour, sweet, salty, bitter, and spicy. Essential ingredients that help achieve this balance include:\n",
|
||||
"\n",
|
||||
"1. **Fish Sauce (Nam Pla)**: A salty, savory sauce made from fermented fish. It's a cornerstone of Thai cooking, used to add depth of flavor.\n",
|
||||
"\n",
|
||||
"2. **Lime Juice**: Used to add a fresh, tangy citrus flavor to dishes, especially in salads and some curries.\n",
|
||||
"\n",
|
||||
"3. **Chilies**: Thai cuisine often features fresh Thai bird's eye chilies for heat, as well as dried chilies for certain recipes.\n",
|
||||
"\n",
|
||||
"4. **Lemongrass**: A citrusy, fragrant herb that is often used in soups, curries, and teas.\n",
|
||||
"\n",
|
||||
"5. **Galangal**: Similar to ginger, galangal has a sharp, peppery flavor and is used in soups and curries.\n",
|
||||
"\n",
|
||||
"6. **Kaffir Lime Leaves**: They add a distinct, zesty citrus aroma and flavor to Thai dishes.\n",
|
||||
"\n",
|
||||
"7. **Coconut Milk**: Adds richness and creaminess, commonly used in curries and desserts.\n",
|
||||
"\n",
|
||||
"8. **Palm Sugar**: Used as a sweetener, palm sugar has a nuanced flavor, unlike regular sugar.\n",
|
||||
"\n",
|
||||
"9. **Tamarind Paste**: Provides a sour element to many dishes, particularly pad Thai and some sauces.\n",
|
||||
"\n",
|
||||
"10. **Thai Basil**: Adds a spicy, peppery flavor, different from the sweet basil used in Western cooking.\n",
|
||||
"\n",
|
||||
"11. **Coriander (Cilantro)**: Used as a garnish and for its fresh, citrusy leaves and roots, which add depth to sauces and stocks.\n",
|
||||
"\n",
|
||||
"12. **Shrimp Paste**: A very pungent paste made from fermented shrimp, used sparingly to enrich the flavor of dishes.\n",
|
||||
"\n",
|
||||
"These ingredients are commonly used in combination to create the complex and rich flavors characteristic of Thai cuisine. Fresh and high-quality versions of these ingredients contribute significantly to the authenticity of Thai dishes.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Test question 1: Basic Thai cooking\n",
|
||||
"question1 = \"What are the essential ingredients for Thai cooking?\"\n",
|
||||
"print(f\"🤔 Question: {question1}\")\n",
|
||||
"\n",
|
||||
"try:\n",
|
||||
" response1 = rag_agent.start(question1)\n",
|
||||
" print(f\"�� Answer: {response1}\")\n",
|
||||
"except Exception as e:\n",
|
||||
" print(f\"❌ Error: {e}\")"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
Loaded 100 of 704 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user