File size: 40,502 Bytes
5d2dd77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Welcome to the start of your adventure in Agentic AI"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<table style=\"margin: 0; text-align: left; width:100%\">\n",
    "    <tr>\n",
    "        <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",
    "            <img src=\"../assets/stop.png\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
    "        </td>\n",
    "        <td>\n",
    "            <h2 style=\"color:#ff7800;\">Are you ready for action??</h2>\n",
    "            <span style=\"color:#ff7800;\">Have you completed all the setup steps in the <a href=\"../setup/\">setup</a> folder?<br/>\n",
    "            Have you checked out the guides in the <a href=\"../guides/01_intro.ipynb\">guides</a> folder?<br/>\n",
    "            Well in that case, you're ready!!\n",
    "            </span>\n",
    "        </td>\n",
    "    </tr>\n",
    "</table>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<table style=\"margin: 0; text-align: left; width:100%\">\n",
    "    <tr>\n",
    "        <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",
    "            <img src=\"../assets/tools.png\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
    "        </td>\n",
    "        <td>\n",
    "            <h2 style=\"color:#00bfff;\">This code is a live resource - keep an eye out for my updates</h2>\n",
    "            <span style=\"color:#00bfff;\">I push updates regularly. As people ask questions or have problems, I add more examples and improve explanations. As a result, the code below might not be identical to the videos, as I've added more steps and better comments. Consider this like an interactive book that accompanies the lectures.<br/><br/>\n",
    "            I try to send emails regularly with important updates related to the course. You can find this in the 'Announcements' section of Udemy in the left sidebar. You can also choose to receive my emails via your Notification Settings in Udemy. I'm respectful of your inbox and always try to add value with my emails!\n",
    "            </span>\n",
    "        </td>\n",
    "    </tr>\n",
    "</table>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### And please do remember to contact me if I can help\n",
    "\n",
    "And I love to connect: https://www.linkedin.com/in/eddonner/\n",
    "\n",
    "\n",
    "### New to Notebooks like this one? Head over to the guides folder!\n",
    "\n",
    "Just to check you've already added the Python and Jupyter extensions to Cursor, if not already installed:\n",
    "- Open extensions (View >> extensions)\n",
    "- Search for python, and when the results show, click on the ms-python one, and Install it if not already installed\n",
    "- Search for jupyter, and when the results show, click on the Microsoft one, and Install it if not already installed  \n",
    "Then View >> Explorer to bring back the File Explorer.\n",
    "\n",
    "And then:\n",
    "1. Click where it says \"Select Kernel\" near the top right, and select the option called `.venv (Python 3.12.9)` or similar, which should be the first choice or the most prominent choice. You may need to choose \"Python Environments\" first.\n",
    "2. Click in each \"cell\" below, starting with the cell immediately below this text, and press Shift+Enter to run\n",
    "3. Enjoy!\n",
    "\n",
    "After you click \"Select Kernel\", if there is no option like `.venv (Python 3.12.9)` then please do the following:  \n",
    "1. On Mac: From the Cursor menu, choose Settings >> VS Code Settings (NOTE: be sure to select `VSCode Settings` not `Cursor Settings`);  \n",
    "On Windows PC: From the File menu, choose Preferences >> VS Code Settings(NOTE: be sure to select `VSCode Settings` not `Cursor Settings`)  \n",
    "2. In the Settings search bar, type \"venv\"  \n",
    "3. In the field \"Path to folder with a list of Virtual Environments\" put the path to the project root, like C:\\Users\\username\\projects\\agents (on a Windows PC) or /Users/username/projects/agents (on Mac or Linux).  \n",
    "And then try again.\n",
    "\n",
    "Having problems with missing Python versions in that list? Have you ever used Anaconda before? It might be interferring. Quit Cursor, bring up a new command line, and make sure that your Anaconda environment is deactivated:    \n",
    "`conda deactivate`  \n",
    "And if you still have any problems with conda and python versions, it's possible that you will need to run this too:  \n",
    "`conda config --set auto_activate_base false`  \n",
    "and then from within the Agents directory, you should be able to run `uv python list` and see the Python 3.12 version."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# First let's do an import\n",
    "from dotenv import load_dotenv\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Next it's time to load the API keys into environment variables\n",
    "\n",
    "load_dotenv(override=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "OpenAI API Key exists and begins sk-proj-\n"
     ]
    }
   ],
   "source": [
    "# Check the keys\n",
    "\n",
    "import os\n",
    "openai_api_key = os.getenv('OPENAI_API_KEY')\n",
    "\n",
    "if openai_api_key:\n",
    "    print(f\"OpenAI API Key exists and begins {openai_api_key[:8]}\")\n",
    "else:\n",
    "    print(\"OpenAI API Key not set - please head to the troubleshooting guide in the setup folder\")\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# And now - the all important import statement\n",
    "# If you get an import error - head over to troubleshooting guide\n",
    "\n",
    "from openai import OpenAI"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# And now we'll create an instance of the OpenAI class\n",
    "# If you're not sure what it means to create an instance of a class - head over to the guides folder!\n",
    "# If you get a NameError - head over to the guides folder to learn about NameErrors\n",
    "\n",
    "openai = OpenAI()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a list of messages in the familiar OpenAI format\n",
    "\n",
    "messages = [{\"role\": \"user\", \"content\": \"What is 2+2?\"}]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2 + 2 equals 4.\n"
     ]
    }
   ],
   "source": [
    "# And now call it! Any problems, head to the troubleshooting guide\n",
    "# This uses GPT 4.1 nano, the incredibly cheap model\n",
    "\n",
    "response = openai.chat.completions.create(\n",
    "    model=\"gpt-4.1-nano\",\n",
    "    messages=messages\n",
    ")\n",
    "\n",
    "print(response.choices[0].message.content)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# And now - let's ask for a question:\n",
    "\n",
    "question = \"Please propose a hard, challenging question to assess someone's IQ. Respond only with the question.\"\n",
    "messages = [{\"role\": \"user\", \"content\": question}]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If a clock’s hour hand moves 1/12th of a full rotation every hour, how many degrees will it have turned after 7 hours and 45 minutes?\n"
     ]
    }
   ],
   "source": [
    "# ask it - this uses GPT 4.1 mini, still cheap but more powerful than nano\n",
    "\n",
    "response = openai.chat.completions.create(\n",
    "    model=\"gpt-4.1-mini\",\n",
    "    messages=messages\n",
    ")\n",
    "\n",
    "question = response.choices[0].message.content\n",
    "\n",
    "print(question)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "# form a new messages list\n",
    "messages = [{\"role\": \"user\", \"content\": question}]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Let's analyze the problem step by step.\n",
      "\n",
      "1. **Given:**  \n",
      "   The hour hand moves \\(\\frac{1}{12}\\) of a full rotation every hour.\n",
      "\n",
      "2. **Full rotation in degrees:**  \n",
      "   A full rotation is \\(360^\\circ\\).\n",
      "\n",
      "3. **Degrees moved per hour:**  \n",
      "   \\[\n",
      "   \\frac{1}{12} \\times 360^\\circ = 30^\\circ \\text{ per hour}\n",
      "   \\]\n",
      "\n",
      "4. **Total time:**  \n",
      "   7 hours and 45 minutes.\n",
      "\n",
      "5. **Convert 45 minutes to hours:**  \n",
      "   \\[\n",
      "   45 \\text{ minutes} = \\frac{45}{60} = 0.75 \\text{ hours}\n",
      "   \\]\n",
      "\n",
      "6. **Calculate total degrees moved:**  \n",
      "   \\[\n",
      "   30^\\circ \\times (7 + 0.75) = 30^\\circ \\times 7.75 = 232.5^\\circ\n",
      "   \\]\n",
      "\n",
      "**Answer:**\n",
      "\n",
      "\\[\n",
      "\\boxed{232.5^\\circ}\n",
      "\\]\n",
      "\n",
      "The hour hand will have turned 232.5 degrees after 7 hours and 45 minutes.\n"
     ]
    }
   ],
   "source": [
    "# Ask it again\n",
    "\n",
    "response = openai.chat.completions.create(\n",
    "    model=\"gpt-4.1-mini\",\n",
    "    messages=messages\n",
    ")\n",
    "\n",
    "answer = response.choices[0].message.content\n",
    "print(answer)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "Let's analyze the problem step by step.\n",
       "\n",
       "1. **Given:**  \n",
       "   The hour hand moves \\(\\frac{1}{12}\\) of a full rotation every hour.\n",
       "\n",
       "2. **Full rotation in degrees:**  \n",
       "   A full rotation is \\(360^\\circ\\).\n",
       "\n",
       "3. **Degrees moved per hour:**  \n",
       "   \\[\n",
       "   \\frac{1}{12} \\times 360^\\circ = 30^\\circ \\text{ per hour}\n",
       "   \\]\n",
       "\n",
       "4. **Total time:**  \n",
       "   7 hours and 45 minutes.\n",
       "\n",
       "5. **Convert 45 minutes to hours:**  \n",
       "   \\[\n",
       "   45 \\text{ minutes} = \\frac{45}{60} = 0.75 \\text{ hours}\n",
       "   \\]\n",
       "\n",
       "6. **Calculate total degrees moved:**  \n",
       "   \\[\n",
       "   30^\\circ \\times (7 + 0.75) = 30^\\circ \\times 7.75 = 232.5^\\circ\n",
       "   \\]\n",
       "\n",
       "**Answer:**\n",
       "\n",
       "\\[\n",
       "\\boxed{232.5^\\circ}\n",
       "\\]\n",
       "\n",
       "The hour hand will have turned 232.5 degrees after 7 hours and 45 minutes."
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from IPython.display import Markdown, display\n",
    "\n",
    "display(Markdown(answer))\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Congratulations!\n",
    "\n",
    "That was a small, simple step in the direction of Agentic AI, with your new environment!\n",
    "\n",
    "Next time things get more interesting..."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<table style=\"margin: 0; text-align: left; width:100%\">\n",
    "    <tr>\n",
    "        <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",
    "            <img src=\"../assets/exercise.png\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
    "        </td>\n",
    "        <td>\n",
    "            <h2 style=\"color:#ff7800;\">Exercise</h2>\n",
    "            <span style=\"color:#ff7800;\">Now try this commercial application:<br/>\n",
    "            First ask the LLM to pick a business area that might be worth exploring for an Agentic AI opportunity.<br/>\n",
    "            Then ask the LLM to present a pain-point in that industry - something challenging that might be ripe for an Agentic solution.<br/>\n",
    "            Finally have 3 third LLM call propose the Agentic AI solution.\n",
    "            </span>\n",
    "        </td>\n",
    "    </tr>\n",
    "</table>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "incomplete input (553938246.py, line 13)",
     "output_type": "error",
     "traceback": [
      "  \u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[14]\u001b[39m\u001b[32m, line 13\u001b[39m\n\u001b[31m    \u001b[39m\u001b[31m# And repeat!\u001b[39m\n                 ^\n\u001b[31mSyntaxError\u001b[39m\u001b[31m:\u001b[39m incomplete input\n"
     ]
    }
   ],
   "source": [
    "# First create the messages:\n",
    "\n",
    "messages = [{\"role\": \"user\", \"content\": \"Pick a business area that is worth exploring for an agentic AI opportunity\"}]\n",
    "\n",
    "# Then make the first call:\n",
    "\n",
    "response = openai.chat.completions.create(\n",
    "    model=\"gpt-4o-mini\",\n",
    "    messages=messages\n",
    ")\n",
    "\n",
    "# Then read the business idea:\n",
    "\n",
    "business_idea = response.choices[0].message.content\n",
    "\n",
    "# And repeat!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "messages = [{\"role\": \"user\", \"content\": \"Pick a business area that is worth exploring for an agentic AI opportunity\"}]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "response = openai.chat.completions.create(\n",
    "    model=\"gpt-4o-mini\",\n",
    "    messages=messages\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "business_idea = response.choices[0].message.content\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "One promising business area for exploring agentic AI opportunities is **healthcare, specifically in patient management and personalized medicine**. The healthcare sector is undergoing rapid transformation through technology, and the integration of agentic AI can significantly enhance patient outcomes, operational efficiency, and overall healthcare delivery.\n",
      "\n",
      "### Key Opportunities in Healthcare for Agentic AI:\n",
      "\n",
      "1. **Personalized Treatment Plans**:\n",
      "   - Agentic AI can analyze vast amounts of patient data, including genetic information, medical history, lifestyle factors, and current health metrics, to create tailored treatment plans. This could lead to more effective interventions, especially in fields like oncology or chronic disease management.\n",
      "\n",
      "2. **Virtual Health Assistants**:\n",
      "   - AI-powered chatbots or virtual assistants can provide patients with 24/7 support for scheduling appointments, medication management, and answering health-related questions. These agents could continuously learn from interactions to improve service quality and patient engagement.\n",
      "\n",
      "3. **Predictive Analytics**:\n",
      "   - Using historical data, AI can predict patient deterioration, readmission risks, or potential complications with greater accuracy. This capability can enhance proactive care management and intervention strategies, reducing emergency visits and improving patient outcomes.\n",
      "\n",
      "4. **Clinical Decision Support**:\n",
      "   - AI can assist healthcare professionals by providing evidence-based recommendations and insights during patient consultations. This can streamline decision-making processes and enhance the quality of care delivered.\n",
      "\n",
      "5. **Remote Patient Monitoring**:\n",
      "   - Agentic AI can manage data from wearable devices and home monitoring systems to track chronic conditions in real time, alerting healthcare providers and patients to any critical changes.\n",
      "\n",
      "6. **Operational Efficiency**:\n",
      "   - AI can optimize scheduling, staff allocation, supply chain management, and resource utilization within healthcare facilities. This can lead to reduced costs and improved access to care.\n",
      "\n",
      "7. **Telemedicine Enhancement**:\n",
      "   - AI can improve telehealth experiences by triaging patient inquiries, collecting symptom information before consultations, and summarizing past medical records, thus allowing healthcare providers to focus more on patient interaction during virtual visits.\n",
      "\n",
      "### Conclusion:\n",
      "Incorporating agentic AI into healthcare presents opportunities for innovation that can positively impact patient care, reduce costs, and improve operational efficiency. As technology continues to advance, the potential for AI to drive meaningful change in this sector is substantial, making it a worthwhile area to explore.\n"
     ]
    }
   ],
   "source": [
    "print(business_idea)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "messages = [{\"role\": \"user\", \"content\": \"Pick a pain point in this industry - something challenging that might be ripe for an agentic solution\"}]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "response = openai.chat.completions.create(\n",
    "    model=\"gpt-4o-mini\",\n",
    "    messages=messages\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "pain_point = response.choices[0].message.content\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "One significant pain point in the healthcare industry is the challenge of patient data interoperability. Despite advancements in electronic health records (EHR) systems, many healthcare providers still struggle to share and access patient information across different platforms and organizations. This lack of interoperability can lead to fragmented care, inefficiencies, delayed diagnoses, and increased costs.\n",
      "\n",
      "An agentic solution could involve developing a unified, AI-driven platform that facilitates seamless data exchange between various EHR systems, ensuring that all healthcare providers have access to complete and up-to-date patient information. This platform could utilize standardized data formats, robust security protocols, and real-time analytics to enhance patient care while maintaining privacy compliance.\n",
      "\n",
      "Moreover, integrating patient engagement tools, such as mobile apps or portals, would empower patients to access their own health data, make informed decisions, and participate actively in their care journey. Overall, addressing the interoperability issue could significantly improve care coordination, patient outcomes, and overall healthcare efficiency.\n"
     ]
    }
   ],
   "source": [
    "print(pain_point)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "messages = [{\"role\": \"user\", \"content\": \"Propose your agentic AI solution\"}]\n",
    "\n",
    "response = openai.chat.completions.create(\n",
    "    model=\"gpt-4o-mini\",\n",
    "    messages=messages\n",
    ")\n",
    "\n",
    "agentic_solution = response.choices[0].message.content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Certainly! Here's a proposal for an agentic AI solution designed to assist small businesses in optimizing their operations and decision-making processes.\n",
      "\n",
      "### Agentic AI Solution: SmartBusiness Assistant (SBA)\n",
      "\n",
      "#### Overview\n",
      "The SmartBusiness Assistant (SBA) is an intelligent, agentic AI solution that empowers small business owners by streamlining operations, enhancing customer engagement, and providing data-driven insights. SBA learns from the business's unique context and evolves to meet its changing needs, acting as a proactive partner in decision-making.\n",
      "\n",
      "#### Key Features\n",
      "\n",
      "1. **Operational Optimization**\n",
      "   - **Inventory Management**: Automates inventory tracking by predicting stock levels and suggesting reorder points based on sales trends and seasonality.\n",
      "   - **Task Automation**: Automates repetitive tasks such as invoicing, payroll, and scheduling, allowing business owners to focus on strategic activities.\n",
      "  \n",
      "2. **Customer Engagement**\n",
      "   - **Personalized Marketing**: Utilizes customer data to create targeted marketing campaigns, recommending products/services based on past purchases and preferences.\n",
      "   - **Assisted Customer Service**: Implements AI-driven chatbots for 24/7 customer support, handling common inquiries and escalating complex issues to human agents.\n",
      "\n",
      "3. **Data-Driven Insights**\n",
      "   - **Business Analytics Dashboard**: Provides real-time analytics on sales performance, customer behavior, and market trends, helping owners make informed decisions.\n",
      "   - **Predictive Analytics**: Uses historical data to forecast sales and identify opportunities for growth.\n",
      "\n",
      "4. **Learning & Adaptation**\n",
      "   - **Contextual Learning**: Adapts to the specific dynamics of the business by learning from user interactions and continuously refining its algorithms based on feedback and performance metrics.\n",
      "   - **Scenario Simulation**: Allows users to simulate various business scenarios (e.g., price changes, new product launches) and assess potential outcomes based on historical data.\n",
      "\n",
      "5. **Integration & Accessibility**\n",
      "   - **Cloud-Based Platform**: Accessible from any device, ensuring that small business owners can monitor and manage their operations on the go.\n",
      "   - **Seamless Integration**: Integrates with existing tools (e.g., accounting software, CRM systems) to provide a cohesive ecosystem for operations.\n",
      "\n",
      "#### Implementation Plan\n",
      "\n",
      "1. **Needs Assessment**: Conduct an initial assessment to understand the specific needs and challenges faced by the business.\n",
      "2. **Custom Configuration**: Tailor the SBA to align with the business’s processes and goals.\n",
      "3. **Training & Onboarding**: Provide comprehensive training for the business owner and staff to maximize the value of the SBA.\n",
      "4. **Ongoing Support**: Offer continuous support and regular updates to maintain the system's effectiveness and address any emerging needs.\n",
      "\n",
      "#### Ethical Considerations\n",
      "- **Data Privacy**: Ensure compliance with data protection regulations (e.g., GDPR) and implement robust security measures to safeguard sensitive information.\n",
      "- **Transparency**: Maintain transparency about how the AI makes decisions and recommendations, allowing users to understand and trust the process.\n",
      "\n",
      "#### Conclusion\n",
      "The SmartBusiness Assistant leverages the power of agentic AI to transform the way small businesses operate. By automating tasks, personalizing customer interactions, and providing actionable insights, the SBA empowers business owners to focus on growth and innovation in a competitive landscape.\n"
     ]
    }
   ],
   "source": [
    "print(agentic_solution)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "**Agentic AI Solution for Patient Data Interoperability in Healthcare**\n",
      "\n",
      "**Solution Overview:**\n",
      "The proposed solution is an Agentic AI system called **HealthSync AI**, designed to facilitate seamless data interoperability across different healthcare systems. HealthSync AI will leverage advanced natural language processing (NLP), machine learning, and a decentralized blockchain infrastructure to ensure secure, efficient, and real-time access to patient data while maintaining privacy and compliance with regulations such as HIPAA.\n",
      "\n",
      "**Core Features:**\n",
      "\n",
      "1. **Natural Language Processing (NLP):**\n",
      "   - HealthSync AI will utilize NLP to extract and standardize data from unstructured clinical notes, lab reports, and other textual data formats across disparate systems (EHRs, labs, pharmacies, etc.).\n",
      "   - It will translate medical terminology into standardized codes (such as SNOMED, LOINC, and CPT) to ensure uniformity in patient data representation.\n",
      "\n",
      "2. **Interoperability Protocol:**\n",
      "   - The system will support interoperability protocols such as FHIR (Fast Healthcare Interoperability Resources) and HL7, facilitating the exchange of healthcare information between systems using standardized APIs.\n",
      "   - Smart adapters will be created for legacy systems that may not support these standards, allowing for their seamless integration.\n",
      "\n",
      "3. **Decentralized Blockchain Infrastructure:**\n",
      "   - HealthSync AI will implement a permissioned blockchain to create a secure, tamper-proof registry of patient data sharing that tracks consent, access, and data usage.\n",
      "   - This will empower patients to control their data, authorizing which healthcare providers can access their information while ensuring compliance with relevant regulations.\n",
      "\n",
      "4. **Dynamic Patient Profiles:**\n",
      "   - The AI will create dynamic patient profiles that aggregate data from multiple sources in real-time, enabling healthcare providers to have a comprehensive view of a patient’s medical history, treatment plans, and ongoing medications.\n",
      "   - These profiles can be updated with new information automatically and shared across connected systems while respecting patient consent.\n",
      "\n",
      "5. **Predictive Analytics and Decision Support:**\n",
      "   - The Agentic AI will analyze aggregated patient data to offer predictive analytics that can assist healthcare providers in making informed clinical decisions.\n",
      "   - The system can flag potential health risks based on historical data patterns, thereby enabling proactive interventions.\n",
      "\n",
      "6. **Interfacing with IoT and Wearables:**\n",
      "   - By integrating with IoT devices and wearables (such as blood glucose monitors and fitness trackers), HealthSync AI can continuously update patient profiles with real-time health data, further enhancing the continuity of care.\n",
      "\n",
      "7. **User-Friendly Interfaces:**\n",
      "   - The solution will incorporate user-friendly dashboards for healthcare providers and patients, providing intuitive access to patient records, health insights, and interactive consent management features.\n",
      "\n",
      "**Implementation Strategy:**\n",
      "\n",
      "1. **Stakeholder Engagement:**\n",
      "   - Collaborate with key stakeholders, including healthcare providers, data privacy experts, and patients, to define critical interoperability needs and assess current challenges.\n",
      "   \n",
      "2. **Pilot Programs:**\n",
      "   - Conduct pilot implementations in select healthcare organizations to test interoperability across different systems, gather feedback, and iterate on the design.\n",
      "\n",
      "3. **Regulatory Compliance:**\n",
      "   - Ensure ongoing compliance with applicable regulations and data protection standards throughout the development and operation phases.\n",
      "\n",
      "4. **Training and Support:**\n",
      "   - Provide robust training for healthcare staff on how to utilize the system effectively and understand the significance of patient consent and data privacy.\n",
      "\n",
      "5. **Continuous Improvement:**\n",
      "   - Implement a feedback loop where users can report issues, suggest improvements, and contribute to the ongoing development of HealthSync AI to adapt to evolving industry needs.\n",
      "\n",
      "**Conclusion:**\n",
      "HealthSync AI presents a comprehensive solution for patient data interoperability in healthcare, empowering providers with actionable insights while prioritizing patient privacy and control. By leveraging advanced AI technologies, standardized protocols, and blockchain security, this solution aims to transform how patient data is shared and utilized across the healthcare ecosystem, ultimately improving patient outcomes and healthcare efficiency.\n"
     ]
    }
   ],
   "source": [
    "messages = [{\"role\": \"user\", \"content\": \"Propose an Agentic AI solution for the problem of patient data interoperability in the healthcare industry\"}]\n",
    "\n",
    "response = openai.chat.completions.create(\n",
    "    model=\"gpt-4o-mini\",\n",
    "    messages=messages\n",
    ")\n",
    "\n",
    "agentic_solution = response.choices[0].message.content\n",
    "\n",
    "print(agentic_solution)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "One potential agentic AI solution to address project delays and cost overruns in the construction industry is the implementation of an AI-driven project management platform that integrates real-time data analytics, predictive modeling, and communication tools. Let's break down how this solution can alleviate the pain points mentioned:\n",
      "\n",
      "### AI-Driven Project Management Platform\n",
      "\n",
      "#### Key Features:\n",
      "\n",
      "1. **Predictive Analytics**:\n",
      "   - The platform uses historical data from past projects to identify patterns and predict potential delays and cost overruns. By analyzing various factors such as weather conditions, labor availability, and supply chain stability, the AI can forecast risks before they materialize.\n",
      "\n",
      "2. **Real-Time Monitoring**:\n",
      "   - Integrating IoT sensors on site allows for real-time tracking of labor, materials, and equipment usage. This data can be instantly analyzed by the AI to detect anomalies and inefficiencies, enabling rapid responses to emerging issues.\n",
      "\n",
      "3. **Dynamic Scheduling**:\n",
      "   - The AI can create and adjust project schedules based on real-time data. If a supply chain disruption occurs, the AI can propose new timelines or alternate material sources, optimizing schedules to minimize downtime.\n",
      "\n",
      "4. **Enhanced Communication Tools**:\n",
      "   - The platform can facilitate seamless communication among all stakeholders (contractors, subcontractors, suppliers, and clients). Integrated chat tools and collaboration features ensure that updates are shared quickly, reducing the chances of miscommunication.\n",
      "\n",
      "5. **Resource Allocation Optimization**:\n",
      "   - Using machine learning algorithms, the platform can predict labor shortages and optimize the allocation of resources, ensuring that the right number of workers is available on-site when needed. This helps mitigate the impacts of labor shortages on project timelines.\n",
      "\n",
      "6. **Scenario Planning**:\n",
      "   - The AI can simulate various scenarios (e.g., weather changes, supply delays) and their potential impact on timelines and budgets. This allows project managers to develop contingency plans proactively.\n",
      "\n",
      "7. **Feedback Loop**:\n",
      "   - The platform can learn from project outcomes to refine its models continuously. By identifying which predictive factors were most accurate in past projects, the system can improve its future predictions.\n",
      "\n",
      "### Benefits:\n",
      "\n",
      "- **Reduced Delays and Overruns**: By providing predictive insights and real-time data, the platform equips project managers to make informed decisions quickly, addressing potential issues before they escalate.\n",
      "  \n",
      "- **Improved Collaboration**: With enhanced communication tools, all stakeholders can stay informed and aligned, leading to fewer misunderstandings and a stronger project flow.\n",
      "\n",
      "- **Increased Efficiency**: Dynamic scheduling and resource optimization can lead to better use of available resources, reducing idle time and increasing productivity on-site.\n",
      "\n",
      "- **Strengthened Client Relationships**: Clients benefit from regular updates and transparency about project status, leading to greater trust and satisfaction.\n",
      "\n",
      "- **Reduced Stress for Project Managers**: By automating routine tasks and offering predictive insights, project managers can focus on strategic decision-making, reducing their overall workload and stress.\n",
      "\n",
      "### Conclusion:\n",
      "\n",
      "An AI-driven project management platform represents a powerful agentic solution to the construction industry's significant pain points regarding project delays and cost overruns. By leveraging real-time data and predictive analytics, it enables better planning, improves communication, and enhances project management strategies, ultimately leading to more successful project outcomes.\n"
     ]
    }
   ],
   "source": [
    "messages = [{\"role\": \"user\", \"content\": \"Identify a pain point in the construction industry\"}]\n",
    "\n",
    "response = openai.chat.completions.create(\n",
    "    model=\"gpt-4o-mini\",\n",
    "    messages=messages\n",
    ")\n",
    "\n",
    "pain_point = response.choices[0].message.content\n",
    "\n",
    "messages = [{\"role\": \"user\", \"content\": \"Identify and explain an agentic AI solution for \" + pain_point}]\n",
    "\n",
    "response = openai.chat.completions.create(\n",
    "    model=\"gpt-4o-mini\",\n",
    "    messages=messages\n",
    ")\n",
    "\n",
    "ai_solution = response.choices[0].message.content\n",
    "\n",
    "print(ai_solution)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "To address a specific pain point, let's consider the challenge of employee burnout in remote work environments—a growing concern for many organizations. An agentic AI solution can help alleviate this issue by providing personalized support and enhancing employee well-being.\n",
      "\n",
      "### Solution: AI-Driven Mental Health and Productivity Assistant\n",
      "\n",
      "#### Overview\n",
      "An AI-driven assistant, referred to as \"WellBot,\" is designed to monitor employee well-being, offer personalized mental health resources, and provide productivity-enhancing suggestions tailored to individual needs.\n",
      "\n",
      "#### Key Features\n",
      "\n",
      "1. **Well-being Monitoring:**\n",
      "   - **Sentiment Analysis:** WellBot can analyze employee communication patterns (emails, chat messages) and engagement metrics (e.g., meeting attendance, response times) for signs of fatigue, stress, or discontent. \n",
      "   - **Surveys and Pulse Checks:** Through regular, non-intrusive surveys, the assistant can gauge employee morale and allow workers to express their feelings about their workload, stress levels, and overall satisfaction.\n",
      "\n",
      "2. **Personalized Recommendations:**\n",
      "   - **Workload Management:** Based on workload and engagement levels, WellBot can recommend adjustments, such as breaking tasks into smaller components or scheduling regular breaks to enhance productivity.\n",
      "   - **Mental Health Resources:** The AI can suggest resources such as articles, videos, or guided meditations focused on stress relief, mindfulness, or time management tailored to individual preferences.\n",
      "\n",
      "3. **Scheduled Check-ins:**\n",
      "   - WellBot can proactively reach out to employees with scheduled check-ins to discuss their workload, provide positive reinforcement, and open a dialogue about any stressors they are facing.\n",
      "\n",
      "4. **Virtual Peer Support:**\n",
      "   - The assistant can facilitate virtual meet-ups or peer support groups, encouraging employees to connect and share experiences, thus fostering a sense of community and belonging.\n",
      "\n",
      "5. **Feedback Loop:**\n",
      "   - WellBot can continuously learn from user interactions and feedback, improving its recommendations and support based on emerging trends and individual preferences.\n",
      "\n",
      "#### Benefits\n",
      "- **Reduced Burnout:** By providing personalized support and resources, employees may experience lower stress levels and improved job satisfaction, ultimately reducing burnout rates.\n",
      "- **Enhanced Productivity:** Personalized recommendations help employees manage their workload more efficiently, leading to better output quality and quantity.\n",
      "- **Proactive Well-being Culture:** The introduction of WellBot can foster a culture where employee well-being is prioritized, making staff feel valued and supported.\n",
      "- **Data-Driven Insights:** Organizations can gain insights from aggregated data to identify trends and intervene in areas that require attention, improving overall workplace health.\n",
      "\n",
      "#### Conclusion\n",
      "Deploying an agentic AI solution like WellBot not only addresses the pain point of employee burnout but also contributes to creating a healthier, more engaged remote working culture. Such an initiative shows a commitment to staff well-being and can boost retention and overall productivity.\n"
     ]
    }
   ],
   "source": [
    "messages = [{\"role\": \"user\", \"content\": \"Identify and explain an agentic AI solution for the pain point\"}]\n",
    "\n",
    "response = openai.chat.completions.create(\n",
    "    model=\"gpt-4o-mini\",\n",
    "    messages=messages\n",
    ")\n",
    "\n",
    "ai_solution = response.choices[0].message.content\n",
    "\n",
    "print(ai_solution)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}