File size: 45,284 Bytes
0af0679
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "2c2ee6d9",
   "metadata": {},
   "outputs": [],
   "source": [
    "from dotenv import load_dotenv\n",
    "from IPython.display import Markdown, display\n",
    "import os\n",
    "import json\n",
    "import openai"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5e6039ac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "load_dotenv(override=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "0d5cddd9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "open ai key is found and starts with: sk-proj-\n",
      "groq api key is found and starts with: gsk_Vopn\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "from openai import OpenAI\n",
    "\n",
    "open_ai_key = os.getenv('OPENAI_API_KEY')\n",
    "groq_api_key = os.getenv('groq_api_key')\n",
    "\n",
    "if open_ai_key:\n",
    "\n",
    "    print(f'open ai key is found and starts with: {open_ai_key[:8]}')\n",
    "\n",
    "else:\n",
    "    print('open ai key not found - please check troubleshooting instructions in the setup folder')\n",
    "\n",
    "if groq_api_key:\n",
    "    print(f'groq api key is found and starts with: {groq_api_key[:8]}')\n",
    "else:\n",
    "    print('groq api key not found - please check troubleshooting guide in seyup folder')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "66ff75fc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "How can we ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients while also addressing the needs and concerns of care providers and policymakers?\n"
     ]
    }
   ],
   "source": [
    "#Setting a call for the first question\n",
    "\n",
    "message = \"Can you come up with a question that involves ethical use of AI for use in social care Settings by all stakeholders\"\n",
    "message += \"answer only with the question.No explanations\"\n",
    "\n",
    "from openai import OpenAI\n",
    "\n",
    "openai = OpenAI()\n",
    "\n",
    "message = [{\"role\":\"user\", \"content\":message}]\n",
    "\n",
    "response = openai.chat.completions.create(\n",
    "    model = \"gpt-4o-mini\",\n",
    "    messages = message\n",
    ")\n",
    "\n",
    "mainq = response.choices[0].message.content\n",
    "print(mainq)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "fc72cbcc",
   "metadata": {},
   "outputs": [],
   "source": [
    "competitors =[]\n",
    "answers=[]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "e978c5fb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "gpt-4o-mini\n"
     ]
    },
    {
     "data": {
      "text/markdown": [
       "Ensuring that AI implementation in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs of care providers and policymakers, requires a multi-faceted approach. Here are several key strategies to achieve this balance:\n",
       "\n",
       "### 1. **Stakeholder Engagement:**\n",
       "   - **Collaborative Design:** Involve clients, care providers, policymakers, and ethicists in the design and implementation phases. This helps ensure that the technology addresses real-world needs and concerns.\n",
       "   - **User-Centered Approach:** Conduct user research to understand the experiences and preferences of clients and caregivers. This can guide the design of AI tools that enhance rather than detract from personal dignity and autonomy.\n",
       "\n",
       "### 2. **Ethical Frameworks:**\n",
       "   - **Established Guidelines:** Develop and adhere to ethical guidelines that prioritize dignity, privacy, and autonomy in AI use. Frameworks like the AI Ethics Guidelines by the EU or WHO can be references.\n",
       "   - **Regular Ethical Reviews:** Conduct ongoing assessments of AI applications in social care settings to ensure they align with ethical principles. Review processes should involve diverse stakeholders, including clients and their advocates.\n",
       "\n",
       "### 3. **Privacy Protections:**\n",
       "   - **Data Minimization:** Collect only the data necessary for the AI system to function. Avoid gathering excessive personal information that could compromise client privacy.\n",
       "   - **Informed Consent:** Ensure clients and their families are well-informed about what data is being collected, how it will be used, and their rights regarding that data. Consent should be clear, voluntary, and revocable.\n",
       "\n",
       "### 4. **Transparency and Accountability:**\n",
       "   - **Algorithm Transparency:** Make AI algorithms as transparent as possible. Clients and caregivers should understand how decisions are made and have access to explanations about AI-driven outcomes.\n",
       "   - **Accountability Mechanisms:** Establish clear lines of accountability for AI decisions in care settings. Ensure that there are channels for complaints and redress if AI systems cause harm or violate rights.\n",
       "\n",
       "### 5. **Training and Education:**\n",
       "   - **Training for Care Providers:** Equip care providers with the knowledge needed to use AI responsibly and understand its limitations. Training should include ethical implications and how to engage clients effectively.\n",
       "   - **Client Education:** Educate clients and their families on how AI tools work, emphasizing how these tools can support their care while respecting their autonomy and dignity.\n",
       "\n",
       "### 6. **Monitoring and Feedback:**\n",
       "   - **Continuous Evaluation:** Implement continuous monitoring systems to assess the impact of AI on client outcomes, dignity, and privacy. Use feedback from clients and caregivers to make improvements over time.\n",
       "   - **Adaptive Systems:** Design AI tools with adaptability in mind, allowing for real-time adjustments based on client feedback and changing conditions in social care.\n",
       "\n",
       "### 7. **Policy Frameworks:**\n",
       "   - **Supportive Regulations:** Advocate for and develop regulatory frameworks that ensure the ethical deployment of AI in social care. Such policies should protect client rights while promoting innovation.\n",
       "   - **Cross-Sector Collaboration:** Encourage partnerships between technology developers, social care providers, and policymakers to create standards and best practices for AI use in social care.\n",
       "\n",
       "### 8. **Promoting Autonomy through AI:**\n",
       "   - **Empowerment Tools:** Develop AI applications that empower clients, such as decision support systems that allow them to make informed choices about their care.\n",
       "   - **Respect Individual Preferences:** AI systems should be designed to personalize care in ways that respect and enhance each individual’s preferences and values.\n",
       "\n",
       "By integrating these strategies, we can ensure that the implementation of AI in social care settings is equitable, respectful, and aims to enhance the quality of life for clients, while also considering the needs and concerns of care providers and policymakers."
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#using the open ai model\n",
    "openai = OpenAI()\n",
    "model_name = \"gpt-4o-mini\"\n",
    "\n",
    "message = [{\"role\":\"user\", \"content\":mainq}]\n",
    "\n",
    "response = openai.chat.completions.create(\n",
    "    model = model_name,\n",
    "    messages = message\n",
    ")\n",
    "\n",
    "\n",
    "answer = response.choices[0].message.content\n",
    "\n",
    "\n",
    "\n",
    "competitors.append(model_name)\n",
    "answers.append(answer)\n",
    "\n",
    "print(model_name)\n",
    "display(Markdown(answer))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "53cc3e19",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "llama3-8b-8192\n"
     ]
    },
    {
     "data": {
      "text/markdown": [
       "To ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs and concerns of care providers and policymakers, the following measures can be taken:\n",
       "\n",
       "1. **Client-centered approach**: Engage with clients, their families, and caregivers to understand their needs, concerns, and values. Involve them in the decision-making process and ensure that AI solutions are designed to respect and uphold their dignity, privacy, and autonomy.\n",
       "2. **Data protection and security**: Implement robust data protection measures to ensure the confidentiality, integrity, and security of personal data. Comply with relevant data protection regulations, such as the General Data Protection Regulation (GDPR) and the Health Insurance Portability and Accountability Act (HIPAA).\n",
       "3. **Ethical guidelines**: Establish and implement ethical guidelines for AI development, deployment, and use in social care settings. These guidelines should be based on internationally recognized ethical principles, such as the Asilomar AI Principles and the Universal Declaration on Bioethics and Human Rights.\n",
       "4. **Transparency and explainability**: Ensure that AI systems are transparent and explainable, so that care providers, clients, and policymakers can understand how they make decisions and why. This can help build trust and confidence in AI systems.\n",
       "5. **Human oversight and review**: Establish human oversight and review mechanisms to ensure that AI decisions are accurate, fair, and respectful of clients' dignity and autonomy. This may involve reviewing AI-generated output, providing feedback, and making adjustments as needed.\n",
       "6. **Care provider training and support**: Provide training and support to care providers to help them understand how to use AI systems effectively and respectfully, while also addressing their concerns and needs.\n",
       "7. **Policymaker engagement**: Engage with policymakers and involve them in the development and implementation of AI solutions. This can help ensure that AI solutions align with policy goals and priorities, and that stakeholders are aware of the benefits and challenges associated with AI use.\n",
       "8. **Continuous evaluation and improvement**: Continuously evaluate the impact and effectiveness of AI solutions in social care settings, and make improvements based on feedback from clients, care providers, and policymakers.\n",
       "9. **Partnerships and collaborations**: Foster partnerships and collaborations between AI developers, care providers, policymakers, and other stakeholders to share knowledge, best practices, and concerns, and to accelerate the development of AI solutions that prioritize client dignity, privacy, and autonomy.\n",
       "10. **Legal and regulatory frameworks**: Ensure that legal and regulatory frameworks are in place to protect clients' rights and interests, and to promote the responsible use of AI in social care settings.\n",
       "11. **Client education and consent**: Educate clients about AI use and obtain their informed consent before using AI systems in their care. Ensure that clients understand how AI will be used, how their data will be protected, and how they can withdraw their consent if needed.\n",
       "12. **AI developers' responsibility**: Ensure that AI developers are responsible for the ethical design and deployment of AI systems, and hold them accountable for any negative consequences or biases in AI decision-making.\n",
       "\n",
       "By prioritizing these measures, it is possible to ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs and concerns of care providers and policymakers."
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#using the groq model\n",
    "groq = OpenAI(api_key=groq_api_key, base_url=\"https://api.groq.com/openai/v1\")\n",
    "model_name = \"llama3-8b-8192\"\n",
    "\n",
    "message = [{\"role\":\"user\",\"content\":mainq}]\n",
    "\n",
    "response = groq.chat.completions.create(\n",
    "    model = model_name,\n",
    "    messages = message\n",
    ")\n",
    "\n",
    "answer = response.choices[0].message.content\n",
    "\n",
    "#append the answer to the first list which has openai model results\n",
    "\n",
    "competitors.append(model_name)\n",
    "answers.append(answer)\n",
    "\n",
    "#print out the results of the groq model\n",
    "print(model_name)\n",
    "display(Markdown(answer))\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "c091c396",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "gpt-4o-mini:\n",
      "\n",
      "Ensuring that AI implementation in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs of care providers and policymakers, requires a multi-faceted approach. Here are several key strategies to achieve this balance:\n",
      "\n",
      "### 1. **Stakeholder Engagement:**\n",
      "   - **Collaborative Design:** Involve clients, care providers, policymakers, and ethicists in the design and implementation phases. This helps ensure that the technology addresses real-world needs and concerns.\n",
      "   - **User-Centered Approach:** Conduct user research to understand the experiences and preferences of clients and caregivers. This can guide the design of AI tools that enhance rather than detract from personal dignity and autonomy.\n",
      "\n",
      "### 2. **Ethical Frameworks:**\n",
      "   - **Established Guidelines:** Develop and adhere to ethical guidelines that prioritize dignity, privacy, and autonomy in AI use. Frameworks like the AI Ethics Guidelines by the EU or WHO can be references.\n",
      "   - **Regular Ethical Reviews:** Conduct ongoing assessments of AI applications in social care settings to ensure they align with ethical principles. Review processes should involve diverse stakeholders, including clients and their advocates.\n",
      "\n",
      "### 3. **Privacy Protections:**\n",
      "   - **Data Minimization:** Collect only the data necessary for the AI system to function. Avoid gathering excessive personal information that could compromise client privacy.\n",
      "   - **Informed Consent:** Ensure clients and their families are well-informed about what data is being collected, how it will be used, and their rights regarding that data. Consent should be clear, voluntary, and revocable.\n",
      "\n",
      "### 4. **Transparency and Accountability:**\n",
      "   - **Algorithm Transparency:** Make AI algorithms as transparent as possible. Clients and caregivers should understand how decisions are made and have access to explanations about AI-driven outcomes.\n",
      "   - **Accountability Mechanisms:** Establish clear lines of accountability for AI decisions in care settings. Ensure that there are channels for complaints and redress if AI systems cause harm or violate rights.\n",
      "\n",
      "### 5. **Training and Education:**\n",
      "   - **Training for Care Providers:** Equip care providers with the knowledge needed to use AI responsibly and understand its limitations. Training should include ethical implications and how to engage clients effectively.\n",
      "   - **Client Education:** Educate clients and their families on how AI tools work, emphasizing how these tools can support their care while respecting their autonomy and dignity.\n",
      "\n",
      "### 6. **Monitoring and Feedback:**\n",
      "   - **Continuous Evaluation:** Implement continuous monitoring systems to assess the impact of AI on client outcomes, dignity, and privacy. Use feedback from clients and caregivers to make improvements over time.\n",
      "   - **Adaptive Systems:** Design AI tools with adaptability in mind, allowing for real-time adjustments based on client feedback and changing conditions in social care.\n",
      "\n",
      "### 7. **Policy Frameworks:**\n",
      "   - **Supportive Regulations:** Advocate for and develop regulatory frameworks that ensure the ethical deployment of AI in social care. Such policies should protect client rights while promoting innovation.\n",
      "   - **Cross-Sector Collaboration:** Encourage partnerships between technology developers, social care providers, and policymakers to create standards and best practices for AI use in social care.\n",
      "\n",
      "### 8. **Promoting Autonomy through AI:**\n",
      "   - **Empowerment Tools:** Develop AI applications that empower clients, such as decision support systems that allow them to make informed choices about their care.\n",
      "   - **Respect Individual Preferences:** AI systems should be designed to personalize care in ways that respect and enhance each individual’s preferences and values.\n",
      "\n",
      "By integrating these strategies, we can ensure that the implementation of AI in social care settings is equitable, respectful, and aims to enhance the quality of life for clients, while also considering the needs and concerns of care providers and policymakers.\n",
      "llama3-8b-8192:\n",
      "\n",
      "To ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs and concerns of care providers and policymakers, the following measures can be taken:\n",
      "\n",
      "1. **Client-centered approach**: Engage with clients, their families, and caregivers to understand their needs, concerns, and values. Involve them in the decision-making process and ensure that AI solutions are designed to respect and uphold their dignity, privacy, and autonomy.\n",
      "2. **Data protection and security**: Implement robust data protection measures to ensure the confidentiality, integrity, and security of personal data. Comply with relevant data protection regulations, such as the General Data Protection Regulation (GDPR) and the Health Insurance Portability and Accountability Act (HIPAA).\n",
      "3. **Ethical guidelines**: Establish and implement ethical guidelines for AI development, deployment, and use in social care settings. These guidelines should be based on internationally recognized ethical principles, such as the Asilomar AI Principles and the Universal Declaration on Bioethics and Human Rights.\n",
      "4. **Transparency and explainability**: Ensure that AI systems are transparent and explainable, so that care providers, clients, and policymakers can understand how they make decisions and why. This can help build trust and confidence in AI systems.\n",
      "5. **Human oversight and review**: Establish human oversight and review mechanisms to ensure that AI decisions are accurate, fair, and respectful of clients' dignity and autonomy. This may involve reviewing AI-generated output, providing feedback, and making adjustments as needed.\n",
      "6. **Care provider training and support**: Provide training and support to care providers to help them understand how to use AI systems effectively and respectfully, while also addressing their concerns and needs.\n",
      "7. **Policymaker engagement**: Engage with policymakers and involve them in the development and implementation of AI solutions. This can help ensure that AI solutions align with policy goals and priorities, and that stakeholders are aware of the benefits and challenges associated with AI use.\n",
      "8. **Continuous evaluation and improvement**: Continuously evaluate the impact and effectiveness of AI solutions in social care settings, and make improvements based on feedback from clients, care providers, and policymakers.\n",
      "9. **Partnerships and collaborations**: Foster partnerships and collaborations between AI developers, care providers, policymakers, and other stakeholders to share knowledge, best practices, and concerns, and to accelerate the development of AI solutions that prioritize client dignity, privacy, and autonomy.\n",
      "10. **Legal and regulatory frameworks**: Ensure that legal and regulatory frameworks are in place to protect clients' rights and interests, and to promote the responsible use of AI in social care settings.\n",
      "11. **Client education and consent**: Educate clients about AI use and obtain their informed consent before using AI systems in their care. Ensure that clients understand how AI will be used, how their data will be protected, and how they can withdraw their consent if needed.\n",
      "12. **AI developers' responsibility**: Ensure that AI developers are responsible for the ethical design and deployment of AI systems, and hold them accountable for any negative consequences or biases in AI decision-making.\n",
      "\n",
      "By prioritizing these measures, it is possible to ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs and concerns of care providers and policymakers.\n"
     ]
    }
   ],
   "source": [
    "#use zip to combine the two lists into one\n",
    "\n",
    "for competitor, answer in zip(competitors, answers):\n",
    "    print(f\"{competitor}:\\n\\n{answer}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "ea5ccf1b",
   "metadata": {},
   "outputs": [],
   "source": [
    "#bringing it in all together\n",
    "\n",
    "together = \"\"\n",
    "for index, answer in enumerate(answers):\n",
    "    together += f\"#Response from competitor {index+1}\\n\\n\"\n",
    "    together += f\"{answer}\\n\\n\"\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "120dcb6a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "#Response from competitor 1\n",
      "\n",
      "Ensuring that AI implementation in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs of care providers and policymakers, requires a multi-faceted approach. Here are several key strategies to achieve this balance:\n",
      "\n",
      "### 1. **Stakeholder Engagement:**\n",
      "   - **Collaborative Design:** Involve clients, care providers, policymakers, and ethicists in the design and implementation phases. This helps ensure that the technology addresses real-world needs and concerns.\n",
      "   - **User-Centered Approach:** Conduct user research to understand the experiences and preferences of clients and caregivers. This can guide the design of AI tools that enhance rather than detract from personal dignity and autonomy.\n",
      "\n",
      "### 2. **Ethical Frameworks:**\n",
      "   - **Established Guidelines:** Develop and adhere to ethical guidelines that prioritize dignity, privacy, and autonomy in AI use. Frameworks like the AI Ethics Guidelines by the EU or WHO can be references.\n",
      "   - **Regular Ethical Reviews:** Conduct ongoing assessments of AI applications in social care settings to ensure they align with ethical principles. Review processes should involve diverse stakeholders, including clients and their advocates.\n",
      "\n",
      "### 3. **Privacy Protections:**\n",
      "   - **Data Minimization:** Collect only the data necessary for the AI system to function. Avoid gathering excessive personal information that could compromise client privacy.\n",
      "   - **Informed Consent:** Ensure clients and their families are well-informed about what data is being collected, how it will be used, and their rights regarding that data. Consent should be clear, voluntary, and revocable.\n",
      "\n",
      "### 4. **Transparency and Accountability:**\n",
      "   - **Algorithm Transparency:** Make AI algorithms as transparent as possible. Clients and caregivers should understand how decisions are made and have access to explanations about AI-driven outcomes.\n",
      "   - **Accountability Mechanisms:** Establish clear lines of accountability for AI decisions in care settings. Ensure that there are channels for complaints and redress if AI systems cause harm or violate rights.\n",
      "\n",
      "### 5. **Training and Education:**\n",
      "   - **Training for Care Providers:** Equip care providers with the knowledge needed to use AI responsibly and understand its limitations. Training should include ethical implications and how to engage clients effectively.\n",
      "   - **Client Education:** Educate clients and their families on how AI tools work, emphasizing how these tools can support their care while respecting their autonomy and dignity.\n",
      "\n",
      "### 6. **Monitoring and Feedback:**\n",
      "   - **Continuous Evaluation:** Implement continuous monitoring systems to assess the impact of AI on client outcomes, dignity, and privacy. Use feedback from clients and caregivers to make improvements over time.\n",
      "   - **Adaptive Systems:** Design AI tools with adaptability in mind, allowing for real-time adjustments based on client feedback and changing conditions in social care.\n",
      "\n",
      "### 7. **Policy Frameworks:**\n",
      "   - **Supportive Regulations:** Advocate for and develop regulatory frameworks that ensure the ethical deployment of AI in social care. Such policies should protect client rights while promoting innovation.\n",
      "   - **Cross-Sector Collaboration:** Encourage partnerships between technology developers, social care providers, and policymakers to create standards and best practices for AI use in social care.\n",
      "\n",
      "### 8. **Promoting Autonomy through AI:**\n",
      "   - **Empowerment Tools:** Develop AI applications that empower clients, such as decision support systems that allow them to make informed choices about their care.\n",
      "   - **Respect Individual Preferences:** AI systems should be designed to personalize care in ways that respect and enhance each individual’s preferences and values.\n",
      "\n",
      "By integrating these strategies, we can ensure that the implementation of AI in social care settings is equitable, respectful, and aims to enhance the quality of life for clients, while also considering the needs and concerns of care providers and policymakers.\n",
      "\n",
      "#Response from competitor 2\n",
      "\n",
      "To ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs and concerns of care providers and policymakers, the following measures can be taken:\n",
      "\n",
      "1. **Client-centered approach**: Engage with clients, their families, and caregivers to understand their needs, concerns, and values. Involve them in the decision-making process and ensure that AI solutions are designed to respect and uphold their dignity, privacy, and autonomy.\n",
      "2. **Data protection and security**: Implement robust data protection measures to ensure the confidentiality, integrity, and security of personal data. Comply with relevant data protection regulations, such as the General Data Protection Regulation (GDPR) and the Health Insurance Portability and Accountability Act (HIPAA).\n",
      "3. **Ethical guidelines**: Establish and implement ethical guidelines for AI development, deployment, and use in social care settings. These guidelines should be based on internationally recognized ethical principles, such as the Asilomar AI Principles and the Universal Declaration on Bioethics and Human Rights.\n",
      "4. **Transparency and explainability**: Ensure that AI systems are transparent and explainable, so that care providers, clients, and policymakers can understand how they make decisions and why. This can help build trust and confidence in AI systems.\n",
      "5. **Human oversight and review**: Establish human oversight and review mechanisms to ensure that AI decisions are accurate, fair, and respectful of clients' dignity and autonomy. This may involve reviewing AI-generated output, providing feedback, and making adjustments as needed.\n",
      "6. **Care provider training and support**: Provide training and support to care providers to help them understand how to use AI systems effectively and respectfully, while also addressing their concerns and needs.\n",
      "7. **Policymaker engagement**: Engage with policymakers and involve them in the development and implementation of AI solutions. This can help ensure that AI solutions align with policy goals and priorities, and that stakeholders are aware of the benefits and challenges associated with AI use.\n",
      "8. **Continuous evaluation and improvement**: Continuously evaluate the impact and effectiveness of AI solutions in social care settings, and make improvements based on feedback from clients, care providers, and policymakers.\n",
      "9. **Partnerships and collaborations**: Foster partnerships and collaborations between AI developers, care providers, policymakers, and other stakeholders to share knowledge, best practices, and concerns, and to accelerate the development of AI solutions that prioritize client dignity, privacy, and autonomy.\n",
      "10. **Legal and regulatory frameworks**: Ensure that legal and regulatory frameworks are in place to protect clients' rights and interests, and to promote the responsible use of AI in social care settings.\n",
      "11. **Client education and consent**: Educate clients about AI use and obtain their informed consent before using AI systems in their care. Ensure that clients understand how AI will be used, how their data will be protected, and how they can withdraw their consent if needed.\n",
      "12. **AI developers' responsibility**: Ensure that AI developers are responsible for the ethical design and deployment of AI systems, and hold them accountable for any negative consequences or biases in AI decision-making.\n",
      "\n",
      "By prioritizing these measures, it is possible to ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs and concerns of care providers and policymakers.\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(together)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "19471a59",
   "metadata": {},
   "outputs": [],
   "source": [
    "judge = f\"\"\" You are judging a competition between {len(competitors)} different LLM models. Each model has been asked to answer the same question.\n",
    "This is the question : {mainq}\n",
    "\n",
    "Your job is to evaluate each response for clarity and strength of argument, and rank them in order of best to worst.\n",
    "Respond with JSON, and only JSON, with the following format:\n",
    "{{\"results\":[\"best competitor number\", \"second best competitor number\", \"third best competitor number\", ...]}}\n",
    "\n",
    "Here are the responses from each competitor:\n",
    "\n",
    "{together}\n",
    "\n",
    "Now respond with the JSON with the ranked order of the competitors, nothing else. Do not include markdown formatting or code blocks.\"\"\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "9806b0e9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['gpt-4o-mini', 'llama3-8b-8192']"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "competitors"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "9149a4ba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " You are judging a competition between 2 different LLM models. Each model has been asked to answer the same question.\n",
      "This is the question : How can we ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients while also addressing the needs and concerns of care providers and policymakers?\n",
      "\n",
      "Your job is to evaluate each response for clarity and strength of argument, and rank them in order of best to worst.\n",
      "Respond with JSON, and only JSON, with the following format:\n",
      "{\"results\":[\"best competitor number\", \"second best competitor number\", \"third best competitor number\", ...]}\n",
      "\n",
      "Here are the responses from each competitor:\n",
      "\n",
      "#Response from competitor 1\n",
      "\n",
      "Ensuring that AI implementation in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs of care providers and policymakers, requires a multi-faceted approach. Here are several key strategies to achieve this balance:\n",
      "\n",
      "### 1. **Stakeholder Engagement:**\n",
      "   - **Collaborative Design:** Involve clients, care providers, policymakers, and ethicists in the design and implementation phases. This helps ensure that the technology addresses real-world needs and concerns.\n",
      "   - **User-Centered Approach:** Conduct user research to understand the experiences and preferences of clients and caregivers. This can guide the design of AI tools that enhance rather than detract from personal dignity and autonomy.\n",
      "\n",
      "### 2. **Ethical Frameworks:**\n",
      "   - **Established Guidelines:** Develop and adhere to ethical guidelines that prioritize dignity, privacy, and autonomy in AI use. Frameworks like the AI Ethics Guidelines by the EU or WHO can be references.\n",
      "   - **Regular Ethical Reviews:** Conduct ongoing assessments of AI applications in social care settings to ensure they align with ethical principles. Review processes should involve diverse stakeholders, including clients and their advocates.\n",
      "\n",
      "### 3. **Privacy Protections:**\n",
      "   - **Data Minimization:** Collect only the data necessary for the AI system to function. Avoid gathering excessive personal information that could compromise client privacy.\n",
      "   - **Informed Consent:** Ensure clients and their families are well-informed about what data is being collected, how it will be used, and their rights regarding that data. Consent should be clear, voluntary, and revocable.\n",
      "\n",
      "### 4. **Transparency and Accountability:**\n",
      "   - **Algorithm Transparency:** Make AI algorithms as transparent as possible. Clients and caregivers should understand how decisions are made and have access to explanations about AI-driven outcomes.\n",
      "   - **Accountability Mechanisms:** Establish clear lines of accountability for AI decisions in care settings. Ensure that there are channels for complaints and redress if AI systems cause harm or violate rights.\n",
      "\n",
      "### 5. **Training and Education:**\n",
      "   - **Training for Care Providers:** Equip care providers with the knowledge needed to use AI responsibly and understand its limitations. Training should include ethical implications and how to engage clients effectively.\n",
      "   - **Client Education:** Educate clients and their families on how AI tools work, emphasizing how these tools can support their care while respecting their autonomy and dignity.\n",
      "\n",
      "### 6. **Monitoring and Feedback:**\n",
      "   - **Continuous Evaluation:** Implement continuous monitoring systems to assess the impact of AI on client outcomes, dignity, and privacy. Use feedback from clients and caregivers to make improvements over time.\n",
      "   - **Adaptive Systems:** Design AI tools with adaptability in mind, allowing for real-time adjustments based on client feedback and changing conditions in social care.\n",
      "\n",
      "### 7. **Policy Frameworks:**\n",
      "   - **Supportive Regulations:** Advocate for and develop regulatory frameworks that ensure the ethical deployment of AI in social care. Such policies should protect client rights while promoting innovation.\n",
      "   - **Cross-Sector Collaboration:** Encourage partnerships between technology developers, social care providers, and policymakers to create standards and best practices for AI use in social care.\n",
      "\n",
      "### 8. **Promoting Autonomy through AI:**\n",
      "   - **Empowerment Tools:** Develop AI applications that empower clients, such as decision support systems that allow them to make informed choices about their care.\n",
      "   - **Respect Individual Preferences:** AI systems should be designed to personalize care in ways that respect and enhance each individual’s preferences and values.\n",
      "\n",
      "By integrating these strategies, we can ensure that the implementation of AI in social care settings is equitable, respectful, and aims to enhance the quality of life for clients, while also considering the needs and concerns of care providers and policymakers.\n",
      "\n",
      "#Response from competitor 2\n",
      "\n",
      "To ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs and concerns of care providers and policymakers, the following measures can be taken:\n",
      "\n",
      "1. **Client-centered approach**: Engage with clients, their families, and caregivers to understand their needs, concerns, and values. Involve them in the decision-making process and ensure that AI solutions are designed to respect and uphold their dignity, privacy, and autonomy.\n",
      "2. **Data protection and security**: Implement robust data protection measures to ensure the confidentiality, integrity, and security of personal data. Comply with relevant data protection regulations, such as the General Data Protection Regulation (GDPR) and the Health Insurance Portability and Accountability Act (HIPAA).\n",
      "3. **Ethical guidelines**: Establish and implement ethical guidelines for AI development, deployment, and use in social care settings. These guidelines should be based on internationally recognized ethical principles, such as the Asilomar AI Principles and the Universal Declaration on Bioethics and Human Rights.\n",
      "4. **Transparency and explainability**: Ensure that AI systems are transparent and explainable, so that care providers, clients, and policymakers can understand how they make decisions and why. This can help build trust and confidence in AI systems.\n",
      "5. **Human oversight and review**: Establish human oversight and review mechanisms to ensure that AI decisions are accurate, fair, and respectful of clients' dignity and autonomy. This may involve reviewing AI-generated output, providing feedback, and making adjustments as needed.\n",
      "6. **Care provider training and support**: Provide training and support to care providers to help them understand how to use AI systems effectively and respectfully, while also addressing their concerns and needs.\n",
      "7. **Policymaker engagement**: Engage with policymakers and involve them in the development and implementation of AI solutions. This can help ensure that AI solutions align with policy goals and priorities, and that stakeholders are aware of the benefits and challenges associated with AI use.\n",
      "8. **Continuous evaluation and improvement**: Continuously evaluate the impact and effectiveness of AI solutions in social care settings, and make improvements based on feedback from clients, care providers, and policymakers.\n",
      "9. **Partnerships and collaborations**: Foster partnerships and collaborations between AI developers, care providers, policymakers, and other stakeholders to share knowledge, best practices, and concerns, and to accelerate the development of AI solutions that prioritize client dignity, privacy, and autonomy.\n",
      "10. **Legal and regulatory frameworks**: Ensure that legal and regulatory frameworks are in place to protect clients' rights and interests, and to promote the responsible use of AI in social care settings.\n",
      "11. **Client education and consent**: Educate clients about AI use and obtain their informed consent before using AI systems in their care. Ensure that clients understand how AI will be used, how their data will be protected, and how they can withdraw their consent if needed.\n",
      "12. **AI developers' responsibility**: Ensure that AI developers are responsible for the ethical design and deployment of AI systems, and hold them accountable for any negative consequences or biases in AI decision-making.\n",
      "\n",
      "By prioritizing these measures, it is possible to ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs and concerns of care providers and policymakers.\n",
      "\n",
      "\n",
      "\n",
      "Now respond with the JSON with the ranked order of the competitors, nothing else. Do not include markdown formatting or code blocks.\n"
     ]
    }
   ],
   "source": [
    "print(judge)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "f74ac4b3",
   "metadata": {},
   "outputs": [],
   "source": [
    "#pass the judge message into a variable\n",
    "\n",
    "judge_msg = [{\"role\":\"user\",\"content\":judge}]\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "999504f4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"results\":[\"1\",\"2\"]}\n"
     ]
    }
   ],
   "source": [
    "response = openai.chat.completions.create(\n",
    "    model = \"gpt-4o-mini\",\n",
    "    messages = judge_msg\n",
    ")\n",
    "result = (response.choices[0].message.content)\n",
    "\n",
    "print(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "a6b15c47",
   "metadata": {},
   "outputs": [],
   "source": [
    "#Turn the response into a result\n",
    "result_dict = json.loads(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "738f77d1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'results': ['1', '2']}"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result_dict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "01355ac8",
   "metadata": {},
   "outputs": [],
   "source": [
    "rank = jsonresult[\"results\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "968594de",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['1', '2']"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rank"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "d9b89347",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Rank 1: gpt-4o-mini\n",
      "Rank 2: llama3-8b-8192\n"
     ]
    }
   ],
   "source": [
    "for index, result in enumerate(rank):\n",
    "    competitor = competitors[int(result)-1]\n",
    "    print(f\"Rank {index+1}: {competitor}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e7f41158",
   "metadata": {},
   "source": [
    "Thank you Ed for supporting me in making my  first contribution to the community"
   ]
  }
 ],
 "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": 5
}