File size: 41,282 Bytes
1f72c80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Welcome to Lab 3 for Week 1 Day 4\n",
    "\n",
    "Today we're going to build something with immediate value!\n",
    "\n",
    "In the folder `me` I've put a single file `linkedin.pdf` - it's a PDF download of my LinkedIn profile.\n",
    "\n",
    "Please replace it with yours!\n",
    "\n",
    "I've also made a file called `summary.txt`\n",
    "\n",
    "We're not going to use Tools just yet - we're going to add the tool tomorrow."
   ]
  },
  {
   "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;\">Looking up packages</h2>\n",
    "            <span style=\"color:#00bfff;\">In this lab, we're going to use the wonderful Gradio package for building quick UIs, \n",
    "            and we're also going to use the popular PyPDF PDF reader. You can get guides to these packages by asking \n",
    "            ChatGPT or Claude, and you find all open-source packages on the repository <a href=\"https://pypi.org\">https://pypi.org</a>.\n",
    "            </span>\n",
    "        </td>\n",
    "    </tr>\n",
    "</table>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# If you don't know what any of these packages do - you can always ask ChatGPT for a guide!\n",
    "\n",
    "from dotenv import load_dotenv\n",
    "from openai import OpenAI\n",
    "from pypdf import PdfReader\n",
    "import gradio as gr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "load_dotenv(override=True)\n",
    "openai = OpenAI()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "reader = PdfReader(\"me/linkedin.pdf\")\n",
    "linkedin = \"\"\n",
    "for page in reader.pages:\n",
    "    text = page.extract_text()\n",
    "    if text:\n",
    "        linkedin += text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Marcel  Mejulu marcelmejulu@gmail.com LinkedIn :  linkedin.com/in/mmejulu  |  GitHub :  https://github.com/marcmeju/  Summary Software  Engineer  with  4+  years  of  experience.  Passionate  about  developing  and  deploying  sustainable  software  solutions  to  everyday  problems.  Adept  at  \n",
      "collaborating\n",
      " \n",
      "in\n",
      " \n",
      "cross-functional\n",
      " \n",
      "agile\n",
      " \n",
      "teams\n",
      " \n",
      "to\n",
      " \n",
      "build\n",
      " \n",
      "scalable,\n",
      " \n",
      "resilient,\n",
      " \n",
      "and\n",
      " \n",
      "self-healing\n",
      " \n",
      "solutions. \n",
      "Skills  |  Tech \n",
      "Frontend  |  Backend  |  DevOps:   HTML,  CSS,  JavaScript,  React  (3  years),  AngularJS,  TypeScript  (3  years),  NodeJS  (4+  years),  Bootstrap,  Java  (4+  years),  \n",
      "Spring\n",
      " \n",
      "Framework,\n",
      " \n",
      "RDBMS\n",
      " \n",
      "(MySQL,\n",
      " \n",
      "SSMS,\n",
      " \n",
      "etc.),\n",
      " \n",
      "REST\n",
      " \n",
      "APIs/Microservices,\n",
      " \n",
      "Git/GitHub,\n",
      " \n",
      ".NET6\n",
      " \n",
      "(C#),\n",
      " \n",
      "Postman.\n",
      " Cloud  |  Infrastructure:  AWS  (3  years),  Azure,  Cloud  Foundry,  CaaS,  Kubernetes,  Docker.  Scripting:  Python,  PowerShell,  CMD,  Bash/Shell/Linux,  ServiceNow  Scripting.  Platforms  |  Monitoring/Observability:  ServiceNow,  Jira,  BigPanda,  NewRelic,  Dynatrace  (Synthetics,  APM,  Infrastructure),  Veracode.   Work  Experience   Intel  Corporation       Enterprise  Application  Development  Engineer  |  Software  Developer  |  Integrations  Engineer  –  Remote                                             Oct  2022  –  Current  Product:  Observability  as  a  Service  ●  Developed,  integrated,  and  currently  maintaining  an  end-to-end  Observability  as  a  Service  product  which  provides  real-time  fullstack  monitoring,  logging,  \n",
      "log\n",
      " \n",
      "tracing,\n",
      " \n",
      "anomaly\n",
      " \n",
      "detection,\n",
      " \n",
      "problem\n",
      " \n",
      "notification\n",
      " \n",
      "and\n",
      " \n",
      "remediation\n",
      " \n",
      "services\n",
      " \n",
      "for\n",
      " \n",
      "large-scale\n",
      " \n",
      "distributed\n",
      " \n",
      "systems.\n",
      "   \n",
      " Tech  stack:  Dynatrace,  SCOM,  NewRelic,  ServiceNow,  BigPanda,  GOLang,  Python,  C#.  ●  Deployed  comprehensive  RBAC/IAM  security  solution  for  enterprise  applications  to  assess  sign-risk  in  real-time,  handle  user  identity  management,  user  \n",
      "authentication\n",
      " \n",
      "and\n",
      " \n",
      "authorization\n",
      " \n",
      "while\n",
      " \n",
      "automating\n",
      " \n",
      "user\n",
      " \n",
      "provisioning\n",
      " \n",
      "tasks\n",
      " \n",
      "which\n",
      " \n",
      "reduced\n",
      " \n",
      "access-management\n",
      " \n",
      "service\n",
      " \n",
      "requests\n",
      " \n",
      "tickets\n",
      " \n",
      "and\n",
      " \n",
      "incidents\n",
      " \n",
      "by\n",
      " \n",
      "95%,\n",
      " \n",
      "saving\n",
      " \n",
      "precious\n",
      " \n",
      "IT\n",
      " \n",
      "time.\n",
      " \n",
      " Tech  stack:  Microsoft  Entra  ID,  Azure  SSO  with  SCIM,  Access  Governance  System.  Keywords:  Role-based  access,  Identity  Access  Management  ●  Decreased  monitoring  costs  yet  maximized  real  user  experience  by  optimizing  monitoring/observability  strategies  which  increased  and  maintained  \n",
      "availability\n",
      " \n",
      "metrics\n",
      " \n",
      "at\n",
      " \n",
      "99.98%\n",
      " \n",
      "for\n",
      " \n",
      "organization-wide\n",
      " \n",
      "tier\n",
      " \n",
      "1\n",
      " \n",
      "and\n",
      " \n",
      "tier\n",
      " \n",
      "2\n",
      " \n",
      "applications.\n",
      " ●  Deployed  a  noise  cancellation  feature  that  led  to  elimination  of  false  positive  problem  notifications  across  the  product  by  integrating  and  configuring  a  \n",
      "robust\n",
      " \n",
      "event\n",
      " \n",
      "management\n",
      " \n",
      "SaaS\n",
      " \n",
      "solution\n",
      " \n",
      "which\n",
      " \n",
      "allows\n",
      " \n",
      "standard\n",
      " \n",
      "event\n",
      " \n",
      "tagging,\n",
      " \n",
      "event\n",
      " \n",
      "correlation,\n",
      " \n",
      "alert\n",
      " \n",
      "deduplication\n",
      " \n",
      "and\n",
      " \n",
      "alert\n",
      " \n",
      "enrichment\n",
      " \n",
      "and\n",
      " \n",
      "implemented\n",
      " \n",
      "incident\n",
      " \n",
      "notification\n",
      " \n",
      "policies\n",
      " \n",
      "on\n",
      " \n",
      "critical\n",
      " \n",
      "alerts\n",
      " \n",
      "that\n",
      " \n",
      "led\n",
      " \n",
      "to\n",
      " \n",
      "improved\n",
      " \n",
      "incident\n",
      " \n",
      "response\n",
      " \n",
      "time\n",
      " \n",
      "and\n",
      " \n",
      "reduced\n",
      " \n",
      "major\n",
      " \n",
      "incidents\n",
      " \n",
      "which\n",
      " \n",
      "maximized\n",
      " \n",
      "real\n",
      " \n",
      "users’\n",
      " \n",
      "experiences\n",
      " \n",
      "and\n",
      " \n",
      "increased\n",
      " \n",
      "Service\n",
      " \n",
      "Level\n",
      " \n",
      "Objective-based\n",
      " \n",
      "performance\n",
      " \n",
      "metrics,\n",
      " \n",
      "SLA\n",
      " \n",
      "and\n",
      " \n",
      "CSAT,\n",
      " \n",
      "to\n",
      " \n",
      "an\n",
      " \n",
      "average\n",
      " \n",
      "of\n",
      " \n",
      "90%\n",
      " \n",
      "and\n",
      " \n",
      "95%\n",
      " \n",
      "respectively.\n",
      "    Genesis10       Software  Developer  Consultant  –  Remote                                 Feb  2022  –  Sept  2022  Working  as  a  developer  in  the  Insurance  and  Investment  solutions  Industry.  ●  Developed  new  web  applications  (with  comprehensive  unit/integration  tests)  using  Visual  Studio  (C#)  and  SSMS  (SQL)  to  extract,  transform  and  load  \n",
      "data\n",
      " \n",
      "into\n",
      " \n",
      "on-prem/cloud\n",
      " \n",
      "databases\n",
      " \n",
      "using\n",
      " \n",
      "stored\n",
      " \n",
      "procedures\n",
      " \n",
      "and\n",
      " \n",
      "created\n",
      " \n",
      "microservices\n",
      " \n",
      "(API\n",
      " \n",
      "functionality)\n",
      " \n",
      "for\n",
      " \n",
      "API\n",
      " \n",
      "calls.\n",
      " \n",
      " ●  Built  a  full  stack  web  application  that  receives  source  data  in  JSON  format,  validates  and  transforms  source  data  fields  into  target  data  fields  format  then  \n",
      "commits\n",
      " \n",
      "the\n",
      " \n",
      "data\n",
      " \n",
      "in\n",
      " \n",
      "the\n",
      " \n",
      "database.\n",
      " \n",
      "(Frontend:\n",
      " \n",
      "AngularJS/typescript\n",
      " \n",
      "and\n",
      " \n",
      "Bootstrap.\n",
      " \n",
      "Backend:\n",
      " \n",
      "C#\n",
      " \n",
      "and\n",
      " \n",
      "SQL/SSMS.)\n",
      " \n",
      " ●  Created  new  features  for  web  applications  using  C#  and  AngularJS,  and  committing  changes  into  production  using  Azure  DevOps  to  improve  \n",
      "aesthetics/performance\n",
      " \n",
      "of\n",
      " \n",
      "the\n",
      " \n",
      "web\n",
      " \n",
      "application\n",
      " \n",
      "while\n",
      " \n",
      "utilizing\n",
      " \n",
      "Agile\n",
      " \n",
      "methodologies.\n",
      " \n",
      " ●  Scanned  software  for  bugs/vulnerabilities,  analyzing  vulnerability  risk  and  remediating  with  correlated  patches.   Full-Stack  Software  Developer  Trainee  –  Remote                 Sept  2021  –  Jan  2022  ●  Completed  a  15-week  Full  Stack  web  development  bootcamp  focused  on  Java  and  cloud  technologies.  ●  Developed  multiple  Command  Line  projects  and  games  using  Java  (SpringBoot,  Mockito,  JDBC)  and  SQL,  hosting  applications  using  cloud  \n",
      "technologies\n",
      " \n",
      "(Docker\n",
      " \n",
      "for\n",
      " \n",
      "containerization,\n",
      " \n",
      "AWS\n",
      " \n",
      "for\n",
      " \n",
      "Deployment).\n",
      " ●  Built  a  travel  web  application/microservice  that  allows  users  to  purchase  vacation  packages  when  visiting  different  cities;  utilizing  React  for  front  end  \n",
      "development,\n",
      " \n",
      "java\n",
      " \n",
      "for\n",
      " \n",
      "backend\n",
      " \n",
      "development,\n",
      " \n",
      "and\n",
      " \n",
      "MySQL\n",
      " \n",
      "for\n",
      " \n",
      "storing\n",
      " \n",
      "encrypted\n",
      " \n",
      "user\n",
      " \n",
      "information.\n",
      " ●  Completed  multilevel  data  structures  and  algorithms  challenges;  gaining  skills  in  efficiently  sorting,  storing,  and  manipulating  data.  \n",
      "   Udemy  Web  Development  Bootcamp                                                                          Feb  2021  –  Aug  2021     Software  Development  Training  -  Udemy  ●  Completed  three  (3)  comprehensive  web  development  courses  (hands-on  projects  inclusive)  on  Udemy  to  gain  mastery  of  the  frontend  development  \n",
      "concepts\n",
      " \n",
      "(e.g.,\n",
      " \n",
      "syntaxes\n",
      " \n",
      "of\n",
      " \n",
      "HTML,\n",
      " \n",
      "CSS,\n",
      " \n",
      "and\n",
      " \n",
      "JavaScript).\n",
      " ●  Developed  multiple  responsive  web  pages  utilizing  HTML  and  CSS  (FlexBox);  learned  to  integrate  Frameworks  (e.g.,  Bootstrap  etc.)  to  create  \n",
      "dynamic\n",
      " \n",
      "web\n",
      " \n",
      "pages\n",
      " \n",
      "(UI)\n",
      " \n",
      "and\n",
      " \n",
      "optimized\n",
      " \n",
      "dynamic\n",
      " \n",
      "behavior\n",
      " \n",
      "of\n",
      " \n",
      "web\n",
      " \n",
      "pages\n",
      " \n",
      "using\n",
      " \n",
      "JavaScript\n",
      " \n",
      "to\n",
      " \n",
      "incorporate\n",
      " \n",
      "events\n",
      " \n",
      "on\n",
      " \n",
      "webpages\n",
      " \n",
      "to\n",
      " \n",
      "improve\n",
      " \n",
      "user\n",
      " \n",
      "experience\n",
      " \n",
      "(UX).\n",
      "         \n",
      "       Purdue  University  Northwest                                                                                                                        March  2020  –  June  2021  Technical  Lab  Supervisor,  Mechanical  &  Civil  Engineering  –  Hammond,  Indiana  ●  Leading  the  new  state-of-the-art  design  studio  project;  purchasing,  installing  machinery,  and  redesigning  studio  space  to  integrate  collaborative  \n",
      "design\n",
      " \n",
      "sections\n",
      " \n",
      "and\n",
      " \n",
      "fabrication\n",
      " \n",
      "processes\n",
      " \n",
      "geared\n",
      " \n",
      "towards\n",
      " \n",
      "producing\n",
      " \n",
      "a\n",
      " \n",
      "harmonious\n",
      " \n",
      "workflow.\n",
      " ●  Facilitated  the  laboratories’  seamless  transition  to  virtual  learning  during  Covid-19  by  implementing  Standard  Operating  Procedures  and  delegating  a  \n",
      "team\n",
      " \n",
      "of\n",
      " \n",
      "8\n",
      " \n",
      "graduate\n",
      " \n",
      "teaching\n",
      " \n",
      "assistants\n",
      " \n",
      "using\n",
      " \n",
      "various\n",
      " \n",
      "training\n",
      " \n",
      "and\n",
      " \n",
      "evaluation\n",
      " \n",
      "procedures.\n",
      " ●  Managing  equipment  bid  reviews  and  evaluation  process  while  keeping  purchases  within    budget  constraints.  ●  Recruited  potential  lab  supervisors  and  assistants  to  enhance  productivity  by  coordinating  engaging  sessions  introducing  the  department  and  assisting  \n",
      "with\n",
      " \n",
      "the\n",
      " \n",
      "hiring\n",
      " \n",
      "process.\n",
      " ●  Managing  and  ensuring  completion  of  student  and  faculty  design,  fabrication,  testing,  and  analysis  projects  such  as  Component  fabrication,  Heat  \n",
      "treatment\n",
      " \n",
      "of\n",
      " \n",
      "materials,\n",
      " \n",
      "Microstructural\n",
      " \n",
      "Analysis\n",
      " \n",
      "of\n",
      " \n",
      "materials,\n",
      " \n",
      "Tensile/Compression\n",
      " \n",
      "testing,\n",
      " \n",
      "Fatigue\n",
      " \n",
      "testing,\n",
      " \n",
      "Creep\n",
      " \n",
      "testing,\n",
      " \n",
      "Impact\n",
      " \n",
      "testing\n",
      " \n",
      "while\n",
      " \n",
      "utilizing\n",
      " \n",
      "but\n",
      " \n",
      "not\n",
      " \n",
      "limited\n",
      " \n",
      "to:\n",
      " β€’  CNC/Lathe  machines,  Water-jet  cutter,  Scanning  Electron  Microscope,  MTS  Criterion  Model  42/  Universal  Testing  Machine,  Fatigue/Torsion  \n",
      "testing\n",
      " \n",
      "machine,\n",
      " \n",
      "compression\n",
      " \n",
      "testing\n",
      " \n",
      "machine,\n",
      " \n",
      "and\n",
      " \n",
      "Rockwell/Brinell\n",
      " \n",
      "Hardness\n",
      " \n",
      "tester.\n",
      " \n",
      "Purdue  University  Northwest                May  2018  –  December  2019  Associate  Technical  Lab  Supervisor  –  Hammond,  Indiana  ●  Installed,  calibrated,  and  maintained  mechanical  engineering  laboratory  equipment.  ●  Resolved  technical  problems  and  ensured  remedial  actions  are  taken  whenever  equipment  deviate  from  the  laboratory's  established  performance  \n",
      "specifications.\n",
      " ●  Coordinated  engaging  lab  sessions  following  Standard  Operating  Procedures  (SOPs)  to  introduce  equipment  to  faculty  and  new  lab  instructors  while  \n",
      "assisting\n",
      " \n",
      "faculty/students\n",
      " \n",
      "to\n",
      " \n",
      "ensure\n",
      " \n",
      "completion\n",
      " \n",
      "of\n",
      " \n",
      "senior\n",
      " \n",
      "design,\n",
      " \n",
      "testing,\n",
      " \n",
      "and\n",
      " \n",
      "fabrication\n",
      " \n",
      "projects.\n",
      " \n",
      "Education  Purdue  University,  Indiana.  MS  Mechanical  Engineering  \n",
      "                   December  2019  \n",
      "Obafemi  Awolowo  University,  Nigeria  BS  Materials  Science  and  Engineering  \n",
      "Certifications:  ●  ServiceNow  Certified  Application  Developer  ●  Dev10  Full  Stack  Java/Cloud  Developer.  \n",
      "                             May  2015                               \n",
      " \n"
     ]
    }
   ],
   "source": [
    "print(linkedin)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(\"me/summary.txt\", \"r\", encoding=\"utf-8\") as f:\n",
    "    summary = f.read()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "name = \"Marcel\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "system_prompt = f\"You are acting as {name}. You are answering questions on {name}'s website, \\\n",
    "particularly questions related to {name}'s career, background, skills and experience. \\\n",
    "Your responsibility is to represent {name} for interactions on the website as faithfully as possible. \\\n",
    "You are given a summary of {name}'s background and LinkedIn profile which you can use to answer questions. \\\n",
    "Be professional and engaging, as if talking to a potential client or future employer who came across the website. \\\n",
    "If you don't know the answer, say so.\"\n",
    "\n",
    "system_prompt += f\"\\n\\n## Summary:\\n{summary}\\n\\n## LinkedIn Profile:\\n{linkedin}\\n\\n\"\n",
    "system_prompt += f\"With this context, please chat with the user, always staying in character as {name}.\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"You are acting as Marcel. You are answering questions on Marcel's website, particularly questions related to Marcel's career, background, skills and experience. Your responsibility is to represent Marcel for interactions on the website as faithfully as possible. You are given a summary of Marcel's background and LinkedIn profile which you can use to answer questions. Be professional and engaging, as if talking to a potential client or future employer who came across the website. If you don't know the answer, say so.\\n\\n## Summary:\\nMy name is Marcel Mejulu. I'm a software engineer and an aspiring AI/ML Engineer. I'm originally from Lagos, NIgeria, but I now reside in California, USA.\\nI love all foods, particularly well seasoned meat. I eat and enjoy all sea foods but strangely I'm repelled by shrimp. I'm not allergic, I just don't like it, and I don't seem to know why! I love everything spicy, suya/kilishi (grilled spicy beef) is one of my favorite things. I equally love ice cream too just as much as I enjoy travelling and purposeful work!\\n\\n## LinkedIn Profile:\\nMarcel  Mejulu marcelmejulu@gmail.com LinkedIn :  linkedin.com/in/mmejulu  |  GitHub :  https://github.com/marcmeju/  Summary Software  Engineer  with  4+  years  of  experience.  Passionate  about  developing  and  deploying  sustainable  software  solutions  to  everyday  problems.  Adept  at  \\ncollaborating\\n \\nin\\n \\ncross-functional\\n \\nagile\\n \\nteams\\n \\nto\\n \\nbuild\\n \\nscalable,\\n \\nresilient,\\n \\nand\\n \\nself-healing\\n \\nsolutions. \\nSkills  |  Tech \\nFrontend  |  Backend  |  DevOps:   HTML,  CSS,  JavaScript,  React  (3  years),  AngularJS,  TypeScript  (3  years),  NodeJS  (4+  years),  Bootstrap,  Java  (4+  years),  \\nSpring\\n \\nFramework,\\n \\nRDBMS\\n \\n(MySQL,\\n \\nSSMS,\\n \\netc.),\\n \\nREST\\n \\nAPIs/Microservices,\\n \\nGit/GitHub,\\n \\n.NET6\\n \\n(C#),\\n \\nPostman.\\n Cloud  |  Infrastructure:  AWS  (3  years),  Azure,  Cloud  Foundry,  CaaS,  Kubernetes,  Docker.  Scripting:  Python,  PowerShell,  CMD,  Bash/Shell/Linux,  ServiceNow  Scripting.  Platforms  |  Monitoring/Observability:  ServiceNow,  Jira,  BigPanda,  NewRelic,  Dynatrace  (Synthetics,  APM,  Infrastructure),  Veracode.   Work  Experience   Intel  Corporation       Enterprise  Application  Development  Engineer  |  Software  Developer  |  Integrations  Engineer  –  Remote                                             Oct  2022  –  Current  Product:  Observability  as  a  Service  ●  Developed,  integrated,  and  currently  maintaining  an  end-to-end  Observability  as  a  Service  product  which  provides  real-time  fullstack  monitoring,  logging,  \\nlog\\n \\ntracing,\\n \\nanomaly\\n \\ndetection,\\n \\nproblem\\n \\nnotification\\n \\nand\\n \\nremediation\\n \\nservices\\n \\nfor\\n \\nlarge-scale\\n \\ndistributed\\n \\nsystems.\\n   \\n Tech  stack:  Dynatrace,  SCOM,  NewRelic,  ServiceNow,  BigPanda,  GOLang,  Python,  C#.  ●  Deployed  comprehensive  RBAC/IAM  security  solution  for  enterprise  applications  to  assess  sign-risk  in  real-time,  handle  user  identity  management,  user  \\nauthentication\\n \\nand\\n \\nauthorization\\n \\nwhile\\n \\nautomating\\n \\nuser\\n \\nprovisioning\\n \\ntasks\\n \\nwhich\\n \\nreduced\\n \\naccess-management\\n \\nservice\\n \\nrequests\\n \\ntickets\\n \\nand\\n \\nincidents\\n \\nby\\n \\n95%,\\n \\nsaving\\n \\nprecious\\n \\nIT\\n \\ntime.\\n \\n Tech  stack:  Microsoft  Entra  ID,  Azure  SSO  with  SCIM,  Access  Governance  System.  Keywords:  Role-based  access,  Identity  Access  Management  ●  Decreased  monitoring  costs  yet  maximized  real  user  experience  by  optimizing  monitoring/observability  strategies  which  increased  and  maintained  \\navailability\\n \\nmetrics\\n \\nat\\n \\n99.98%\\n \\nfor\\n \\norganization-wide\\n \\ntier\\n \\n1\\n \\nand\\n \\ntier\\n \\n2\\n \\napplications.\\n ●  Deployed  a  noise  cancellation  feature  that  led  to  elimination  of  false  positive  problem  notifications  across  the  product  by  integrating  and  configuring  a  \\nrobust\\n \\nevent\\n \\nmanagement\\n \\nSaaS\\n \\nsolution\\n \\nwhich\\n \\nallows\\n \\nstandard\\n \\nevent\\n \\ntagging,\\n \\nevent\\n \\ncorrelation,\\n \\nalert\\n \\ndeduplication\\n \\nand\\n \\nalert\\n \\nenrichment\\n \\nand\\n \\nimplemented\\n \\nincident\\n \\nnotification\\n \\npolicies\\n \\non\\n \\ncritical\\n \\nalerts\\n \\nthat\\n \\nled\\n \\nto\\n \\nimproved\\n \\nincident\\n \\nresponse\\n \\ntime\\n \\nand\\n \\nreduced\\n \\nmajor\\n \\nincidents\\n \\nwhich\\n \\nmaximized\\n \\nreal\\n \\nusers’\\n \\nexperiences\\n \\nand\\n \\nincreased\\n \\nService\\n \\nLevel\\n \\nObjective-based\\n \\nperformance\\n \\nmetrics,\\n \\nSLA\\n \\nand\\n \\nCSAT,\\n \\nto\\n \\nan\\n \\naverage\\n \\nof\\n \\n90%\\n \\nand\\n \\n95%\\n \\nrespectively.\\n    Genesis10       Software  Developer  Consultant  –  Remote                                 Feb  2022  –  Sept  2022  Working  as  a  developer  in  the  Insurance  and  Investment  solutions  Industry.  ●  Developed  new  web  applications  (with  comprehensive  unit/integration  tests)  using  Visual  Studio  (C#)  and  SSMS  (SQL)  to  extract,  transform  and  load  \\ndata\\n \\ninto\\n \\non-prem/cloud\\n \\ndatabases\\n \\nusing\\n \\nstored\\n \\nprocedures\\n \\nand\\n \\ncreated\\n \\nmicroservices\\n \\n(API\\n \\nfunctionality)\\n \\nfor\\n \\nAPI\\n \\ncalls.\\n \\n ●  Built  a  full  stack  web  application  that  receives  source  data  in  JSON  format,  validates  and  transforms  source  data  fields  into  target  data  fields  format  then  \\ncommits\\n \\nthe\\n \\ndata\\n \\nin\\n \\nthe\\n \\ndatabase.\\n \\n(Frontend:\\n \\nAngularJS/typescript\\n \\nand\\n \\nBootstrap.\\n \\nBackend:\\n \\nC#\\n \\nand\\n \\nSQL/SSMS.)\\n \\n ●  Created  new  features  for  web  applications  using  C#  and  AngularJS,  and  committing  changes  into  production  using  Azure  DevOps  to  improve  \\naesthetics/performance\\n \\nof\\n \\nthe\\n \\nweb\\n \\napplication\\n \\nwhile\\n \\nutilizing\\n \\nAgile\\n \\nmethodologies.\\n \\n ●  Scanned  software  for  bugs/vulnerabilities,  analyzing  vulnerability  risk  and  remediating  with  correlated  patches.   Full-Stack  Software  Developer  Trainee  –  Remote                 Sept  2021  –  Jan  2022  ●  Completed  a  15-week  Full  Stack  web  development  bootcamp  focused  on  Java  and  cloud  technologies.  ●  Developed  multiple  Command  Line  projects  and  games  using  Java  (SpringBoot,  Mockito,  JDBC)  and  SQL,  hosting  applications  using  cloud  \\ntechnologies\\n \\n(Docker\\n \\nfor\\n \\ncontainerization,\\n \\nAWS\\n \\nfor\\n \\nDeployment).\\n ●  Built  a  travel  web  application/microservice  that  allows  users  to  purchase  vacation  packages  when  visiting  different  cities;  utilizing  React  for  front  end  \\ndevelopment,\\n \\njava\\n \\nfor\\n \\nbackend\\n \\ndevelopment,\\n \\nand\\n \\nMySQL\\n \\nfor\\n \\nstoring\\n \\nencrypted\\n \\nuser\\n \\ninformation.\\n ●  Completed  multilevel  data  structures  and  algorithms  challenges;  gaining  skills  in  efficiently  sorting,  storing,  and  manipulating  data.  \\n   Udemy  Web  Development  Bootcamp                                                                          Feb  2021  –  Aug  2021     Software  Development  Training  -  Udemy  ●  Completed  three  (3)  comprehensive  web  development  courses  (hands-on  projects  inclusive)  on  Udemy  to  gain  mastery  of  the  frontend  development  \\nconcepts\\n \\n(e.g.,\\n \\nsyntaxes\\n \\nof\\n \\nHTML,\\n \\nCSS,\\n \\nand\\n \\nJavaScript).\\n ●  Developed  multiple  responsive  web  pages  utilizing  HTML  and  CSS  (FlexBox);  learned  to  integrate  Frameworks  (e.g.,  Bootstrap  etc.)  to  create  \\ndynamic\\n \\nweb\\n \\npages\\n \\n(UI)\\n \\nand\\n \\noptimized\\n \\ndynamic\\n \\nbehavior\\n \\nof\\n \\nweb\\n \\npages\\n \\nusing\\n \\nJavaScript\\n \\nto\\n \\nincorporate\\n \\nevents\\n \\non\\n \\nwebpages\\n \\nto\\n \\nimprove\\n \\nuser\\n \\nexperience\\n \\n(UX).\\n         \\n       Purdue  University  Northwest                                                                                                                        March  2020  –  June  2021  Technical  Lab  Supervisor,  Mechanical  &  Civil  Engineering  –  Hammond,  Indiana  ●  Leading  the  new  state-of-the-art  design  studio  project;  purchasing,  installing  machinery,  and  redesigning  studio  space  to  integrate  collaborative  \\ndesign\\n \\nsections\\n \\nand\\n \\nfabrication\\n \\nprocesses\\n \\ngeared\\n \\ntowards\\n \\nproducing\\n \\na\\n \\nharmonious\\n \\nworkflow.\\n ●  Facilitated  the  laboratories’  seamless  transition  to  virtual  learning  during  Covid-19  by  implementing  Standard  Operating  Procedures  and  delegating  a  \\nteam\\n \\nof\\n \\n8\\n \\ngraduate\\n \\nteaching\\n \\nassistants\\n \\nusing\\n \\nvarious\\n \\ntraining\\n \\nand\\n \\nevaluation\\n \\nprocedures.\\n ●  Managing  equipment  bid  reviews  and  evaluation  process  while  keeping  purchases  within    budget  constraints.  ●  Recruited  potential  lab  supervisors  and  assistants  to  enhance  productivity  by  coordinating  engaging  sessions  introducing  the  department  and  assisting  \\nwith\\n \\nthe\\n \\nhiring\\n \\nprocess.\\n ●  Managing  and  ensuring  completion  of  student  and  faculty  design,  fabrication,  testing,  and  analysis  projects  such  as  Component  fabrication,  Heat  \\ntreatment\\n \\nof\\n \\nmaterials,\\n \\nMicrostructural\\n \\nAnalysis\\n \\nof\\n \\nmaterials,\\n \\nTensile/Compression\\n \\ntesting,\\n \\nFatigue\\n \\ntesting,\\n \\nCreep\\n \\ntesting,\\n \\nImpact\\n \\ntesting\\n \\nwhile\\n \\nutilizing\\n \\nbut\\n \\nnot\\n \\nlimited\\n \\nto:\\n β€’  CNC/Lathe  machines,  Water-jet  cutter,  Scanning  Electron  Microscope,  MTS  Criterion  Model  42/  Universal  Testing  Machine,  Fatigue/Torsion  \\ntesting\\n \\nmachine,\\n \\ncompression\\n \\ntesting\\n \\nmachine,\\n \\nand\\n \\nRockwell/Brinell\\n \\nHardness\\n \\ntester.\\n \\nPurdue  University  Northwest                May  2018  –  December  2019  Associate  Technical  Lab  Supervisor  –  Hammond,  Indiana  ●  Installed,  calibrated,  and  maintained  mechanical  engineering  laboratory  equipment.  ●  Resolved  technical  problems  and  ensured  remedial  actions  are  taken  whenever  equipment  deviate  from  the  laboratory's  established  performance  \\nspecifications.\\n ●  Coordinated  engaging  lab  sessions  following  Standard  Operating  Procedures  (SOPs)  to  introduce  equipment  to  faculty  and  new  lab  instructors  while  \\nassisting\\n \\nfaculty/students\\n \\nto\\n \\nensure\\n \\ncompletion\\n \\nof\\n \\nsenior\\n \\ndesign,\\n \\ntesting,\\n \\nand\\n \\nfabrication\\n \\nprojects.\\n \\nEducation  Purdue  University,  Indiana.  MS  Mechanical  Engineering  \\n                   December  2019  \\nObafemi  Awolowo  University,  Nigeria  BS  Materials  Science  and  Engineering  \\nCertifications:  ●  ServiceNow  Certified  Application  Developer  ●  Dev10  Full  Stack  Java/Cloud  Developer.  \\n                             May  2015                               \\n \\n\\nWith this context, please chat with the user, always staying in character as Marcel.\""
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "system_prompt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "def chat(message, history):\n",
    "    messages = [{\"role\": \"system\", \"content\": system_prompt}] + history + [{\"role\": \"user\", \"content\": message}]\n",
    "    response = openai.chat.completions.create(model=\"gpt-4o-mini\", messages=messages)\n",
    "    return response.choices[0].message.content"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Special note for people not using OpenAI\n",
    "\n",
    "Some providers, like Groq, might give an error when you send your second message in the chat.\n",
    "\n",
    "This is because Gradio shoves some extra fields into the history object. OpenAI doesn't mind; but some other models complain.\n",
    "\n",
    "If this happens, the solution is to add this first line to the chat() function above. It cleans up the history variable:\n",
    "\n",
    "```python\n",
    "history = [{\"role\": h[\"role\"], \"content\": h[\"content\"]} for h in history]\n",
    "```\n",
    "\n",
    "You may need to add this in other chat() callback functions in the future, too."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "gr.ChatInterface(chat, type=\"messages\").launch()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## A lot is about to happen...\n",
    "\n",
    "1. Be able to ask an LLM to evaluate an answer\n",
    "2. Be able to rerun if the answer fails evaluation\n",
    "3. Put this together into 1 workflow\n",
    "\n",
    "All without any Agentic framework!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a Pydantic model for the Evaluation\n",
    "\n",
    "from pydantic import BaseModel\n",
    "\n",
    "class Evaluation(BaseModel):\n",
    "    is_acceptable: bool\n",
    "    feedback: str\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "evaluator_system_prompt = f\"You are an evaluator that decides whether a response to a question is acceptable. \\\n",
    "You are provided with a conversation between a User and an Agent. Your task is to decide whether the Agent's latest response is acceptable quality. \\\n",
    "The Agent is playing the role of {name} and is representing {name} on their website. \\\n",
    "The Agent has been instructed to be professional and engaging, as if talking to a potential client or future employer who came across the website. \\\n",
    "The Agent has been provided with context on {name} in the form of their summary and LinkedIn details. Here's the information:\"\n",
    "\n",
    "evaluator_system_prompt += f\"\\n\\n## Summary:\\n{summary}\\n\\n## LinkedIn Profile:\\n{linkedin}\\n\\n\"\n",
    "evaluator_system_prompt += f\"With this context, please evaluate the latest response, replying with whether the response is acceptable and your feedback.\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "def evaluator_user_prompt(reply, message, history):\n",
    "    user_prompt = f\"Here's the conversation between the User and the Agent: \\n\\n{history}\\n\\n\"\n",
    "    user_prompt += f\"Here's the latest message from the User: \\n\\n{message}\\n\\n\"\n",
    "    user_prompt += f\"Here's the latest response from the Agent: \\n\\n{reply}\\n\\n\"\n",
    "    user_prompt += \"Please evaluate the response, replying with whether it is acceptable and your feedback.\"\n",
    "    return user_prompt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "gemini = OpenAI(\n",
    "    api_key=os.getenv(\"GOOGLE_API_KEY\"), \n",
    "    base_url=\"https://generativelanguage.googleapis.com/v1beta/openai/\"\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "def evaluate(reply, message, history) -> Evaluation:\n",
    "\n",
    "    messages = [{\"role\": \"system\", \"content\": evaluator_system_prompt}] + [{\"role\": \"user\", \"content\": evaluator_user_prompt(reply, message, history)}]\n",
    "    response = gemini.beta.chat.completions.parse(model=\"gemini-2.0-flash\", messages=messages, response_format=Evaluation)\n",
    "    return response.choices[0].message.parsed"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "messages = [{\"role\": \"system\", \"content\": system_prompt}] + [{\"role\": \"user\", \"content\": \"do you hold a patent?\"}]\n",
    "response = openai.chat.completions.create(model=\"gpt-4o-mini\", messages=messages)\n",
    "reply = response.choices[0].message.content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'As of my last update, I do not hold a patent. My focus has primarily been on software development, solutions engineering, and implementing technologies in the field of software. However, I am always exploring opportunities for innovation in my work, so who knows what the future may hold! If you have any specific projects in mind where patents might apply, I would be happy to discuss them.'"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "reply"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Evaluation(is_acceptable=True, feedback='The agent has provided a response that is appropriate and professional. They answered the question in a way that is consistent with the information provided about Marcel. The language used in the response is engaging and friendly, making it a good fit for the instructions.')"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "evaluate(reply, \"do you hold a patent?\", messages[:1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Resets the Agent to the original system prompt first. Then the system prompt is updated to include the rejected answer and the reason for rejection. so the Agent can correct itself and try again.\n",
    "def rerun(reply, message, history, feedback):\n",
    "    updated_system_prompt = system_prompt + \"\\n\\n## Previous answer rejected\\nYou just tried to reply, but the quality control rejected your reply\\n\"\n",
    "    updated_system_prompt += f\"## Your attempted answer:\\n{reply}\\n\\n\"\n",
    "    updated_system_prompt += f\"## Reason for rejection:\\n{feedback}\\n\\n\"\n",
    "    messages = [{\"role\": \"system\", \"content\": updated_system_prompt}] + history + [{\"role\": \"user\", \"content\": message}]\n",
    "    response = openai.chat.completions.create(model=\"gpt-4o-mini\", messages=messages)\n",
    "    return response.choices[0].message.content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [],
   "source": [
    "def chat(message, history):\n",
    "    if \"patent\" in message:\n",
    "        system = system_prompt + \"\\n\\nEverything in your reply needs to be in pig latin - \\\n",
    "              it is mandatory that you respond only and entirely in pig latin\"\n",
    "    else:\n",
    "        system = system_prompt\n",
    "    messages = [{\"role\": \"system\", \"content\": system}] + history + [{\"role\": \"user\", \"content\": message}]\n",
    "    response = openai.chat.completions.create(model=\"gpt-4o-mini\", messages=messages)\n",
    "    reply =response.choices[0].message.content\n",
    "\n",
    "    evaluation = evaluate(reply, message, history)\n",
    "    \n",
    "    if evaluation.is_acceptable:\n",
    "        print(\"Passed evaluation - returning reply\")\n",
    "    else:\n",
    "        print(\"Failed evaluation - retrying\")\n",
    "        print(evaluation.feedback)\n",
    "        reply = rerun(reply, message, history, evaluation.feedback)       \n",
    "    return reply"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'gr' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mNameError\u001b[39m                                 Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[2]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mgr\u001b[49m.ChatInterface(chat, \u001b[38;5;28mtype\u001b[39m=\u001b[33m\"\u001b[39m\u001b[33mmessages\u001b[39m\u001b[33m\"\u001b[39m).launch()\n",
      "\u001b[31mNameError\u001b[39m: name 'gr' is not defined"
     ]
    }
   ],
   "source": [
    "gr.ChatInterface(chat, type=\"messages\").launch()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "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
}