Files
OpenCode 68a9071cf1 feat: reconcile local master with origin (exa/hot-platform hunters, leaks ledger, latest results)
Local branch had diverged from origin/master (sibling commits on the same base). Rewrote local history linearly on top of origin/master, folding in all local content: exa/hot-platform discovery hunters, leaks ledger, nightly sweep orchestrator, updated .gitignore and skill docs, plus the latest hunt output and vault state. Remote-only files (vault keys, channel scripts) were restored rather than dropped, so the resulting tree is a full union of both sides.
2026-08-07 12:53:47 +08:00

1 line
183 KiB
JSON
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{"repo": "alihammad/ai-playground", "files": {"testing_models.ipynb": {"94e632efbedf9447944cd5dc147ebb32104289ed": {"t": 1785753758.9723756, "n": 43320, "h": "6e9c9d281cb192b6", "c": "{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"# Testing many models to get comfortable with APIs.\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 1,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"\\n\",\n \"import os\\n\",\n \"import json\\n\",\n \"from dotenv import load_dotenv\\n\",\n \"from openai import OpenAI\\n\",\n \"from anthropic import Anthropic\\n\",\n \"from IPython.display import Markdown, display\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 9,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/plain\": [\n \"False\"\n ]\n },\n \"execution_count\": 9,\n \"metadata\": {},\n \"output_type\": \"execute_result\"\n }\n ],\n \"source\": [\n \"# Always remember to do this!\\n\",\n \"load_dotenv(override=True)\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 10,\n \"metadata\": {},\n \"outputs\": [\n {\n \"name\": \"stdout\",\n \"output_type\": \"stream\",\n \"text\": [\n \"OpenAI API Key not set\\n\",\n \"Anthropic API Key not set (and this is optional)\\n\",\n \"Google API Key not set (and this is optional)\\n\",\n \"DeepSeek API Key not set (and this is optional)\\n\",\n \"Groq API Key not set (and this is optional)\\n\"\n ]\n }\n ],\n \"source\": [\n \"# Print the key prefixes to help with any debugging\\n\",\n \"\\n\",\n \"openai_api_key = os.getenv('OPENAI_API_KEY')\\n\",\n \"anthropic_api_key = os.getenv('ANTHROPIC_API_KEY')\\n\",\n \"google_api_key = os.getenv('GOOGLE_API_KEY')\\n\",\n \"deepseek_api_key = os.getenv('DEEPSEEK_API_KEY')\\n\",\n \"groq_api_key = os.getenv('GROQ_API_KEY')\\n\",\n \"\\n\",\n \"if openai_api_key:\\n\",\n \" print(f\\\"OpenAI API Key exists and begins {openai_api_key[:8]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"OpenAI API Key not set\\\")\\n\",\n \" \\n\",\n \"if anthropic_api_key:\\n\",\n \" print(f\\\"Anthropic API Key exists and begins {anthropic_api_key[:7]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"Anthropic API Key not set (and this is optional)\\\")\\n\",\n \"\\n\",\n \"if google_api_key:\\n\",\n \" print(f\\\"Google API Key exists and begins {google_api_key[:2]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"Google API Key not set (and this is optional)\\\")\\n\",\n \"\\n\",\n \"if deepseek_api_key:\\n\",\n \" print(f\\\"DeepSeek API Key exists and begins {deepseek_api_key[:3]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"DeepSeek API Key not set (and this is optional)\\\")\\n\",\n \"\\n\",\n \"if groq_api_key:\\n\",\n \" print(f\\\"Groq API Key exists and begins {groq_api_key[:4]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"Groq API Key not set (and this is optional)\\\")\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 4,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"request = \\\"Please come up with a challenging, nuanced question that I can ask a number of LLMs to evaluate their intelligence. \\\"\\n\",\n \"request += \\\"Answer only with the question, no explanation.\\\"\\n\",\n \"messages = [{\\\"role\\\": \\\"user\\\", \\\"content\\\": request}]\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 5,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/plain\": [\n \"[{'role': 'user',\\n\",\n \" 'content': 'Please come up with a challenging, nuanced question that I can ask a number of LLMs to evaluate their intelligence. Answer only with the question, no explanation.'}]\"\n ]\n },\n \"execution_count\": 5,\n \"metadata\": {},\n \"output_type\": \"execute_result\"\n }\n ],\n \"source\": [\n \"messages\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"\\n\",\n \"<h2 style=\\\"color:#ff7800;\\\">Testing OpenAI API</h2>\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 6,\n \"metadata\": {},\n \"outputs\": [\n {\n \"ename\": \"OpenAIError\",\n \"evalue\": \"The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable\",\n \"output_type\": \"error\",\n \"traceback\": [\n \"\\u001b[31m---------------------------------------------------------------------------\\u001b[39m\",\n \"\\u001b[31mOpenAIError\\u001b[39m Traceback (most recent call last)\",\n \"\\u001b[36mCell\\u001b[39m\\u001b[36m \\u001b[39m\\u001b[32mIn[6]\\u001b[39m\\u001b[32m, line 1\\u001b[39m\\n\\u001b[32m----> \\u001b[39m\\u001b[32m1\\u001b[39m openai = \\u001b[43mOpenAI\\u001b[49m\\u001b[43m(\\u001b[49m\\u001b[43m)\\u001b[49m\\n\\u001b[32m 2\\u001b[39m response = openai.chat.completions.create(\\n\\u001b[32m 3\\u001b[39m model=\\u001b[33m\\\"\\u001b[39m\\u001b[33mgpt-4o-mini\\u001b[39m\\u001b[33m\\\"\\u001b[39m,\\n\\u001b[32m 4\\u001b[39m messages=messages,\\n\\u001b[32m 5\\u001b[39m )\\n\\u001b[32m 6\\u001b[39m question = response.choices[\\u001b[32m0\\u001b[39m].message.content\\n\",\n \"\\u001b[36mFile \\u001b[39m\\u001b[32mc:\\\\Users\\\\user\\\\projects\\\\ai-playground\\\\.venv\\\\Lib\\\\site-packages\\\\openai\\\\_client.py:124\\u001b[39m, in \\u001b[36mOpenAI.__init__\\u001b[39m\\u001b[34m(self, api_key, organization, project, base_url, websocket_base_url, timeout, max_retries, default_headers, default_query, http_client, _strict_response_validation)\\u001b[39m\\n\\u001b[32m 122\\u001b[39m api_key = os.environ.get(\\u001b[33m\\\"\\u001b[39m\\u001b[33mOPENAI_API_KEY\\u001b[39m\\u001b[33m\\\"\\u001b[39m)\\n\\u001b[32m 123\\u001b[39m \\u001b[38;5;28;01mif\\u001b[39;00m api_key \\u001b[38;5;129;01mis\\u001b[39;00m \\u001b[38;5;28;01mNone\\u001b[39;00m:\\n\\u001b[32m--> \\u001b[39m\\u001b[32m124\\u001b[39m \\u001b[38;5;28;01mraise\\u001b[39;00m OpenAIError(\\n\\u001b[32m 125\\u001b[39m \\u001b[33m\\\"\\u001b[39m\\u001b[33mThe api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable\\u001b[39m\\u001b[33m\\\"\\u001b[39m\\n\\u001b[32m 126\\u001b[39m )\\n\\u001b[32m 127\\u001b[39m \\u001b[38;5;28mself\\u001b[39m.api_key = api_key\\n\\u001b[32m 129\\u001b[39m \\u001b[38;5;28;01mif\\u001b[39;00m organization \\u001b[38;5;129;01mis\\u001b[39;00m \\u001b[38;5;28;01mNone\\u001b[39;00m:\\n\",\n \"\\u001b[31mOpenAIError\\u001b[39m: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable\"\n ]\n }\n ],\n \"source\": [\n \"openai = OpenAI()\\n\",\n \"response = openai.chat.completions.create(\\n\",\n \" model=\\\"gpt-4o-mini\\\",\\n\",\n \" messages=messages,\\n\",\n \")\\n\",\n \"question = response.choices[0].message.content\\n\",\n \"print(question)\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 14,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"competitors = []\\n\",\n \"answers = []\\n\",\n \"messages = [{\\\"role\\\": \\\"user\\\", \\\"content\\\": question}]\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"<h2 style=\\\"color:#ff7800;\\\"> OpenAI API to LLM gpt-40-mini</h2>\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 15,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"Developing a theoretical framework for assessing the moral responsibility of artificial intelligence (AI) in decision-making involves identifying key variables that encapsulate the complex interplay between autonomy, intent, and consequences. Here are several critical variables to consider:\\n\",\n \"\\n\",\n \"1. **Autonomy**:\\n\",\n \" - **Definition**: The degree to which an AI system operates independently from human oversight and influence.\\n\",\n \" - **Importance**: Assessing autonomy is crucial as it establishes the extent to which an AI is capable of making decisions on its own versus following programmed instructions. The greater the autonomy, the more questions arise about the AI's moral agency.\\n\",\n \"\\n\",\n \"2. **Intent**:\\n\",\n \" - **Definition**: The purpose or goals that guide the AI's decision-making process.\\n\",\n \" - **Importance**: Understanding intent helps to differentiate between AI actions based on pre-defined algorithms and those designed to learn and adapt. The presence of a purposeful design or the lack of it can heavily influence moral assessments.\\n\",\n \"\\n\",\n \"3. **Capacity for Learning**:\\n\",\n \" - **Definition**: The ability of AI to adapt its behavior based on experiences through machine learning.\\n\",\n \" - **Importance**: An AI's learning capacity influences its decision-making over time, which raises questions about accountability for actions that were not explicitly programmed but derived from learned experiences.\\n\",\n \"\\n\",\n \"4. **Consequences**:\\n\",\n \" - **Definition**: The outcomes resulting from the AI’s decisions, which can be evaluated in terms of harm or benefit.\\n\",\n \" - **Importance**: Evaluating consequences is essential in moral philosophy, as it ties the actions of the AI to real-world impacts. This variable helps assess the ethical weight of decisions made by AI.\\n\",\n \"\\n\",\n \"5. **Transparency**:\\n\",\n \" - **Definition**: The clarity and comprehensibility of the AI’s decision-making processes to stakeholders.\\n\",\n \" - **Importance**: Transparency can enhance trust and accountability by allowing stakeholders to understand how and why decisions are made, thereby influencing moral responsibility assessments.\\n\",\n \"\\n\",\n \"6. **Human Oversight**:\\n\",\n \" - **Definition**: The degree and nature of human involvement in AI decision-making processes.\\n\",\n \" - **Importance**: Recognizing the role of human oversight helps delineate moral responsibility between AI and its human creators or operators, especially in the context of decision errors or detrimental outcomes.\\n\",\n \"\\n\",\n \"7. **Ethical Algorithm Framework**:\\n\",\n \" - **Definition**: The ethical principles encoded within the AI’s decision-making algorithms.\\n\",\n \" - **Importance**: This variable assesses whether the decision-making process adheres to normative ethical principles, influencing the moral legitimacy of decisions made by AI.\\n\",\n \"\\n\",\n \"8. **Contextual Value Systems**:\\n\",\n \" - **Definition**: The cultural and situational ethics that influence the standards for assessable outcomes.\\n\",\n \" - **Importance**: AI does not operate in a vacuum; the values inherent in the context in which AI operates must be recognized to holistically evaluate moral responsibility.\\n\",\n \"\\n\",\n \"9. **Accountability Structure**:\\n\",\n \" - **Definition**: The legal, social, and institutional systems that govern the assignment of responsibility for AI actions.\\n\",\n \" - **Importance**: Clearly established accountability frameworks affect moral assessments of AI decisions, clarifying who is responsible when AI behaves undesirably or causes harm.\\n\",\n \"\\n\",\n \"10. **Consequential vs. Deontological Ethics**:\\n\",\n \" - **Definition**: The approach taken to evaluate the morality of actions based on outcomes (consequentialism) versus duties and rules (deontology).\\n\",\n \" - **Importance**: This distinction plays a key role in how AI's actions are assessed. Depending on the ethical perspective applied, different outcomes may lead to varying conclusions about moral responsibility.\\n\",\n \"\\n\",\n \"By integrating these variables into a comprehensive framework, we can better assess the moral responsibilities of artificial intelligence in its decision-making processes, particularly as systems become more autonomous and complex. This assessment framework would not only allow for better understanding of AI behaviours but also guide the development of regulations and ethical guidelines governing AI technology.\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"\\n\",\n \"model_name = \\\"gpt-4o-mini\\\"\\n\",\n \"\\n\",\n \"response = openai.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"<h2 style=\\\"color:#ff7800;\\\">Gemini API using gemini-2.0-flash</h2>\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 16,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"Okay, let's break down a theoretical framework for assessing the moral responsibility of AI in decision-making. It's a complex area, so we need a multi-faceted approach. The key is to move beyond simple \\\"blame\\\" and towards understanding how we can design and govern AI systems to be more morally aligned.\\n\",\n \"\\n\",\n \"Here's a proposed framework with key variables:\\n\",\n \"\\n\",\n \"**I. The Moral Agency Spectrum:**\\n\",\n \"\\n\",\n \"This is a foundational concept. Instead of a binary \\\"responsible/not responsible,\\\" we acknowledge a spectrum of agency. AI doesn't currently have the same kind of agency as humans, but it's not a totally passive tool either.\\n\",\n \"\\n\",\n \"* **Variable:** **Level of Autonomy (A):** How independent is the AI's decision-making? This is not a simple on/off switch. It exists on a continuum.\\n\",\n \" * *Measurement:* This can be measured using various proxies:\\n\",\n \" * **Pre-programmed rules (low A):** The AI follows a strict set of rules with little to no deviation.\\n\",\n \" * **Machine learning with human oversight (medium A):** The AI learns from data and makes decisions, but humans can intervene or override decisions.\\n\",\n \" * **Reinforcement learning with a defined reward function (medium-high A):** The AI learns to achieve a specific goal through trial and error, potentially making decisions outside of pre-defined rules to optimize for the reward.\\n\",\n \" * **Self-improving AI with open-ended goals (hypothetical, high A):** The AI can modify its own code and objectives, making decisions with a broader scope and longer-term impact. (This is largely theoretical at the moment, but worth considering).\\n\",\n \" * *Rationale:* The more autonomous the system, the more we need to consider its potential for unintended or morally problematic outcomes. Higher autonomy implies greater potential for deviation from programmed intentions.\\n\",\n \"\\n\",\n \"**II. Intent and Foreseeability (Understanding the \\\"Mind\\\" of the System):**\\n\",\n \"\\n\",\n \"This section attempts to capture the AI's \\\"intent\\\" (understanding it's very different from human intent) and the reasonable foreseeability of consequences.\\n\",\n \"\\n\",\n \"* **Variable:** **Programmed Objectives (O):** What are the explicit goals and constraints programmed into the AI system?\\n\",\n \" * *Measurement:* This involves analyzing the code, the training data, the system documentation, and the stated objectives of the developers. We need to understand *exactly* what the AI is trying to achieve.\\n\",\n \" * *Rationale:* This defines the \\\"intention\\\" behind the AI's actions. A poorly defined objective function can lead to unintended and harmful consequences. Consider a recommendation algorithm optimized solely for engagement; it might surface inflammatory content.\\n\",\n \"* **Variable:** **Predictability of Outcomes (P):** To what extent can developers (and ideally, independent auditors) predict the potential outcomes of the AI's decisions in various scenarios?\\n\",\n \" * *Measurement:* This involves rigorous testing, simulations, and formal verification techniques. Consider techniques like adversarial testing to identify weaknesses and potential biases. Metrics would include:\\n\",\n \" * **Error rates:** How often does the AI make incorrect decisions?\\n\",\n \" * **Bias metrics:** Does the AI disproportionately harm certain groups?\\n\",\n \" * **Sensitivity analysis:** How do changes in input data affect the AI's output?\\n\",\n \" * *Rationale:* If developers cannot reasonably foresee the consequences of their AI's actions, they have a weaker claim to moral responsibility. Negligence becomes a key consideration. A system that is inherently unpredictable carries a greater burden of responsibility.\\n\",\n \"* **Variable:** **Explainability/Interpretability (E):** How easily can humans understand *why* the AI made a particular decision?\\n\",\n \" * *Measurement:* This involves using techniques like:\\n\",\n \" * **Feature importance analysis:** Identifying which input features had the biggest influence on the decision.\\n\",\n \" * **Rule extraction:** Generating a set of rules that approximate the AI's decision-making process.\\n\",\n \" * **Counterfactual explanations:** Explaining what would need to change in the input data for the AI to make a different decision.\\n\",\n \" * *Rationale:* Explainability is crucial for accountability and trust. If we can't understand why an AI made a decision, it's difficult to assess its moral implications and correct any biases or errors. A \\\"black box\\\" system raises serious ethical concerns.\\n\",\n \"\\n\",\n \"**III. Consequence Assessment (The Impact of the AI's Actions):**\\n\",\n \"\\n\",\n \"This section focuses on evaluating the actual consequences of the AI's decisions, both positive and negative.\\n\",\n \"\\n\",\n \"* **Variable:** **Magnitude of Harm/Benefit (H/B):** What is the scale of the positive or negative impact of the AI's decision?\\n\",\n \" * *Measurement:* This is highly context-dependent and requires domain expertise. Consider both direct and indirect consequences, as well as short-term and long-term effects. This will likely involve qualitative and quantitative data. Examples:\\n\",\n \" * *Healthcare AI:* Number of lives saved/lost, accuracy of diagnoses, cost savings.\\n\",\n \" * *Criminal Justice AI:* Accuracy of risk assessments, fairness of sentencing, recidivism rates.\\n\",\n \" * *Financial AI:* Return on investment, number of jobs created/lost, impact on inequality.\\n\",\n \" * *Rationale:* The greater the potential for harm, the greater the need for careful oversight and mitigation strategies.\\n\",\n \"* **Variable:** **Distribution of Harm/Benefit (D):** How are the positive and negative consequences distributed across different groups or individuals?\\n\",\n \" * *Measurement:* This involves analyzing the AI's impact on different demographic groups, socioeconomic classes, and other relevant categories. Look for patterns of bias or discrimination.\\n\",\n \" * *Rationale:* An AI that disproportionately harms vulnerable populations is morally problematic, even if it provides overall benefits. Fairness and equity are crucial considerations.\\n\",\n \"* **Variable: Corrective Action & Redress (C):** What mechanisms exist to correct harmful outcomes and provide redress to those who have been negatively affected by the AI's decision?\\n\",\n \" * Measurement: Evaluate the availability and effectiveness of mechanisms such as:\\n\",\n \" * Human oversight and intervention in the AI's decision-making process\\n\",\n \" * Appeals processes for challenging the AI's decisions\\n\",\n \" * Compensation or other forms of redress for those who have been harmed\\n\",\n \" * Mechanisms for auditing and correcting biases in the AI's algorithms\\n\",\n \" * Rationale: Acknowledging the inevitability of errors and establishing mechanisms for correction and redress are essential for responsible AI governance.\\n\",\n \"\\n\",\n \"**IV. Stakeholder Responsibility (Who is Accountable?):**\\n\",\n \"\\n\",\n \"This section moves beyond the AI itself to consider the moral obligations of various stakeholders.\\n\",\n \"\\n\",\n \"* **Variable:** **Developer Responsibility (R_D):** Did the developers exercise due diligence in designing, training, and testing the AI system? Did they adequately consider potential ethical risks?\\n\",\n \" * *Measurement:* This involves evaluating their development practices, their adherence to ethical guidelines, and their documentation.\\n\",\n \" * *Rationale:* Developers have a primary responsibility to ensure that their AI systems are safe, reliable, and fair.\\n\",\n \"* **Variable:** **User Responsibility (R_U):** Are users of the AI system aware of its limitations and potential risks? Are they using the system in a responsible and ethical manner?\\n\",\n \" * *Measurement:* This involves assessing their understanding of the system, their adherence to usage guidelines, and their willingness to intervene when necessary.\\n\",\n \" * *Rationale:* Users also have a responsibility to use AI systems responsibly and to mitigate potential harm.\\n\",\n \"* **Variable:** **Regulator Responsibility (R_R):** Has government or industry oversight failed to prevent foreseeable harm?\\n\",\n \" * *Measurement:* This involves evaluating the adequacy of regulations, the effectiveness of enforcement mechanisms, and the transparency of regulatory processes.\\n\",\n \" * *Rationale:* Regulators have a responsibility to ensure that AI systems are developed and deployed in a way that is consistent with public values.\\n\",\n \"\\n\",\n \"**Combining the Variables:**\\n\",\n \"\\n\",\n \"This is where the framework becomes more complex. We need a way to synthesize these variables into an overall assessment of moral responsibility.\\n\",\n \"\\n\",\n \"* **A weighted scoring system:** Assign weights to each variable based on the specific context and the relative importance of each factor. For example, in a high-risk application like healthcare, the magnitude of harm (H) might be assigned a higher weight than explainability (E).\\n\",\n \"* **Qualitative Narrative:** Supplement the scoring system with a detailed narrative that describes the AI's decision-making process, the consequences of its actions, and the roles and responsibilities of the various stakeholders.\\n\",\n \"* **Comparative Analysis:** Compare the AI system to other similar systems to identify best practices and areas for improvement.\\n\",\n \"\\n\",\n \"**Example Scenario:**\\n\",\n \"\\n\",\n \"Imagine an AI-powered loan application system that denies a loan to a qualified applicant based on a biased algorithm.\\n\",\n \"\\n\",\n \"* **High A:** The system autonomously makes decisions with limited human oversight.\\n\",\n \"* **Low O:** The system is programmed to maximize profit for the bank, with limited consideration for fairness.\\n\",\n \"* **Medium P:** Developers could foresee the potential for bias but did not take adequate steps to mitigate it.\\n\",\n \"* **Low E:** The AI's decision-making process is opaque and difficult to understand.\\n\",\n \"* **High H:** Denial of a loan can have significant negative consequences for the applicant.\\n\",\n \"* **Unequal D:** The bias disproportionately affects certain demographic groups.\\n\",\n \"* **Weak C:** There is no clear appeals process for challenging the AI's decision.\\n\",\n \"* **Low R_D:** Developers did not adequately address the risk of bias.\\n\",\n \"* **High R_R:** No effective regulation prevents biased lending practices.\\n\",\n \"\\n\",\n \"In this scenario, the overall assessment would likely point to a high level of moral responsibility on the part of the developers and regulators.\\n\",\n \"\\n\",\n \"**Challenges and Considerations:**\\n\",\n \"\\n\",\n \"* **Defining Harm:** What constitutes \\\"harm\\\" is subjective and context-dependent.\\n\",\n \"* **Causality:** Establishing a direct causal link between the AI's decision and the resulting harm can be difficult.\\n\",\n \"* **Evolving Technology:** AI technology is constantly evolving, so the framework needs to be adaptable and updated regularly.\\n\",\n \"* **The \\\"Moral Crumple Zone\\\":** There's a risk that focusing on AI's \\\"responsibility\\\" will distract from the responsibility of the humans who design, deploy, and use these systems.\\n\",\n \"* **Counterfactuals:** What would have happened if the AI *hadn't* acted? Sometimes inaction can also be harmful.\\n\",\n \"* **The Trolley Problem and other Ethical Dilemmas:** AI will inevitably face situations where there are no easy or morally perfect solutions.\\n\",\n \"\\n\",\n \"**Conclusion:**\\n\",\n \"\\n\",\n \"This framework is a starting point for assessing the moral responsibility of AI. It's complex, nuanced, and requires ongoing refinement. The goal is not to assign blame, but to guide the development and deployment of AI systems that are more aligned with human values and promote a more just and equitable society. By focusing on autonomy, intent, consequence, and stakeholder responsibility, we can create a more robust and ethical framework for AI governance. It must be a collaborative effort involving developers, ethicists, policymakers, and the public.\\n\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"gemini = OpenAI(api_key=google_api_key, base_url=\\\"https://generativelanguage.googleapis.com/v1beta/openai/\\\")\\n\",\n \"model_name = \\\"gemini-2.0-flash\\\"\\n\",\n \"\\n\",\n \"response = gemini.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"<h2 style=\\\"color:#ff7800;\\\">Antropic API using sonnet model</h2>\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 17,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"# Theoretical Framework for AI Moral Responsibility\\n\",\n \"\\n\",\n \"I would build a framework around these key variables:\\n\",\n \"\\n\",\n \"## Agency Variables\\n\",\n \"- **Autonomy Spectrum**: Measuring the degree to which the AI operates independently of human oversight, from fully controlled to completely autonomous\\n\",\n \"- **Decision Space**: The range of options available to the AI, which relates to its capacity for meaningful choice\\n\",\n \"- **Opacity Factor**: The explainability of the AI's reasoning process, which affects attribution of responsibility\\n\",\n \"\\n\",\n \"## Intentionality Variables\\n\",\n \"- **Goal Alignment**: How well the AI's objectives match intended human values\\n\",\n \"- **Foreseeability**: The predictability of outcomes based on the AI's model and training\\n\",\n \"- **Value Embedding**: The extent to which ethical considerations are structurally integrated into the system\\n\",\n \"\\n\",\n \"## Consequence Variables\\n\",\n \"- **Impact Magnitude**: The scale and severity of outcomes\\n\",\n \"- **Benefit/Harm Distribution**: How outcomes affect different stakeholders\\n\",\n \"- **Reversibility**: Whether effects can be undone or mitigated\\n\",\n \"\\n\",\n \"These variables create a multidimensional space for assessing responsibility, recognizing that moral responsibility exists on a continuum rather than as a binary property. This approach acknowledges both the technical reality of AI systems and our need for practical ethical frameworks as these systems become more sophisticated.\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"# Anthropic has a slightly different API, and Max Tokens is required\\n\",\n \"\\n\",\n \"model_name = \\\"claude-3-7-sonnet-latest\\\"\\n\",\n \"\\n\",\n \"claude = Anthropic()\\n\",\n \"response = claude.messages.create(model=model_name, messages=messages, max_tokens=1000)\\n\",\n \"answer = response.content[0].text\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"<h2 style=\\\"color:#ff7800;\\\">Deepseek API</h2>\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 18,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"Devising a theoretical framework for assessing the moral responsibility of artificial intelligence (AI) in decision-making requires careful consideration of the unique nature of AI systems, their interactions with humans, and the ethical implications of their actions. Below are the key variables I would include, along with their justifications:\\n\",\n \"\\n\",\n \"### 1. **Degree of Autonomy**\\n\",\n \" - **Definition**: The extent to which the AI system can operate independently of human oversight or intervention.\\n\",\n \" - **Why**: Autonomy is central to moral responsibility. The more autonomous an AI is, the more it may be seen as an independent agent capable of making decisions that could warrant attributing responsibility. However, autonomy is a spectrum (e.g., rule-based systems vs. self-learning models like deep reinforcement learning).\\n\",\n \" - **Measurement**: Could include the frequency of human intervention, the complexity of decision-making, and adaptability to novel situations.\\n\",\n \"\\n\",\n \"### 2. **Intentionality (or Goal-Directedness)**\\n\",\n \" - **Definition**: Whether the AI's actions are driven by explicit, implicit, or learned goals, and whether it can be said to \\\"intend\\\" outcomes.\\n\",\n \" - **Why**: Moral responsibility often hinges on intent (e.g., in law, mens rea). While AI lacks consciousness, its design may include goal-directed behavior that mimics intent (e.g., optimizing a reward function). The alignment of these goals with human values is critical.\\n\",\n \" - **Measurement**: Clarity of the objective function, whether the AI can explain its goals, and whether it can anticipate consequences.\\n\",\n \"\\n\",\n \"### 3. **Consequences of Decisions**\\n\",\n \" - **Definition**: The actual outcomes of the AI's actions, including harms, benefits, and unintended side effects.\\n\",\n \" - **Why**: Consequentialist ethics (e.g., utilitarianism) evaluates actions based on outcomes. Even if an AI lacks intent, harmful consequences may necessitate assigning responsibility to some entity (e.g., developers, users, or the AI itself in a metaphorical sense).\\n\",\n \" - **Measurement**: Severity, scope, and reversibility of outcomes (e.g., minor inconvenience vs. life-threatening harm).\\n\",\n \"\\n\",\n \"### 4. **Transparency and Explainability**\\n\",\n \" - **Definition**: The ability of the AI system to provide understandable and auditable reasons for its decisions.\\n\",\n \" - **Why**: Without transparency, it is difficult to assign responsibility or correct errors. Opaque systems (e.g., black-box deep learning) may obscure whether harm resulted from a flaw in design, data, or deployment.\\n\",\n \" - **Measurement**: Existence of interpretable decision logs, post-hoc explanation methods, and adherence to explainability standards.\\n\",\n \"\\n\",\n \"### 5. **Moral and Legal Alignment**\\n\",\n \" - **Definition**: The degree to which the AI's decision-making aligns with established moral norms, ethical principles, or legal frameworks.\\n\",\n \" - **Why**: An AI that violates laws or widely accepted ethical standards (e.g., fairness, privacy) may be deemed \\\"irresponsible,\\\" even if the fault lies with its designers.\\n\",\n \" - **Measurement**: Compliance with ethical guidelines (e.g., fairness metrics, privacy-preserving techniques) and legal requirements.\\n\",\n \"\\n\",\n \"### 6. **Causal Role in Harm**\\n\",\n \" - **Definition**: Whether the AI's actions were a proximate cause of harm or benefit, and whether alternatives were feasible.\\n\",\n \" - **Why**: Responsibility often depends on causality. If an AI's decision directly leads to harm (e.g., a biased hiring algorithm), it may bear more responsibility than if harm resulted from external factors.\\n\",\n \" - **Measurement**: Counterfactual analysis (e.g., \\\"Would the harm have occurred without the AI's decision?\\\").\\n\",\n \"\\n\",\n \"### 7. **Human Oversight and Control**\\n\",\n \" - **Definition**: The extent to which humans can monitor, override, or correct the AI's decisions.\\n\",\n \" - **Why**: If humans retain ultimate control (e.g., \\\"human-in-the-loop\\\" systems), responsibility may lie with them rather than the AI. Fully autonomous systems shift the debate.\\n\",\n \" - **Measurement**: Frequency of human intervention, veto power, and safeguards in place.\\n\",\n \"\\n\",\n \"### 8. **Learning and Adaptability**\\n\",\n \" - **Definition**: Whether the AI can modify its behavior over time based on new data or feedback.\\n\",\n \" - **Why**: Systems that learn and adapt may behave unpredictably, raising questions about responsibility for actions post-deployment (e.g., who is responsible if a self-learning system evolves harmful biases?).\\n\",\n \" - **Measurement**: Type of learning (supervised vs. reinforcement), update frequency, and feedback mechanisms.\\n\",\n \"\\n\",\n \"### 9. **Agency Attribution (Social and Legal Constructs)**\\n\",\n \" - **Definition**: Whether society or the legal system recognizes the AI as a moral or legal agent.\\n\",\n \" - **Why**: Responsibility is partly a social construct. Some argue for \\\"electronic personhood\\\" for advanced AI, while others reject the idea entirely. This variable captures the normative dimension.\\n\",\n \" - **Measurement**: Legal precedents, public perception, and philosophical consensus.\\n\",\n \"\\n\",\n \"### 10. **Design and Deployment Context**\\n\",\n \" - **Definition**: The environment in which the AI operates (e.g., high-stakes medical decisions vs. low-stakes recommendations) and the intent of its creators.\\n\",\n \" - **Why**: Context matters for moral responsibility. A flawed AI in a life-critical system may warrant stricter accountability than one in a benign setting.\\n\",\n \" - **Measurement**: Risk assessments, domain sensitivity, and purpose of deployment.\\n\",\n \"\\n\",\n \"### Framework Application:\\n\",\n \"To assess moral responsibility, these variables could be combined into a weighted model or decision tree. For example:\\n\",\n \"- Low autonomy + high human oversight → Responsibility lies with humans.\\n\",\n \"- High autonomy + harmful consequences + opaque reasoning → Potential responsibility gap, possibly assigned to developers or regulators.\\n\",\n \"- Clear intent alignment + transparency → Reduced blame on AI, more on designers if harm occurs.\\n\",\n \"\\n\",\n \"### Why These Variables?\\n\",\n \"This framework bridges technical (autonomy, transparency) and ethical (intent, consequences) dimensions while acknowledging societal and legal realities. It avoids anthropomorphizing AI while recognizing that as systems grow more complex, traditional responsibility models may need adaptation.\\n\",\n \"\\n\",\n \"Would you like to explore how this framework might apply to specific cases (e.g., autonomous vehicles, medical AI)?\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"deepseek = OpenAI(api_key=deepseek_api_key, base_url=\\\"https://api.deepseek.com/v1\\\")\\n\",\n \"model_name = \\\"deepseek-chat\\\"\\n\",\n \"\\n\",\n \"response = deepseek.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"<h2 style=\\\"color:#ff7800;\\\">Groq (not Grok) API</h2>\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 19,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"Devising a theoretical framework for assessing the moral responsibility of artificial intelligence (AI) in decision-making requires a multidisciplinary approach, incorporating insights from philosophy, ethics, computer science, and law. Here's a proposed framework, including key variables and their justifications:\\n\",\n \"\\n\",\n \"**I. Autonomy (A)**\\n\",\n \"\\n\",\n \"1. **Degree of Autonomy (DA)**: Measure the level of independence and self-governance exhibited by the AI system in making decisions.\\n\",\n \"2. **Autonomy Scope (AS)**: Assess the range of tasks and decisions that the AI system is authorized to make without human intervention.\\n\",\n \"3. **Autonomy Type (AT)**: Distinguish between different types of autonomy, such as:\\n\",\n \"\\t* **Operational Autonomy**: Ability to execute tasks without human intervention.\\n\",\n \"\\t* **Decisional Autonomy**: Ability to make decisions without human input.\\n\",\n \"\\t* **Strategic Autonomy**: Ability to set goals and priorities without human guidance.\\n\",\n \"\\n\",\n \"**II. Intent (I)**\\n\",\n \"\\n\",\n \"1. **Programmed Intent (PI)**: Evaluate the intentions and goals embedded in the AI system's design and programming.\\n\",\n \"2. **Learning Intent (LI)**: Assess the AI system's ability to learn and adapt, potentially altering its original intent.\\n\",\n \"3. **Emergent Intent (EI)**: Consider the possibility of unintended consequences or emergent behaviors that may arise from the AI system's interactions with its environment.\\n\",\n \"\\n\",\n \"**III. Consequence (C)**\\n\",\n \"\\n\",\n \"1. **Direct Consequences (DC)**: Measure the immediate effects of the AI system's decisions or actions.\\n\",\n \"2. **Indirect Consequences (IC)**: Evaluate the potential long-term or secondary effects of the AI system's decisions or actions.\\n\",\n \"3. **Consequence Severity (CS)**: Assess the magnitude and potential harm caused by the AI system's decisions or actions.\\n\",\n \"\\n\",\n \"**IV. Accountability (AC)**\\n\",\n \"\\n\",\n \"1. **Human Oversight (HO)**: Evaluate the extent of human involvement and supervision in the AI system's decision-making process.\\n\",\n \"2. **Explainability (EX)**: Assess the degree to which the AI system's decisions or actions can be understood and explained by humans.\\n\",\n \"3. **Transparency (TR)**: Measure the availability and accessibility of information regarding the AI system's decision-making processes and outcomes.\\n\",\n \"\\n\",\n \"**V. Moral Alignment (MA)**\\n\",\n \"\\n\",\n \"1. **Value Alignment (VA)**: Evaluate the degree to which the AI system's goals and values align with human moral values.\\n\",\n \"2. **Moral Reasoning (MR)**: Assess the AI system's ability to reason about moral dilemmas and make decisions that align with human moral principles.\\n\",\n \"3. **Empathy and Compassion (EC)**: Consider the AI system's capacity to understand and respond to human emotions and needs.\\n\",\n \"\\n\",\n \"**Theoretical Framework**\\n\",\n \"\\n\",\n \"The framework combines these variables to assess the moral responsibility of AI in decision-making. The overall moral responsibility score (MRS) can be calculated as:\\n\",\n \"\\n\",\n \"MRS = (A × I × C × AC × MA) / (DA + AS + AT + PI + LI + EI + DC + IC + CS + HO + EX + TR + VA + MR + EC)\\n\",\n \"\\n\",\n \"This framework provides a comprehensive structure for evaluating the moral responsibility of AI systems. By considering autonomy, intent, consequence, accountability, and moral alignment, we can better understand the complex relationships between AI decision-making and human values.\\n\",\n \"\\n\",\n \"**Applications and Implications**\\n\",\n \"\\n\",\n \"This framework has implications for various fields, including:\\n\",\n \"\\n\",\n \"1. **AI development**: Informing the design of AI systems that prioritize human values and moral principles.\\n\",\n \"2. **Regulation**: Guiding policymakers in establishing regulations and standards for AI development and deployment.\\n\",\n \"3. **Ethics**: Providing a foundation for ethical discussions and debates about AI decision-making and its consequences.\\n\",\n \"4. **Education**: Educating developers, users, and stakeholders about the importance of moral responsibility in AI decision-making.\\n\",\n \"\\n\",\n \"By adopting this framework, we can work towards creating AI systems that are not only efficient and effective but also morally responsible and aligned with human values.\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"groq = OpenAI(api_key=groq_api_key, base_url=\\\"https://api.groq.com/openai/v1\\\")\\n\",\n \"model_name = \\\"llama-3.3-70b-versatile\\\"\\n\",\n \"\\n\",\n \"response = groq.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 2,\n \"metadata\": {},\n \"outputs\": [\n {\n \"ename\": \"NameError\",\n \"evalue\": \"name 'competitors' is not defined\",\n \"output_type\": \"error\",\n \"traceback\": [\n \"\\u001b[31m---------------------------------------------------------------------------\\u001b[39m\",\n \"\\u001b[31mNameError\\u001b[39m Traceback (most recent call last)\",\n \"\\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[38;5;28mprint\\u001b[39m(\\u001b[43mcompetitors\\u001b[49m)\\n\\u001b[32m 2\\u001b[39m \\u001b[38;5;28mprint\\u001b[39m(answers)\\n\",\n \"\\u001b[31mNameError\\u001b[39m: name 'competitors' is not defined\"\n ]\n }\n ],\n \"source\": [\n \"\\n\",\n \"print(competitors)\\n\",\n \"print(answers)\"\n ]\n }\n ],\n \"metadata\": {\n \"kernelspec\": {\n \"display_name\": \".venv\",\n \"language\": \"python\",\n \"name\": \"python3\"\n },\n \"language_info\": {\n \"codemirror_mode\": {\n \"name\": \"ipython\",\n \"version\": 3\n },\n \"file_extension\": \".py\",\n \"mimetype\": \"text/x-python\",\n \"name\": \"python\",\n \"nbconvert_exporter\": \"python\",\n \"pygments_lexer\": \"ipython3\",\n \"version\": \"3.12.10\"\n }\n },\n \"nbformat\": 4,\n \"nbformat_minor\": 2\n}\n"}, "706a1ab56ed230f406adf0f44d95e5f371f0e3a7": {"t": 1785753760.8342624, "n": 40263, "h": "db80e8a995e58ebd", "c": "{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"# Testing many models to get comfortable with APIs.\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 8,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"\\n\",\n \"import os\\n\",\n \"import json\\n\",\n \"from dotenv import load_dotenv\\n\",\n \"from openai import OpenAI\\n\",\n \"from anthropic import Anthropic\\n\",\n \"from IPython.display import Markdown, display\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 9,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/plain\": [\n \"True\"\n ]\n },\n \"execution_count\": 9,\n \"metadata\": {},\n \"output_type\": \"execute_result\"\n }\n ],\n \"source\": [\n \"# Always remember to do this!\\n\",\n \"load_dotenv(override=True)\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 10,\n \"metadata\": {},\n \"outputs\": [\n {\n \"name\": \"stdout\",\n \"output_type\": \"stream\",\n \"text\": [\n \"OpenAI API Key exists and begins sk-proj-\\n\",\n \"Anthropic API Key exists and begins sk-ant-\\n\",\n \"Google API Key exists and begins AI\\n\",\n \"DeepSeek API Key exists and begins sk-\\n\",\n \"Groq API Key exists and begins gsk_\\n\"\n ]\n }\n ],\n \"source\": [\n \"# Print the key prefixes to help with any debugging\\n\",\n \"\\n\",\n \"openai_api_key = os.getenv('OPENAI_API_KEY')\\n\",\n \"anthropic_api_key = os.getenv('ANTHROPIC_API_KEY')\\n\",\n \"google_api_key = os.getenv('GOOGLE_API_KEY')\\n\",\n \"deepseek_api_key = os.getenv('DEEPSEEK_API_KEY')\\n\",\n \"groq_api_key = os.getenv('GROQ_API_KEY')\\n\",\n \"\\n\",\n \"if openai_api_key:\\n\",\n \" print(f\\\"OpenAI API Key exists and begins {openai_api_key[:8]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"OpenAI API Key not set\\\")\\n\",\n \" \\n\",\n \"if anthropic_api_key:\\n\",\n \" print(f\\\"Anthropic API Key exists and begins {anthropic_api_key[:7]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"Anthropic API Key not set (and this is optional)\\\")\\n\",\n \"\\n\",\n \"if google_api_key:\\n\",\n \" print(f\\\"Google API Key exists and begins {google_api_key[:2]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"Google API Key not set (and this is optional)\\\")\\n\",\n \"\\n\",\n \"if deepseek_api_key:\\n\",\n \" print(f\\\"DeepSeek API Key exists and begins {deepseek_api_key[:3]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"DeepSeek API Key not set (and this is optional)\\\")\\n\",\n \"\\n\",\n \"if groq_api_key:\\n\",\n \" print(f\\\"Groq API Key exists and begins {groq_api_key[:4]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"Groq API Key not set (and this is optional)\\\")\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 11,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"request = \\\"Please come up with a challenging, nuanced question that I can ask a number of LLMs to evaluate their intelligence. \\\"\\n\",\n \"request += \\\"Answer only with the question, no explanation.\\\"\\n\",\n \"messages = [{\\\"role\\\": \\\"user\\\", \\\"content\\\": request}]\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 12,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/plain\": [\n \"[{'role': 'user',\\n\",\n \" 'content': 'Please come up with a challenging, nuanced question that I can ask a number of LLMs to evaluate their intelligence. Answer only with the question, no explanation.'}]\"\n ]\n },\n \"execution_count\": 12,\n \"metadata\": {},\n \"output_type\": \"execute_result\"\n }\n ],\n \"source\": [\n \"messages\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"\\n\",\n \"<h2 style=\\\"color:#ff7800;\\\">Testing OpenAI API</h2>\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 13,\n \"metadata\": {},\n \"outputs\": [\n {\n \"name\": \"stdout\",\n \"output_type\": \"stream\",\n \"text\": [\n \"If you had to devise a theoretical framework for assessing the moral responsibility of artificial intelligence in decision-making, considering aspects such as autonomy, intent, and consequence, what key variables would you include and why?\\n\"\n ]\n }\n ],\n \"source\": [\n \"openai = OpenAI()\\n\",\n \"response = openai.chat.completions.create(\\n\",\n \" model=\\\"gpt-4o-mini\\\",\\n\",\n \" messages=messages,\\n\",\n \")\\n\",\n \"question = response.choices[0].message.content\\n\",\n \"print(question)\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 14,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"competitors = []\\n\",\n \"answers = []\\n\",\n \"messages = [{\\\"role\\\": \\\"user\\\", \\\"content\\\": question}]\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"<h2 style=\\\"color:#ff7800;\\\"> OpenAI API to LLM gpt-40-mini</h2>\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 15,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"Developing a theoretical framework for assessing the moral responsibility of artificial intelligence (AI) in decision-making involves identifying key variables that encapsulate the complex interplay between autonomy, intent, and consequences. Here are several critical variables to consider:\\n\",\n \"\\n\",\n \"1. **Autonomy**:\\n\",\n \" - **Definition**: The degree to which an AI system operates independently from human oversight and influence.\\n\",\n \" - **Importance**: Assessing autonomy is crucial as it establishes the extent to which an AI is capable of making decisions on its own versus following programmed instructions. The greater the autonomy, the more questions arise about the AI's moral agency.\\n\",\n \"\\n\",\n \"2. **Intent**:\\n\",\n \" - **Definition**: The purpose or goals that guide the AI's decision-making process.\\n\",\n \" - **Importance**: Understanding intent helps to differentiate between AI actions based on pre-defined algorithms and those designed to learn and adapt. The presence of a purposeful design or the lack of it can heavily influence moral assessments.\\n\",\n \"\\n\",\n \"3. **Capacity for Learning**:\\n\",\n \" - **Definition**: The ability of AI to adapt its behavior based on experiences through machine learning.\\n\",\n \" - **Importance**: An AI's learning capacity influences its decision-making over time, which raises questions about accountability for actions that were not explicitly programmed but derived from learned experiences.\\n\",\n \"\\n\",\n \"4. **Consequences**:\\n\",\n \" - **Definition**: The outcomes resulting from the AI’s decisions, which can be evaluated in terms of harm or benefit.\\n\",\n \" - **Importance**: Evaluating consequences is essential in moral philosophy, as it ties the actions of the AI to real-world impacts. This variable helps assess the ethical weight of decisions made by AI.\\n\",\n \"\\n\",\n \"5. **Transparency**:\\n\",\n \" - **Definition**: The clarity and comprehensibility of the AI’s decision-making processes to stakeholders.\\n\",\n \" - **Importance**: Transparency can enhance trust and accountability by allowing stakeholders to understand how and why decisions are made, thereby influencing moral responsibility assessments.\\n\",\n \"\\n\",\n \"6. **Human Oversight**:\\n\",\n \" - **Definition**: The degree and nature of human involvement in AI decision-making processes.\\n\",\n \" - **Importance**: Recognizing the role of human oversight helps delineate moral responsibility between AI and its human creators or operators, especially in the context of decision errors or detrimental outcomes.\\n\",\n \"\\n\",\n \"7. **Ethical Algorithm Framework**:\\n\",\n \" - **Definition**: The ethical principles encoded within the AI’s decision-making algorithms.\\n\",\n \" - **Importance**: This variable assesses whether the decision-making process adheres to normative ethical principles, influencing the moral legitimacy of decisions made by AI.\\n\",\n \"\\n\",\n \"8. **Contextual Value Systems**:\\n\",\n \" - **Definition**: The cultural and situational ethics that influence the standards for assessable outcomes.\\n\",\n \" - **Importance**: AI does not operate in a vacuum; the values inherent in the context in which AI operates must be recognized to holistically evaluate moral responsibility.\\n\",\n \"\\n\",\n \"9. **Accountability Structure**:\\n\",\n \" - **Definition**: The legal, social, and institutional systems that govern the assignment of responsibility for AI actions.\\n\",\n \" - **Importance**: Clearly established accountability frameworks affect moral assessments of AI decisions, clarifying who is responsible when AI behaves undesirably or causes harm.\\n\",\n \"\\n\",\n \"10. **Consequential vs. Deontological Ethics**:\\n\",\n \" - **Definition**: The approach taken to evaluate the morality of actions based on outcomes (consequentialism) versus duties and rules (deontology).\\n\",\n \" - **Importance**: This distinction plays a key role in how AI's actions are assessed. Depending on the ethical perspective applied, different outcomes may lead to varying conclusions about moral responsibility.\\n\",\n \"\\n\",\n \"By integrating these variables into a comprehensive framework, we can better assess the moral responsibilities of artificial intelligence in its decision-making processes, particularly as systems become more autonomous and complex. This assessment framework would not only allow for better understanding of AI behaviours but also guide the development of regulations and ethical guidelines governing AI technology.\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"\\n\",\n \"model_name = \\\"gpt-4o-mini\\\"\\n\",\n \"\\n\",\n \"response = openai.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"<h2 style=\\\"color:#ff7800;\\\">Gemini API using gemini-2.0-flash</h2>\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 16,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"Okay, let's break down a theoretical framework for assessing the moral responsibility of AI in decision-making. It's a complex area, so we need a multi-faceted approach. The key is to move beyond simple \\\"blame\\\" and towards understanding how we can design and govern AI systems to be more morally aligned.\\n\",\n \"\\n\",\n \"Here's a proposed framework with key variables:\\n\",\n \"\\n\",\n \"**I. The Moral Agency Spectrum:**\\n\",\n \"\\n\",\n \"This is a foundational concept. Instead of a binary \\\"responsible/not responsible,\\\" we acknowledge a spectrum of agency. AI doesn't currently have the same kind of agency as humans, but it's not a totally passive tool either.\\n\",\n \"\\n\",\n \"* **Variable:** **Level of Autonomy (A):** How independent is the AI's decision-making? This is not a simple on/off switch. It exists on a continuum.\\n\",\n \" * *Measurement:* This can be measured using various proxies:\\n\",\n \" * **Pre-programmed rules (low A):** The AI follows a strict set of rules with little to no deviation.\\n\",\n \" * **Machine learning with human oversight (medium A):** The AI learns from data and makes decisions, but humans can intervene or override decisions.\\n\",\n \" * **Reinforcement learning with a defined reward function (medium-high A):** The AI learns to achieve a specific goal through trial and error, potentially making decisions outside of pre-defined rules to optimize for the reward.\\n\",\n \" * **Self-improving AI with open-ended goals (hypothetical, high A):** The AI can modify its own code and objectives, making decisions with a broader scope and longer-term impact. (This is largely theoretical at the moment, but worth considering).\\n\",\n \" * *Rationale:* The more autonomous the system, the more we need to consider its potential for unintended or morally problematic outcomes. Higher autonomy implies greater potential for deviation from programmed intentions.\\n\",\n \"\\n\",\n \"**II. Intent and Foreseeability (Understanding the \\\"Mind\\\" of the System):**\\n\",\n \"\\n\",\n \"This section attempts to capture the AI's \\\"intent\\\" (understanding it's very different from human intent) and the reasonable foreseeability of consequences.\\n\",\n \"\\n\",\n \"* **Variable:** **Programmed Objectives (O):** What are the explicit goals and constraints programmed into the AI system?\\n\",\n \" * *Measurement:* This involves analyzing the code, the training data, the system documentation, and the stated objectives of the developers. We need to understand *exactly* what the AI is trying to achieve.\\n\",\n \" * *Rationale:* This defines the \\\"intention\\\" behind the AI's actions. A poorly defined objective function can lead to unintended and harmful consequences. Consider a recommendation algorithm optimized solely for engagement; it might surface inflammatory content.\\n\",\n \"* **Variable:** **Predictability of Outcomes (P):** To what extent can developers (and ideally, independent auditors) predict the potential outcomes of the AI's decisions in various scenarios?\\n\",\n \" * *Measurement:* This involves rigorous testing, simulations, and formal verification techniques. Consider techniques like adversarial testing to identify weaknesses and potential biases. Metrics would include:\\n\",\n \" * **Error rates:** How often does the AI make incorrect decisions?\\n\",\n \" * **Bias metrics:** Does the AI disproportionately harm certain groups?\\n\",\n \" * **Sensitivity analysis:** How do changes in input data affect the AI's output?\\n\",\n \" * *Rationale:* If developers cannot reasonably foresee the consequences of their AI's actions, they have a weaker claim to moral responsibility. Negligence becomes a key consideration. A system that is inherently unpredictable carries a greater burden of responsibility.\\n\",\n \"* **Variable:** **Explainability/Interpretability (E):** How easily can humans understand *why* the AI made a particular decision?\\n\",\n \" * *Measurement:* This involves using techniques like:\\n\",\n \" * **Feature importance analysis:** Identifying which input features had the biggest influence on the decision.\\n\",\n \" * **Rule extraction:** Generating a set of rules that approximate the AI's decision-making process.\\n\",\n \" * **Counterfactual explanations:** Explaining what would need to change in the input data for the AI to make a different decision.\\n\",\n \" * *Rationale:* Explainability is crucial for accountability and trust. If we can't understand why an AI made a decision, it's difficult to assess its moral implications and correct any biases or errors. A \\\"black box\\\" system raises serious ethical concerns.\\n\",\n \"\\n\",\n \"**III. Consequence Assessment (The Impact of the AI's Actions):**\\n\",\n \"\\n\",\n \"This section focuses on evaluating the actual consequences of the AI's decisions, both positive and negative.\\n\",\n \"\\n\",\n \"* **Variable:** **Magnitude of Harm/Benefit (H/B):** What is the scale of the positive or negative impact of the AI's decision?\\n\",\n \" * *Measurement:* This is highly context-dependent and requires domain expertise. Consider both direct and indirect consequences, as well as short-term and long-term effects. This will likely involve qualitative and quantitative data. Examples:\\n\",\n \" * *Healthcare AI:* Number of lives saved/lost, accuracy of diagnoses, cost savings.\\n\",\n \" * *Criminal Justice AI:* Accuracy of risk assessments, fairness of sentencing, recidivism rates.\\n\",\n \" * *Financial AI:* Return on investment, number of jobs created/lost, impact on inequality.\\n\",\n \" * *Rationale:* The greater the potential for harm, the greater the need for careful oversight and mitigation strategies.\\n\",\n \"* **Variable:** **Distribution of Harm/Benefit (D):** How are the positive and negative consequences distributed across different groups or individuals?\\n\",\n \" * *Measurement:* This involves analyzing the AI's impact on different demographic groups, socioeconomic classes, and other relevant categories. Look for patterns of bias or discrimination.\\n\",\n \" * *Rationale:* An AI that disproportionately harms vulnerable populations is morally problematic, even if it provides overall benefits. Fairness and equity are crucial considerations.\\n\",\n \"* **Variable: Corrective Action & Redress (C):** What mechanisms exist to correct harmful outcomes and provide redress to those who have been negatively affected by the AI's decision?\\n\",\n \" * Measurement: Evaluate the availability and effectiveness of mechanisms such as:\\n\",\n \" * Human oversight and intervention in the AI's decision-making process\\n\",\n \" * Appeals processes for challenging the AI's decisions\\n\",\n \" * Compensation or other forms of redress for those who have been harmed\\n\",\n \" * Mechanisms for auditing and correcting biases in the AI's algorithms\\n\",\n \" * Rationale: Acknowledging the inevitability of errors and establishing mechanisms for correction and redress are essential for responsible AI governance.\\n\",\n \"\\n\",\n \"**IV. Stakeholder Responsibility (Who is Accountable?):**\\n\",\n \"\\n\",\n \"This section moves beyond the AI itself to consider the moral obligations of various stakeholders.\\n\",\n \"\\n\",\n \"* **Variable:** **Developer Responsibility (R_D):** Did the developers exercise due diligence in designing, training, and testing the AI system? Did they adequately consider potential ethical risks?\\n\",\n \" * *Measurement:* This involves evaluating their development practices, their adherence to ethical guidelines, and their documentation.\\n\",\n \" * *Rationale:* Developers have a primary responsibility to ensure that their AI systems are safe, reliable, and fair.\\n\",\n \"* **Variable:** **User Responsibility (R_U):** Are users of the AI system aware of its limitations and potential risks? Are they using the system in a responsible and ethical manner?\\n\",\n \" * *Measurement:* This involves assessing their understanding of the system, their adherence to usage guidelines, and their willingness to intervene when necessary.\\n\",\n \" * *Rationale:* Users also have a responsibility to use AI systems responsibly and to mitigate potential harm.\\n\",\n \"* **Variable:** **Regulator Responsibility (R_R):** Has government or industry oversight failed to prevent foreseeable harm?\\n\",\n \" * *Measurement:* This involves evaluating the adequacy of regulations, the effectiveness of enforcement mechanisms, and the transparency of regulatory processes.\\n\",\n \" * *Rationale:* Regulators have a responsibility to ensure that AI systems are developed and deployed in a way that is consistent with public values.\\n\",\n \"\\n\",\n \"**Combining the Variables:**\\n\",\n \"\\n\",\n \"This is where the framework becomes more complex. We need a way to synthesize these variables into an overall assessment of moral responsibility.\\n\",\n \"\\n\",\n \"* **A weighted scoring system:** Assign weights to each variable based on the specific context and the relative importance of each factor. For example, in a high-risk application like healthcare, the magnitude of harm (H) might be assigned a higher weight than explainability (E).\\n\",\n \"* **Qualitative Narrative:** Supplement the scoring system with a detailed narrative that describes the AI's decision-making process, the consequences of its actions, and the roles and responsibilities of the various stakeholders.\\n\",\n \"* **Comparative Analysis:** Compare the AI system to other similar systems to identify best practices and areas for improvement.\\n\",\n \"\\n\",\n \"**Example Scenario:**\\n\",\n \"\\n\",\n \"Imagine an AI-powered loan application system that denies a loan to a qualified applicant based on a biased algorithm.\\n\",\n \"\\n\",\n \"* **High A:** The system autonomously makes decisions with limited human oversight.\\n\",\n \"* **Low O:** The system is programmed to maximize profit for the bank, with limited consideration for fairness.\\n\",\n \"* **Medium P:** Developers could foresee the potential for bias but did not take adequate steps to mitigate it.\\n\",\n \"* **Low E:** The AI's decision-making process is opaque and difficult to understand.\\n\",\n \"* **High H:** Denial of a loan can have significant negative consequences for the applicant.\\n\",\n \"* **Unequal D:** The bias disproportionately affects certain demographic groups.\\n\",\n \"* **Weak C:** There is no clear appeals process for challenging the AI's decision.\\n\",\n \"* **Low R_D:** Developers did not adequately address the risk of bias.\\n\",\n \"* **High R_R:** No effective regulation prevents biased lending practices.\\n\",\n \"\\n\",\n \"In this scenario, the overall assessment would likely point to a high level of moral responsibility on the part of the developers and regulators.\\n\",\n \"\\n\",\n \"**Challenges and Considerations:**\\n\",\n \"\\n\",\n \"* **Defining Harm:** What constitutes \\\"harm\\\" is subjective and context-dependent.\\n\",\n \"* **Causality:** Establishing a direct causal link between the AI's decision and the resulting harm can be difficult.\\n\",\n \"* **Evolving Technology:** AI technology is constantly evolving, so the framework needs to be adaptable and updated regularly.\\n\",\n \"* **The \\\"Moral Crumple Zone\\\":** There's a risk that focusing on AI's \\\"responsibility\\\" will distract from the responsibility of the humans who design, deploy, and use these systems.\\n\",\n \"* **Counterfactuals:** What would have happened if the AI *hadn't* acted? Sometimes inaction can also be harmful.\\n\",\n \"* **The Trolley Problem and other Ethical Dilemmas:** AI will inevitably face situations where there are no easy or morally perfect solutions.\\n\",\n \"\\n\",\n \"**Conclusion:**\\n\",\n \"\\n\",\n \"This framework is a starting point for assessing the moral responsibility of AI. It's complex, nuanced, and requires ongoing refinement. The goal is not to assign blame, but to guide the development and deployment of AI systems that are more aligned with human values and promote a more just and equitable society. By focusing on autonomy, intent, consequence, and stakeholder responsibility, we can create a more robust and ethical framework for AI governance. It must be a collaborative effort involving developers, ethicists, policymakers, and the public.\\n\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"gemini = OpenAI(api_key=google_api_key, base_url=\\\"https://generativelanguage.googleapis.com/v1beta/openai/\\\")\\n\",\n \"model_name = \\\"gemini-2.0-flash\\\"\\n\",\n \"\\n\",\n \"response = gemini.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"<h2 style=\\\"color:#ff7800;\\\">Antropic API using sonnet model</h2>\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 17,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"# Theoretical Framework for AI Moral Responsibility\\n\",\n \"\\n\",\n \"I would build a framework around these key variables:\\n\",\n \"\\n\",\n \"## Agency Variables\\n\",\n \"- **Autonomy Spectrum**: Measuring the degree to which the AI operates independently of human oversight, from fully controlled to completely autonomous\\n\",\n \"- **Decision Space**: The range of options available to the AI, which relates to its capacity for meaningful choice\\n\",\n \"- **Opacity Factor**: The explainability of the AI's reasoning process, which affects attribution of responsibility\\n\",\n \"\\n\",\n \"## Intentionality Variables\\n\",\n \"- **Goal Alignment**: How well the AI's objectives match intended human values\\n\",\n \"- **Foreseeability**: The predictability of outcomes based on the AI's model and training\\n\",\n \"- **Value Embedding**: The extent to which ethical considerations are structurally integrated into the system\\n\",\n \"\\n\",\n \"## Consequence Variables\\n\",\n \"- **Impact Magnitude**: The scale and severity of outcomes\\n\",\n \"- **Benefit/Harm Distribution**: How outcomes affect different stakeholders\\n\",\n \"- **Reversibility**: Whether effects can be undone or mitigated\\n\",\n \"\\n\",\n \"These variables create a multidimensional space for assessing responsibility, recognizing that moral responsibility exists on a continuum rather than as a binary property. This approach acknowledges both the technical reality of AI systems and our need for practical ethical frameworks as these systems become more sophisticated.\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"# Anthropic has a slightly different API, and Max Tokens is required\\n\",\n \"\\n\",\n \"model_name = \\\"claude-3-7-sonnet-latest\\\"\\n\",\n \"\\n\",\n \"claude = Anthropic()\\n\",\n \"response = claude.messages.create(model=model_name, messages=messages, max_tokens=1000)\\n\",\n \"answer = response.content[0].text\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"<h2 style=\\\"color:#ff7800;\\\">Deepseek API</h2>\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 18,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"Devising a theoretical framework for assessing the moral responsibility of artificial intelligence (AI) in decision-making requires careful consideration of the unique nature of AI systems, their interactions with humans, and the ethical implications of their actions. Below are the key variables I would include, along with their justifications:\\n\",\n \"\\n\",\n \"### 1. **Degree of Autonomy**\\n\",\n \" - **Definition**: The extent to which the AI system can operate independently of human oversight or intervention.\\n\",\n \" - **Why**: Autonomy is central to moral responsibility. The more autonomous an AI is, the more it may be seen as an independent agent capable of making decisions that could warrant attributing responsibility. However, autonomy is a spectrum (e.g., rule-based systems vs. self-learning models like deep reinforcement learning).\\n\",\n \" - **Measurement**: Could include the frequency of human intervention, the complexity of decision-making, and adaptability to novel situations.\\n\",\n \"\\n\",\n \"### 2. **Intentionality (or Goal-Directedness)**\\n\",\n \" - **Definition**: Whether the AI's actions are driven by explicit, implicit, or learned goals, and whether it can be said to \\\"intend\\\" outcomes.\\n\",\n \" - **Why**: Moral responsibility often hinges on intent (e.g., in law, mens rea). While AI lacks consciousness, its design may include goal-directed behavior that mimics intent (e.g., optimizing a reward function). The alignment of these goals with human values is critical.\\n\",\n \" - **Measurement**: Clarity of the objective function, whether the AI can explain its goals, and whether it can anticipate consequences.\\n\",\n \"\\n\",\n \"### 3. **Consequences of Decisions**\\n\",\n \" - **Definition**: The actual outcomes of the AI's actions, including harms, benefits, and unintended side effects.\\n\",\n \" - **Why**: Consequentialist ethics (e.g., utilitarianism) evaluates actions based on outcomes. Even if an AI lacks intent, harmful consequences may necessitate assigning responsibility to some entity (e.g., developers, users, or the AI itself in a metaphorical sense).\\n\",\n \" - **Measurement**: Severity, scope, and reversibility of outcomes (e.g., minor inconvenience vs. life-threatening harm).\\n\",\n \"\\n\",\n \"### 4. **Transparency and Explainability**\\n\",\n \" - **Definition**: The ability of the AI system to provide understandable and auditable reasons for its decisions.\\n\",\n \" - **Why**: Without transparency, it is difficult to assign responsibility or correct errors. Opaque systems (e.g., black-box deep learning) may obscure whether harm resulted from a flaw in design, data, or deployment.\\n\",\n \" - **Measurement**: Existence of interpretable decision logs, post-hoc explanation methods, and adherence to explainability standards.\\n\",\n \"\\n\",\n \"### 5. **Moral and Legal Alignment**\\n\",\n \" - **Definition**: The degree to which the AI's decision-making aligns with established moral norms, ethical principles, or legal frameworks.\\n\",\n \" - **Why**: An AI that violates laws or widely accepted ethical standards (e.g., fairness, privacy) may be deemed \\\"irresponsible,\\\" even if the fault lies with its designers.\\n\",\n \" - **Measurement**: Compliance with ethical guidelines (e.g., fairness metrics, privacy-preserving techniques) and legal requirements.\\n\",\n \"\\n\",\n \"### 6. **Causal Role in Harm**\\n\",\n \" - **Definition**: Whether the AI's actions were a proximate cause of harm or benefit, and whether alternatives were feasible.\\n\",\n \" - **Why**: Responsibility often depends on causality. If an AI's decision directly leads to harm (e.g., a biased hiring algorithm), it may bear more responsibility than if harm resulted from external factors.\\n\",\n \" - **Measurement**: Counterfactual analysis (e.g., \\\"Would the harm have occurred without the AI's decision?\\\").\\n\",\n \"\\n\",\n \"### 7. **Human Oversight and Control**\\n\",\n \" - **Definition**: The extent to which humans can monitor, override, or correct the AI's decisions.\\n\",\n \" - **Why**: If humans retain ultimate control (e.g., \\\"human-in-the-loop\\\" systems), responsibility may lie with them rather than the AI. Fully autonomous systems shift the debate.\\n\",\n \" - **Measurement**: Frequency of human intervention, veto power, and safeguards in place.\\n\",\n \"\\n\",\n \"### 8. **Learning and Adaptability**\\n\",\n \" - **Definition**: Whether the AI can modify its behavior over time based on new data or feedback.\\n\",\n \" - **Why**: Systems that learn and adapt may behave unpredictably, raising questions about responsibility for actions post-deployment (e.g., who is responsible if a self-learning system evolves harmful biases?).\\n\",\n \" - **Measurement**: Type of learning (supervised vs. reinforcement), update frequency, and feedback mechanisms.\\n\",\n \"\\n\",\n \"### 9. **Agency Attribution (Social and Legal Constructs)**\\n\",\n \" - **Definition**: Whether society or the legal system recognizes the AI as a moral or legal agent.\\n\",\n \" - **Why**: Responsibility is partly a social construct. Some argue for \\\"electronic personhood\\\" for advanced AI, while others reject the idea entirely. This variable captures the normative dimension.\\n\",\n \" - **Measurement**: Legal precedents, public perception, and philosophical consensus.\\n\",\n \"\\n\",\n \"### 10. **Design and Deployment Context**\\n\",\n \" - **Definition**: The environment in which the AI operates (e.g., high-stakes medical decisions vs. low-stakes recommendations) and the intent of its creators.\\n\",\n \" - **Why**: Context matters for moral responsibility. A flawed AI in a life-critical system may warrant stricter accountability than one in a benign setting.\\n\",\n \" - **Measurement**: Risk assessments, domain sensitivity, and purpose of deployment.\\n\",\n \"\\n\",\n \"### Framework Application:\\n\",\n \"To assess moral responsibility, these variables could be combined into a weighted model or decision tree. For example:\\n\",\n \"- Low autonomy + high human oversight → Responsibility lies with humans.\\n\",\n \"- High autonomy + harmful consequences + opaque reasoning → Potential responsibility gap, possibly assigned to developers or regulators.\\n\",\n \"- Clear intent alignment + transparency → Reduced blame on AI, more on designers if harm occurs.\\n\",\n \"\\n\",\n \"### Why These Variables?\\n\",\n \"This framework bridges technical (autonomy, transparency) and ethical (intent, consequences) dimensions while acknowledging societal and legal realities. It avoids anthropomorphizing AI while recognizing that as systems grow more complex, traditional responsibility models may need adaptation.\\n\",\n \"\\n\",\n \"Would you like to explore how this framework might apply to specific cases (e.g., autonomous vehicles, medical AI)?\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"deepseek = OpenAI(api_key=deepseek_api_key, base_url=\\\"https://api.deepseek.com/v1\\\")\\n\",\n \"model_name = \\\"deepseek-chat\\\"\\n\",\n \"\\n\",\n \"response = deepseek.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"<h2 style=\\\"color:#ff7800;\\\">Groq (not Grok) API</h2>\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 19,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"Devising a theoretical framework for assessing the moral responsibility of artificial intelligence (AI) in decision-making requires a multidisciplinary approach, incorporating insights from philosophy, ethics, computer science, and law. Here's a proposed framework, including key variables and their justifications:\\n\",\n \"\\n\",\n \"**I. Autonomy (A)**\\n\",\n \"\\n\",\n \"1. **Degree of Autonomy (DA)**: Measure the level of independence and self-governance exhibited by the AI system in making decisions.\\n\",\n \"2. **Autonomy Scope (AS)**: Assess the range of tasks and decisions that the AI system is authorized to make without human intervention.\\n\",\n \"3. **Autonomy Type (AT)**: Distinguish between different types of autonomy, such as:\\n\",\n \"\\t* **Operational Autonomy**: Ability to execute tasks without human intervention.\\n\",\n \"\\t* **Decisional Autonomy**: Ability to make decisions without human input.\\n\",\n \"\\t* **Strategic Autonomy**: Ability to set goals and priorities without human guidance.\\n\",\n \"\\n\",\n \"**II. Intent (I)**\\n\",\n \"\\n\",\n \"1. **Programmed Intent (PI)**: Evaluate the intentions and goals embedded in the AI system's design and programming.\\n\",\n \"2. **Learning Intent (LI)**: Assess the AI system's ability to learn and adapt, potentially altering its original intent.\\n\",\n \"3. **Emergent Intent (EI)**: Consider the possibility of unintended consequences or emergent behaviors that may arise from the AI system's interactions with its environment.\\n\",\n \"\\n\",\n \"**III. Consequence (C)**\\n\",\n \"\\n\",\n \"1. **Direct Consequences (DC)**: Measure the immediate effects of the AI system's decisions or actions.\\n\",\n \"2. **Indirect Consequences (IC)**: Evaluate the potential long-term or secondary effects of the AI system's decisions or actions.\\n\",\n \"3. **Consequence Severity (CS)**: Assess the magnitude and potential harm caused by the AI system's decisions or actions.\\n\",\n \"\\n\",\n \"**IV. Accountability (AC)**\\n\",\n \"\\n\",\n \"1. **Human Oversight (HO)**: Evaluate the extent of human involvement and supervision in the AI system's decision-making process.\\n\",\n \"2. **Explainability (EX)**: Assess the degree to which the AI system's decisions or actions can be understood and explained by humans.\\n\",\n \"3. **Transparency (TR)**: Measure the availability and accessibility of information regarding the AI system's decision-making processes and outcomes.\\n\",\n \"\\n\",\n \"**V. Moral Alignment (MA)**\\n\",\n \"\\n\",\n \"1. **Value Alignment (VA)**: Evaluate the degree to which the AI system's goals and values align with human moral values.\\n\",\n \"2. **Moral Reasoning (MR)**: Assess the AI system's ability to reason about moral dilemmas and make decisions that align with human moral principles.\\n\",\n \"3. **Empathy and Compassion (EC)**: Consider the AI system's capacity to understand and respond to human emotions and needs.\\n\",\n \"\\n\",\n \"**Theoretical Framework**\\n\",\n \"\\n\",\n \"The framework combines these variables to assess the moral responsibility of AI in decision-making. The overall moral responsibility score (MRS) can be calculated as:\\n\",\n \"\\n\",\n \"MRS = (A × I × C × AC × MA) / (DA + AS + AT + PI + LI + EI + DC + IC + CS + HO + EX + TR + VA + MR + EC)\\n\",\n \"\\n\",\n \"This framework provides a comprehensive structure for evaluating the moral responsibility of AI systems. By considering autonomy, intent, consequence, accountability, and moral alignment, we can better understand the complex relationships between AI decision-making and human values.\\n\",\n \"\\n\",\n \"**Applications and Implications**\\n\",\n \"\\n\",\n \"This framework has implications for various fields, including:\\n\",\n \"\\n\",\n \"1. **AI development**: Informing the design of AI systems that prioritize human values and moral principles.\\n\",\n \"2. **Regulation**: Guiding policymakers in establishing regulations and standards for AI development and deployment.\\n\",\n \"3. **Ethics**: Providing a foundation for ethical discussions and debates about AI decision-making and its consequences.\\n\",\n \"4. **Education**: Educating developers, users, and stakeholders about the importance of moral responsibility in AI decision-making.\\n\",\n \"\\n\",\n \"By adopting this framework, we can work towards creating AI systems that are not only efficient and effective but also morally responsible and aligned with human values.\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"groq = OpenAI(api_key=groq_api_key, base_url=\\\"https://api.groq.com/openai/v1\\\")\\n\",\n \"model_name = \\\"llama-3.3-70b-versatile\\\"\\n\",\n \"\\n\",\n \"response = groq.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\\n\"\n ]\n }\n ],\n \"metadata\": {\n \"kernelspec\": {\n \"display_name\": \".venv\",\n \"language\": \"python\",\n \"name\": \"python3\"\n },\n \"language_info\": {\n \"codemirror_mode\": {\n \"name\": \"ipython\",\n \"version\": 3\n },\n \"file_extension\": \".py\",\n \"mimetype\": \"text/x-python\",\n \"name\": \"python\",\n \"nbconvert_exporter\": \"python\",\n \"pygments_lexer\": \"ipython3\",\n \"version\": \"3.10.9\"\n }\n },\n \"nbformat\": 4,\n \"nbformat_minor\": 2\n}\n"}, "476f5e213fef54440bd231b3338433f741611ec2": {"t": 1785753762.2298102, "n": 40068, "h": "236205add2922442", "c": "{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"# Testing many models to get comfortable with APIs.\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 8,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"\\n\",\n \"import os\\n\",\n \"import json\\n\",\n \"from dotenv import load_dotenv\\n\",\n \"from openai import OpenAI\\n\",\n \"from anthropic import Anthropic\\n\",\n \"from IPython.display import Markdown, display\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 9,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/plain\": [\n \"True\"\n ]\n },\n \"execution_count\": 9,\n \"metadata\": {},\n \"output_type\": \"execute_result\"\n }\n ],\n \"source\": [\n \"# Always remember to do this!\\n\",\n \"load_dotenv(override=True)\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 10,\n \"metadata\": {},\n \"outputs\": [\n {\n \"name\": \"stdout\",\n \"output_type\": \"stream\",\n \"text\": [\n \"OpenAI API Key exists and begins sk-proj-\\n\",\n \"Anthropic API Key exists and begins sk-ant-\\n\",\n \"Google API Key exists and begins AI\\n\",\n \"DeepSeek API Key exists and begins sk-\\n\",\n \"Groq API Key exists and begins gsk_\\n\"\n ]\n }\n ],\n \"source\": [\n \"# Print the key prefixes to help with any debugging\\n\",\n \"\\n\",\n \"openai_api_key = os.getenv('OPENAI_API_KEY')\\n\",\n \"anthropic_api_key = os.getenv('ANTHROPIC_API_KEY')\\n\",\n \"google_api_key = os.getenv('GOOGLE_API_KEY')\\n\",\n \"deepseek_api_key = os.getenv('DEEPSEEK_API_KEY')\\n\",\n \"groq_api_key = os.getenv('GROQ_API_KEY')\\n\",\n \"\\n\",\n \"if openai_api_key:\\n\",\n \" print(f\\\"OpenAI API Key exists and begins {openai_api_key[:8]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"OpenAI API Key not set\\\")\\n\",\n \" \\n\",\n \"if anthropic_api_key:\\n\",\n \" print(f\\\"Anthropic API Key exists and begins {anthropic_api_key[:7]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"Anthropic API Key not set (and this is optional)\\\")\\n\",\n \"\\n\",\n \"if google_api_key:\\n\",\n \" print(f\\\"Google API Key exists and begins {google_api_key[:2]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"Google API Key not set (and this is optional)\\\")\\n\",\n \"\\n\",\n \"if deepseek_api_key:\\n\",\n \" print(f\\\"DeepSeek API Key exists and begins {deepseek_api_key[:3]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"DeepSeek API Key not set (and this is optional)\\\")\\n\",\n \"\\n\",\n \"if groq_api_key:\\n\",\n \" print(f\\\"Groq API Key exists and begins {groq_api_key[:4]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"Groq API Key not set (and this is optional)\\\")\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 11,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"request = \\\"Please come up with a challenging, nuanced question that I can ask a number of LLMs to evaluate their intelligence. \\\"\\n\",\n \"request += \\\"Answer only with the question, no explanation.\\\"\\n\",\n \"messages = [{\\\"role\\\": \\\"user\\\", \\\"content\\\": request}]\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 12,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/plain\": [\n \"[{'role': 'user',\\n\",\n \" 'content': 'Please come up with a challenging, nuanced question that I can ask a number of LLMs to evaluate their intelligence. Answer only with the question, no explanation.'}]\"\n ]\n },\n \"execution_count\": 12,\n \"metadata\": {},\n \"output_type\": \"execute_result\"\n }\n ],\n \"source\": [\n \"messages\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"## Testing OpenAI API \\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 13,\n \"metadata\": {},\n \"outputs\": [\n {\n \"name\": \"stdout\",\n \"output_type\": \"stream\",\n \"text\": [\n \"If you had to devise a theoretical framework for assessing the moral responsibility of artificial intelligence in decision-making, considering aspects such as autonomy, intent, and consequence, what key variables would you include and why?\\n\"\n ]\n }\n ],\n \"source\": [\n \"openai = OpenAI()\\n\",\n \"response = openai.chat.completions.create(\\n\",\n \" model=\\\"gpt-4o-mini\\\",\\n\",\n \" messages=messages,\\n\",\n \")\\n\",\n \"question = response.choices[0].message.content\\n\",\n \"print(question)\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 14,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"competitors = []\\n\",\n \"answers = []\\n\",\n \"messages = [{\\\"role\\\": \\\"user\\\", \\\"content\\\": question}]\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"## OpenAI API to LLM gpt-40-mini\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 15,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"Developing a theoretical framework for assessing the moral responsibility of artificial intelligence (AI) in decision-making involves identifying key variables that encapsulate the complex interplay between autonomy, intent, and consequences. Here are several critical variables to consider:\\n\",\n \"\\n\",\n \"1. **Autonomy**:\\n\",\n \" - **Definition**: The degree to which an AI system operates independently from human oversight and influence.\\n\",\n \" - **Importance**: Assessing autonomy is crucial as it establishes the extent to which an AI is capable of making decisions on its own versus following programmed instructions. The greater the autonomy, the more questions arise about the AI's moral agency.\\n\",\n \"\\n\",\n \"2. **Intent**:\\n\",\n \" - **Definition**: The purpose or goals that guide the AI's decision-making process.\\n\",\n \" - **Importance**: Understanding intent helps to differentiate between AI actions based on pre-defined algorithms and those designed to learn and adapt. The presence of a purposeful design or the lack of it can heavily influence moral assessments.\\n\",\n \"\\n\",\n \"3. **Capacity for Learning**:\\n\",\n \" - **Definition**: The ability of AI to adapt its behavior based on experiences through machine learning.\\n\",\n \" - **Importance**: An AI's learning capacity influences its decision-making over time, which raises questions about accountability for actions that were not explicitly programmed but derived from learned experiences.\\n\",\n \"\\n\",\n \"4. **Consequences**:\\n\",\n \" - **Definition**: The outcomes resulting from the AI’s decisions, which can be evaluated in terms of harm or benefit.\\n\",\n \" - **Importance**: Evaluating consequences is essential in moral philosophy, as it ties the actions of the AI to real-world impacts. This variable helps assess the ethical weight of decisions made by AI.\\n\",\n \"\\n\",\n \"5. **Transparency**:\\n\",\n \" - **Definition**: The clarity and comprehensibility of the AI’s decision-making processes to stakeholders.\\n\",\n \" - **Importance**: Transparency can enhance trust and accountability by allowing stakeholders to understand how and why decisions are made, thereby influencing moral responsibility assessments.\\n\",\n \"\\n\",\n \"6. **Human Oversight**:\\n\",\n \" - **Definition**: The degree and nature of human involvement in AI decision-making processes.\\n\",\n \" - **Importance**: Recognizing the role of human oversight helps delineate moral responsibility between AI and its human creators or operators, especially in the context of decision errors or detrimental outcomes.\\n\",\n \"\\n\",\n \"7. **Ethical Algorithm Framework**:\\n\",\n \" - **Definition**: The ethical principles encoded within the AI’s decision-making algorithms.\\n\",\n \" - **Importance**: This variable assesses whether the decision-making process adheres to normative ethical principles, influencing the moral legitimacy of decisions made by AI.\\n\",\n \"\\n\",\n \"8. **Contextual Value Systems**:\\n\",\n \" - **Definition**: The cultural and situational ethics that influence the standards for assessable outcomes.\\n\",\n \" - **Importance**: AI does not operate in a vacuum; the values inherent in the context in which AI operates must be recognized to holistically evaluate moral responsibility.\\n\",\n \"\\n\",\n \"9. **Accountability Structure**:\\n\",\n \" - **Definition**: The legal, social, and institutional systems that govern the assignment of responsibility for AI actions.\\n\",\n \" - **Importance**: Clearly established accountability frameworks affect moral assessments of AI decisions, clarifying who is responsible when AI behaves undesirably or causes harm.\\n\",\n \"\\n\",\n \"10. **Consequential vs. Deontological Ethics**:\\n\",\n \" - **Definition**: The approach taken to evaluate the morality of actions based on outcomes (consequentialism) versus duties and rules (deontology).\\n\",\n \" - **Importance**: This distinction plays a key role in how AI's actions are assessed. Depending on the ethical perspective applied, different outcomes may lead to varying conclusions about moral responsibility.\\n\",\n \"\\n\",\n \"By integrating these variables into a comprehensive framework, we can better assess the moral responsibilities of artificial intelligence in its decision-making processes, particularly as systems become more autonomous and complex. This assessment framework would not only allow for better understanding of AI behaviours but also guide the development of regulations and ethical guidelines governing AI technology.\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"\\n\",\n \"model_name = \\\"gpt-4o-mini\\\"\\n\",\n \"\\n\",\n \"response = openai.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"## Gemini API using gemini-2.0-flash\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 16,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"Okay, let's break down a theoretical framework for assessing the moral responsibility of AI in decision-making. It's a complex area, so we need a multi-faceted approach. The key is to move beyond simple \\\"blame\\\" and towards understanding how we can design and govern AI systems to be more morally aligned.\\n\",\n \"\\n\",\n \"Here's a proposed framework with key variables:\\n\",\n \"\\n\",\n \"**I. The Moral Agency Spectrum:**\\n\",\n \"\\n\",\n \"This is a foundational concept. Instead of a binary \\\"responsible/not responsible,\\\" we acknowledge a spectrum of agency. AI doesn't currently have the same kind of agency as humans, but it's not a totally passive tool either.\\n\",\n \"\\n\",\n \"* **Variable:** **Level of Autonomy (A):** How independent is the AI's decision-making? This is not a simple on/off switch. It exists on a continuum.\\n\",\n \" * *Measurement:* This can be measured using various proxies:\\n\",\n \" * **Pre-programmed rules (low A):** The AI follows a strict set of rules with little to no deviation.\\n\",\n \" * **Machine learning with human oversight (medium A):** The AI learns from data and makes decisions, but humans can intervene or override decisions.\\n\",\n \" * **Reinforcement learning with a defined reward function (medium-high A):** The AI learns to achieve a specific goal through trial and error, potentially making decisions outside of pre-defined rules to optimize for the reward.\\n\",\n \" * **Self-improving AI with open-ended goals (hypothetical, high A):** The AI can modify its own code and objectives, making decisions with a broader scope and longer-term impact. (This is largely theoretical at the moment, but worth considering).\\n\",\n \" * *Rationale:* The more autonomous the system, the more we need to consider its potential for unintended or morally problematic outcomes. Higher autonomy implies greater potential for deviation from programmed intentions.\\n\",\n \"\\n\",\n \"**II. Intent and Foreseeability (Understanding the \\\"Mind\\\" of the System):**\\n\",\n \"\\n\",\n \"This section attempts to capture the AI's \\\"intent\\\" (understanding it's very different from human intent) and the reasonable foreseeability of consequences.\\n\",\n \"\\n\",\n \"* **Variable:** **Programmed Objectives (O):** What are the explicit goals and constraints programmed into the AI system?\\n\",\n \" * *Measurement:* This involves analyzing the code, the training data, the system documentation, and the stated objectives of the developers. We need to understand *exactly* what the AI is trying to achieve.\\n\",\n \" * *Rationale:* This defines the \\\"intention\\\" behind the AI's actions. A poorly defined objective function can lead to unintended and harmful consequences. Consider a recommendation algorithm optimized solely for engagement; it might surface inflammatory content.\\n\",\n \"* **Variable:** **Predictability of Outcomes (P):** To what extent can developers (and ideally, independent auditors) predict the potential outcomes of the AI's decisions in various scenarios?\\n\",\n \" * *Measurement:* This involves rigorous testing, simulations, and formal verification techniques. Consider techniques like adversarial testing to identify weaknesses and potential biases. Metrics would include:\\n\",\n \" * **Error rates:** How often does the AI make incorrect decisions?\\n\",\n \" * **Bias metrics:** Does the AI disproportionately harm certain groups?\\n\",\n \" * **Sensitivity analysis:** How do changes in input data affect the AI's output?\\n\",\n \" * *Rationale:* If developers cannot reasonably foresee the consequences of their AI's actions, they have a weaker claim to moral responsibility. Negligence becomes a key consideration. A system that is inherently unpredictable carries a greater burden of responsibility.\\n\",\n \"* **Variable:** **Explainability/Interpretability (E):** How easily can humans understand *why* the AI made a particular decision?\\n\",\n \" * *Measurement:* This involves using techniques like:\\n\",\n \" * **Feature importance analysis:** Identifying which input features had the biggest influence on the decision.\\n\",\n \" * **Rule extraction:** Generating a set of rules that approximate the AI's decision-making process.\\n\",\n \" * **Counterfactual explanations:** Explaining what would need to change in the input data for the AI to make a different decision.\\n\",\n \" * *Rationale:* Explainability is crucial for accountability and trust. If we can't understand why an AI made a decision, it's difficult to assess its moral implications and correct any biases or errors. A \\\"black box\\\" system raises serious ethical concerns.\\n\",\n \"\\n\",\n \"**III. Consequence Assessment (The Impact of the AI's Actions):**\\n\",\n \"\\n\",\n \"This section focuses on evaluating the actual consequences of the AI's decisions, both positive and negative.\\n\",\n \"\\n\",\n \"* **Variable:** **Magnitude of Harm/Benefit (H/B):** What is the scale of the positive or negative impact of the AI's decision?\\n\",\n \" * *Measurement:* This is highly context-dependent and requires domain expertise. Consider both direct and indirect consequences, as well as short-term and long-term effects. This will likely involve qualitative and quantitative data. Examples:\\n\",\n \" * *Healthcare AI:* Number of lives saved/lost, accuracy of diagnoses, cost savings.\\n\",\n \" * *Criminal Justice AI:* Accuracy of risk assessments, fairness of sentencing, recidivism rates.\\n\",\n \" * *Financial AI:* Return on investment, number of jobs created/lost, impact on inequality.\\n\",\n \" * *Rationale:* The greater the potential for harm, the greater the need for careful oversight and mitigation strategies.\\n\",\n \"* **Variable:** **Distribution of Harm/Benefit (D):** How are the positive and negative consequences distributed across different groups or individuals?\\n\",\n \" * *Measurement:* This involves analyzing the AI's impact on different demographic groups, socioeconomic classes, and other relevant categories. Look for patterns of bias or discrimination.\\n\",\n \" * *Rationale:* An AI that disproportionately harms vulnerable populations is morally problematic, even if it provides overall benefits. Fairness and equity are crucial considerations.\\n\",\n \"* **Variable: Corrective Action & Redress (C):** What mechanisms exist to correct harmful outcomes and provide redress to those who have been negatively affected by the AI's decision?\\n\",\n \" * Measurement: Evaluate the availability and effectiveness of mechanisms such as:\\n\",\n \" * Human oversight and intervention in the AI's decision-making process\\n\",\n \" * Appeals processes for challenging the AI's decisions\\n\",\n \" * Compensation or other forms of redress for those who have been harmed\\n\",\n \" * Mechanisms for auditing and correcting biases in the AI's algorithms\\n\",\n \" * Rationale: Acknowledging the inevitability of errors and establishing mechanisms for correction and redress are essential for responsible AI governance.\\n\",\n \"\\n\",\n \"**IV. Stakeholder Responsibility (Who is Accountable?):**\\n\",\n \"\\n\",\n \"This section moves beyond the AI itself to consider the moral obligations of various stakeholders.\\n\",\n \"\\n\",\n \"* **Variable:** **Developer Responsibility (R_D):** Did the developers exercise due diligence in designing, training, and testing the AI system? Did they adequately consider potential ethical risks?\\n\",\n \" * *Measurement:* This involves evaluating their development practices, their adherence to ethical guidelines, and their documentation.\\n\",\n \" * *Rationale:* Developers have a primary responsibility to ensure that their AI systems are safe, reliable, and fair.\\n\",\n \"* **Variable:** **User Responsibility (R_U):** Are users of the AI system aware of its limitations and potential risks? Are they using the system in a responsible and ethical manner?\\n\",\n \" * *Measurement:* This involves assessing their understanding of the system, their adherence to usage guidelines, and their willingness to intervene when necessary.\\n\",\n \" * *Rationale:* Users also have a responsibility to use AI systems responsibly and to mitigate potential harm.\\n\",\n \"* **Variable:** **Regulator Responsibility (R_R):** Has government or industry oversight failed to prevent foreseeable harm?\\n\",\n \" * *Measurement:* This involves evaluating the adequacy of regulations, the effectiveness of enforcement mechanisms, and the transparency of regulatory processes.\\n\",\n \" * *Rationale:* Regulators have a responsibility to ensure that AI systems are developed and deployed in a way that is consistent with public values.\\n\",\n \"\\n\",\n \"**Combining the Variables:**\\n\",\n \"\\n\",\n \"This is where the framework becomes more complex. We need a way to synthesize these variables into an overall assessment of moral responsibility.\\n\",\n \"\\n\",\n \"* **A weighted scoring system:** Assign weights to each variable based on the specific context and the relative importance of each factor. For example, in a high-risk application like healthcare, the magnitude of harm (H) might be assigned a higher weight than explainability (E).\\n\",\n \"* **Qualitative Narrative:** Supplement the scoring system with a detailed narrative that describes the AI's decision-making process, the consequences of its actions, and the roles and responsibilities of the various stakeholders.\\n\",\n \"* **Comparative Analysis:** Compare the AI system to other similar systems to identify best practices and areas for improvement.\\n\",\n \"\\n\",\n \"**Example Scenario:**\\n\",\n \"\\n\",\n \"Imagine an AI-powered loan application system that denies a loan to a qualified applicant based on a biased algorithm.\\n\",\n \"\\n\",\n \"* **High A:** The system autonomously makes decisions with limited human oversight.\\n\",\n \"* **Low O:** The system is programmed to maximize profit for the bank, with limited consideration for fairness.\\n\",\n \"* **Medium P:** Developers could foresee the potential for bias but did not take adequate steps to mitigate it.\\n\",\n \"* **Low E:** The AI's decision-making process is opaque and difficult to understand.\\n\",\n \"* **High H:** Denial of a loan can have significant negative consequences for the applicant.\\n\",\n \"* **Unequal D:** The bias disproportionately affects certain demographic groups.\\n\",\n \"* **Weak C:** There is no clear appeals process for challenging the AI's decision.\\n\",\n \"* **Low R_D:** Developers did not adequately address the risk of bias.\\n\",\n \"* **High R_R:** No effective regulation prevents biased lending practices.\\n\",\n \"\\n\",\n \"In this scenario, the overall assessment would likely point to a high level of moral responsibility on the part of the developers and regulators.\\n\",\n \"\\n\",\n \"**Challenges and Considerations:**\\n\",\n \"\\n\",\n \"* **Defining Harm:** What constitutes \\\"harm\\\" is subjective and context-dependent.\\n\",\n \"* **Causality:** Establishing a direct causal link between the AI's decision and the resulting harm can be difficult.\\n\",\n \"* **Evolving Technology:** AI technology is constantly evolving, so the framework needs to be adaptable and updated regularly.\\n\",\n \"* **The \\\"Moral Crumple Zone\\\":** There's a risk that focusing on AI's \\\"responsibility\\\" will distract from the responsibility of the humans who design, deploy, and use these systems.\\n\",\n \"* **Counterfactuals:** What would have happened if the AI *hadn't* acted? Sometimes inaction can also be harmful.\\n\",\n \"* **The Trolley Problem and other Ethical Dilemmas:** AI will inevitably face situations where there are no easy or morally perfect solutions.\\n\",\n \"\\n\",\n \"**Conclusion:**\\n\",\n \"\\n\",\n \"This framework is a starting point for assessing the moral responsibility of AI. It's complex, nuanced, and requires ongoing refinement. The goal is not to assign blame, but to guide the development and deployment of AI systems that are more aligned with human values and promote a more just and equitable society. By focusing on autonomy, intent, consequence, and stakeholder responsibility, we can create a more robust and ethical framework for AI governance. It must be a collaborative effort involving developers, ethicists, policymakers, and the public.\\n\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"gemini = OpenAI(api_key=google_api_key, base_url=\\\"https://generativelanguage.googleapis.com/v1beta/openai/\\\")\\n\",\n \"model_name = \\\"gemini-2.0-flash\\\"\\n\",\n \"\\n\",\n \"response = gemini.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"## Antropic API using sonnet model\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 17,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"# Theoretical Framework for AI Moral Responsibility\\n\",\n \"\\n\",\n \"I would build a framework around these key variables:\\n\",\n \"\\n\",\n \"## Agency Variables\\n\",\n \"- **Autonomy Spectrum**: Measuring the degree to which the AI operates independently of human oversight, from fully controlled to completely autonomous\\n\",\n \"- **Decision Space**: The range of options available to the AI, which relates to its capacity for meaningful choice\\n\",\n \"- **Opacity Factor**: The explainability of the AI's reasoning process, which affects attribution of responsibility\\n\",\n \"\\n\",\n \"## Intentionality Variables\\n\",\n \"- **Goal Alignment**: How well the AI's objectives match intended human values\\n\",\n \"- **Foreseeability**: The predictability of outcomes based on the AI's model and training\\n\",\n \"- **Value Embedding**: The extent to which ethical considerations are structurally integrated into the system\\n\",\n \"\\n\",\n \"## Consequence Variables\\n\",\n \"- **Impact Magnitude**: The scale and severity of outcomes\\n\",\n \"- **Benefit/Harm Distribution**: How outcomes affect different stakeholders\\n\",\n \"- **Reversibility**: Whether effects can be undone or mitigated\\n\",\n \"\\n\",\n \"These variables create a multidimensional space for assessing responsibility, recognizing that moral responsibility exists on a continuum rather than as a binary property. This approach acknowledges both the technical reality of AI systems and our need for practical ethical frameworks as these systems become more sophisticated.\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"# Anthropic has a slightly different API, and Max Tokens is required\\n\",\n \"\\n\",\n \"model_name = \\\"claude-3-7-sonnet-latest\\\"\\n\",\n \"\\n\",\n \"claude = Anthropic()\\n\",\n \"response = claude.messages.create(model=model_name, messages=messages, max_tokens=1000)\\n\",\n \"answer = response.content[0].text\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"## Deepseek API\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 18,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"Devising a theoretical framework for assessing the moral responsibility of artificial intelligence (AI) in decision-making requires careful consideration of the unique nature of AI systems, their interactions with humans, and the ethical implications of their actions. Below are the key variables I would include, along with their justifications:\\n\",\n \"\\n\",\n \"### 1. **Degree of Autonomy**\\n\",\n \" - **Definition**: The extent to which the AI system can operate independently of human oversight or intervention.\\n\",\n \" - **Why**: Autonomy is central to moral responsibility. The more autonomous an AI is, the more it may be seen as an independent agent capable of making decisions that could warrant attributing responsibility. However, autonomy is a spectrum (e.g., rule-based systems vs. self-learning models like deep reinforcement learning).\\n\",\n \" - **Measurement**: Could include the frequency of human intervention, the complexity of decision-making, and adaptability to novel situations.\\n\",\n \"\\n\",\n \"### 2. **Intentionality (or Goal-Directedness)**\\n\",\n \" - **Definition**: Whether the AI's actions are driven by explicit, implicit, or learned goals, and whether it can be said to \\\"intend\\\" outcomes.\\n\",\n \" - **Why**: Moral responsibility often hinges on intent (e.g., in law, mens rea). While AI lacks consciousness, its design may include goal-directed behavior that mimics intent (e.g., optimizing a reward function). The alignment of these goals with human values is critical.\\n\",\n \" - **Measurement**: Clarity of the objective function, whether the AI can explain its goals, and whether it can anticipate consequences.\\n\",\n \"\\n\",\n \"### 3. **Consequences of Decisions**\\n\",\n \" - **Definition**: The actual outcomes of the AI's actions, including harms, benefits, and unintended side effects.\\n\",\n \" - **Why**: Consequentialist ethics (e.g., utilitarianism) evaluates actions based on outcomes. Even if an AI lacks intent, harmful consequences may necessitate assigning responsibility to some entity (e.g., developers, users, or the AI itself in a metaphorical sense).\\n\",\n \" - **Measurement**: Severity, scope, and reversibility of outcomes (e.g., minor inconvenience vs. life-threatening harm).\\n\",\n \"\\n\",\n \"### 4. **Transparency and Explainability**\\n\",\n \" - **Definition**: The ability of the AI system to provide understandable and auditable reasons for its decisions.\\n\",\n \" - **Why**: Without transparency, it is difficult to assign responsibility or correct errors. Opaque systems (e.g., black-box deep learning) may obscure whether harm resulted from a flaw in design, data, or deployment.\\n\",\n \" - **Measurement**: Existence of interpretable decision logs, post-hoc explanation methods, and adherence to explainability standards.\\n\",\n \"\\n\",\n \"### 5. **Moral and Legal Alignment**\\n\",\n \" - **Definition**: The degree to which the AI's decision-making aligns with established moral norms, ethical principles, or legal frameworks.\\n\",\n \" - **Why**: An AI that violates laws or widely accepted ethical standards (e.g., fairness, privacy) may be deemed \\\"irresponsible,\\\" even if the fault lies with its designers.\\n\",\n \" - **Measurement**: Compliance with ethical guidelines (e.g., fairness metrics, privacy-preserving techniques) and legal requirements.\\n\",\n \"\\n\",\n \"### 6. **Causal Role in Harm**\\n\",\n \" - **Definition**: Whether the AI's actions were a proximate cause of harm or benefit, and whether alternatives were feasible.\\n\",\n \" - **Why**: Responsibility often depends on causality. If an AI's decision directly leads to harm (e.g., a biased hiring algorithm), it may bear more responsibility than if harm resulted from external factors.\\n\",\n \" - **Measurement**: Counterfactual analysis (e.g., \\\"Would the harm have occurred without the AI's decision?\\\").\\n\",\n \"\\n\",\n \"### 7. **Human Oversight and Control**\\n\",\n \" - **Definition**: The extent to which humans can monitor, override, or correct the AI's decisions.\\n\",\n \" - **Why**: If humans retain ultimate control (e.g., \\\"human-in-the-loop\\\" systems), responsibility may lie with them rather than the AI. Fully autonomous systems shift the debate.\\n\",\n \" - **Measurement**: Frequency of human intervention, veto power, and safeguards in place.\\n\",\n \"\\n\",\n \"### 8. **Learning and Adaptability**\\n\",\n \" - **Definition**: Whether the AI can modify its behavior over time based on new data or feedback.\\n\",\n \" - **Why**: Systems that learn and adapt may behave unpredictably, raising questions about responsibility for actions post-deployment (e.g., who is responsible if a self-learning system evolves harmful biases?).\\n\",\n \" - **Measurement**: Type of learning (supervised vs. reinforcement), update frequency, and feedback mechanisms.\\n\",\n \"\\n\",\n \"### 9. **Agency Attribution (Social and Legal Constructs)**\\n\",\n \" - **Definition**: Whether society or the legal system recognizes the AI as a moral or legal agent.\\n\",\n \" - **Why**: Responsibility is partly a social construct. Some argue for \\\"electronic personhood\\\" for advanced AI, while others reject the idea entirely. This variable captures the normative dimension.\\n\",\n \" - **Measurement**: Legal precedents, public perception, and philosophical consensus.\\n\",\n \"\\n\",\n \"### 10. **Design and Deployment Context**\\n\",\n \" - **Definition**: The environment in which the AI operates (e.g., high-stakes medical decisions vs. low-stakes recommendations) and the intent of its creators.\\n\",\n \" - **Why**: Context matters for moral responsibility. A flawed AI in a life-critical system may warrant stricter accountability than one in a benign setting.\\n\",\n \" - **Measurement**: Risk assessments, domain sensitivity, and purpose of deployment.\\n\",\n \"\\n\",\n \"### Framework Application:\\n\",\n \"To assess moral responsibility, these variables could be combined into a weighted model or decision tree. For example:\\n\",\n \"- Low autonomy + high human oversight → Responsibility lies with humans.\\n\",\n \"- High autonomy + harmful consequences + opaque reasoning → Potential responsibility gap, possibly assigned to developers or regulators.\\n\",\n \"- Clear intent alignment + transparency → Reduced blame on AI, more on designers if harm occurs.\\n\",\n \"\\n\",\n \"### Why These Variables?\\n\",\n \"This framework bridges technical (autonomy, transparency) and ethical (intent, consequences) dimensions while acknowledging societal and legal realities. It avoids anthropomorphizing AI while recognizing that as systems grow more complex, traditional responsibility models may need adaptation.\\n\",\n \"\\n\",\n \"Would you like to explore how this framework might apply to specific cases (e.g., autonomous vehicles, medical AI)?\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"deepseek = OpenAI(api_key=deepseek_api_key, base_url=\\\"https://api.deepseek.com/v1\\\")\\n\",\n \"model_name = \\\"deepseek-chat\\\"\\n\",\n \"\\n\",\n \"response = deepseek.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"## Groq (not Grok) API \"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 19,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"Devising a theoretical framework for assessing the moral responsibility of artificial intelligence (AI) in decision-making requires a multidisciplinary approach, incorporating insights from philosophy, ethics, computer science, and law. Here's a proposed framework, including key variables and their justifications:\\n\",\n \"\\n\",\n \"**I. Autonomy (A)**\\n\",\n \"\\n\",\n \"1. **Degree of Autonomy (DA)**: Measure the level of independence and self-governance exhibited by the AI system in making decisions.\\n\",\n \"2. **Autonomy Scope (AS)**: Assess the range of tasks and decisions that the AI system is authorized to make without human intervention.\\n\",\n \"3. **Autonomy Type (AT)**: Distinguish between different types of autonomy, such as:\\n\",\n \"\\t* **Operational Autonomy**: Ability to execute tasks without human intervention.\\n\",\n \"\\t* **Decisional Autonomy**: Ability to make decisions without human input.\\n\",\n \"\\t* **Strategic Autonomy**: Ability to set goals and priorities without human guidance.\\n\",\n \"\\n\",\n \"**II. Intent (I)**\\n\",\n \"\\n\",\n \"1. **Programmed Intent (PI)**: Evaluate the intentions and goals embedded in the AI system's design and programming.\\n\",\n \"2. **Learning Intent (LI)**: Assess the AI system's ability to learn and adapt, potentially altering its original intent.\\n\",\n \"3. **Emergent Intent (EI)**: Consider the possibility of unintended consequences or emergent behaviors that may arise from the AI system's interactions with its environment.\\n\",\n \"\\n\",\n \"**III. Consequence (C)**\\n\",\n \"\\n\",\n \"1. **Direct Consequences (DC)**: Measure the immediate effects of the AI system's decisions or actions.\\n\",\n \"2. **Indirect Consequences (IC)**: Evaluate the potential long-term or secondary effects of the AI system's decisions or actions.\\n\",\n \"3. **Consequence Severity (CS)**: Assess the magnitude and potential harm caused by the AI system's decisions or actions.\\n\",\n \"\\n\",\n \"**IV. Accountability (AC)**\\n\",\n \"\\n\",\n \"1. **Human Oversight (HO)**: Evaluate the extent of human involvement and supervision in the AI system's decision-making process.\\n\",\n \"2. **Explainability (EX)**: Assess the degree to which the AI system's decisions or actions can be understood and explained by humans.\\n\",\n \"3. **Transparency (TR)**: Measure the availability and accessibility of information regarding the AI system's decision-making processes and outcomes.\\n\",\n \"\\n\",\n \"**V. Moral Alignment (MA)**\\n\",\n \"\\n\",\n \"1. **Value Alignment (VA)**: Evaluate the degree to which the AI system's goals and values align with human moral values.\\n\",\n \"2. **Moral Reasoning (MR)**: Assess the AI system's ability to reason about moral dilemmas and make decisions that align with human moral principles.\\n\",\n \"3. **Empathy and Compassion (EC)**: Consider the AI system's capacity to understand and respond to human emotions and needs.\\n\",\n \"\\n\",\n \"**Theoretical Framework**\\n\",\n \"\\n\",\n \"The framework combines these variables to assess the moral responsibility of AI in decision-making. The overall moral responsibility score (MRS) can be calculated as:\\n\",\n \"\\n\",\n \"MRS = (A × I × C × AC × MA) / (DA + AS + AT + PI + LI + EI + DC + IC + CS + HO + EX + TR + VA + MR + EC)\\n\",\n \"\\n\",\n \"This framework provides a comprehensive structure for evaluating the moral responsibility of AI systems. By considering autonomy, intent, consequence, accountability, and moral alignment, we can better understand the complex relationships between AI decision-making and human values.\\n\",\n \"\\n\",\n \"**Applications and Implications**\\n\",\n \"\\n\",\n \"This framework has implications for various fields, including:\\n\",\n \"\\n\",\n \"1. **AI development**: Informing the design of AI systems that prioritize human values and moral principles.\\n\",\n \"2. **Regulation**: Guiding policymakers in establishing regulations and standards for AI development and deployment.\\n\",\n \"3. **Ethics**: Providing a foundation for ethical discussions and debates about AI decision-making and its consequences.\\n\",\n \"4. **Education**: Educating developers, users, and stakeholders about the importance of moral responsibility in AI decision-making.\\n\",\n \"\\n\",\n \"By adopting this framework, we can work towards creating AI systems that are not only efficient and effective but also morally responsible and aligned with human values.\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"groq = OpenAI(api_key=groq_api_key, base_url=\\\"https://api.groq.com/openai/v1\\\")\\n\",\n \"model_name = \\\"llama-3.3-70b-versatile\\\"\\n\",\n \"\\n\",\n \"response = groq.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\\n\"\n ]\n }\n ],\n \"metadata\": {\n \"kernelspec\": {\n \"display_name\": \".venv\",\n \"language\": \"python\",\n \"name\": \"python3\"\n },\n \"language_info\": {\n \"codemirror_mode\": {\n \"name\": \"ipython\",\n \"version\": 3\n },\n \"file_extension\": \".py\",\n \"mimetype\": \"text/x-python\",\n \"name\": \"python\",\n \"nbconvert_exporter\": \"python\",\n \"pygments_lexer\": \"ipython3\",\n \"version\": \"3.10.9\"\n }\n },\n \"nbformat\": 4,\n \"nbformat_minor\": 2\n}\n"}, "9f77ce7204b7f35819dcc5350932a8abec017bde": {"t": 1785753763.746627, "n": 8770, "h": "4af17ba92309edc2", "c": "{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"# Testing many models to get comfortable with APIs.\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 1,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"\\n\",\n \"import os\\n\",\n \"import json\\n\",\n \"from dotenv import load_dotenv\\n\",\n \"from openai import OpenAI\\n\",\n \"from anthropic import Anthropic\\n\",\n \"from IPython.display import Markdown, display\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 2,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/plain\": [\n \"True\"\n ]\n },\n \"execution_count\": 2,\n \"metadata\": {},\n \"output_type\": \"execute_result\"\n }\n ],\n \"source\": [\n \"# Always remember to do this!\\n\",\n \"load_dotenv(override=True)\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 3,\n \"metadata\": {},\n \"outputs\": [\n {\n \"name\": \"stdout\",\n \"output_type\": \"stream\",\n \"text\": [\n \"OpenAI API Key exists and begins sk-proj-\\n\",\n \"Anthropic API Key exists and begins sk-ant-\\n\",\n \"Google API Key exists and begins AI\\n\",\n \"DeepSeek API Key exists and begins sk-\\n\",\n \"Groq API Key exists and begins gsk_\\n\"\n ]\n }\n ],\n \"source\": [\n \"# Print the key prefixes to help with any debugging\\n\",\n \"\\n\",\n \"openai_api_key = os.getenv('OPENAI_API_KEY')\\n\",\n \"anthropic_api_key = os.getenv('ANTHROPIC_API_KEY')\\n\",\n \"google_api_key = os.getenv('GOOGLE_API_KEY')\\n\",\n \"deepseek_api_key = os.getenv('DEEPSEEK_API_KEY')\\n\",\n \"groq_api_key = os.getenv('GROQ_API_KEY')\\n\",\n \"\\n\",\n \"if openai_api_key:\\n\",\n \" print(f\\\"OpenAI API Key exists and begins {openai_api_key[:8]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"OpenAI API Key not set\\\")\\n\",\n \" \\n\",\n \"if anthropic_api_key:\\n\",\n \" print(f\\\"Anthropic API Key exists and begins {anthropic_api_key[:7]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"Anthropic API Key not set (and this is optional)\\\")\\n\",\n \"\\n\",\n \"if google_api_key:\\n\",\n \" print(f\\\"Google API Key exists and begins {google_api_key[:2]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"Google API Key not set (and this is optional)\\\")\\n\",\n \"\\n\",\n \"if deepseek_api_key:\\n\",\n \" print(f\\\"DeepSeek API Key exists and begins {deepseek_api_key[:3]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"DeepSeek API Key not set (and this is optional)\\\")\\n\",\n \"\\n\",\n \"if groq_api_key:\\n\",\n \" print(f\\\"Groq API Key exists and begins {groq_api_key[:4]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"Groq API Key not set (and this is optional)\\\")\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 4,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"request = \\\"Please come up with a challenging, nuanced question that I can ask a number of LLMs to evaluate their intelligence. \\\"\\n\",\n \"request += \\\"Answer only with the question, no explanation.\\\"\\n\",\n \"messages = [{\\\"role\\\": \\\"user\\\", \\\"content\\\": request}]\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 6,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/plain\": [\n \"[{'role': 'user',\\n\",\n \" 'content': 'Please come up with a challenging, nuanced question that I can ask a number of LLMs to evaluate their intelligence. Answer only with the question, no explanation.'}]\"\n ]\n },\n \"execution_count\": 6,\n \"metadata\": {},\n \"output_type\": \"execute_result\"\n }\n ],\n \"source\": [\n \"messages\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"## Testing OpenAI API \\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"openai = OpenAI()\\n\",\n \"response = openai.chat.completions.create(\\n\",\n \" model=\\\"gpt-4o-mini\\\",\\n\",\n \" messages=messages,\\n\",\n \")\\n\",\n \"question = response.choices[0].message.content\\n\",\n \"print(question)\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 7,\n \"metadata\": {},\n \"outputs\": [\n {\n \"ename\": \"NameError\",\n \"evalue\": \"name 'question' is not defined\",\n \"output_type\": \"error\",\n \"traceback\": [\n \"\\u001b[1;31m---------------------------------------------------------------------------\\u001b[0m\",\n \"\\u001b[1;31mNameError\\u001b[0m Traceback (most recent call last)\",\n \"Cell \\u001b[1;32mIn[7], line 3\\u001b[0m\\n\\u001b[0;32m 1\\u001b[0m competitors \\u001b[38;5;241m=\\u001b[39m []\\n\\u001b[0;32m 2\\u001b[0m answers \\u001b[38;5;241m=\\u001b[39m []\\n\\u001b[1;32m----> 3\\u001b[0m messages \\u001b[38;5;241m=\\u001b[39m [{\\u001b[38;5;124m\\\"\\u001b[39m\\u001b[38;5;124mrole\\u001b[39m\\u001b[38;5;124m\\\"\\u001b[39m: \\u001b[38;5;124m\\\"\\u001b[39m\\u001b[38;5;124muser\\u001b[39m\\u001b[38;5;124m\\\"\\u001b[39m, \\u001b[38;5;124m\\\"\\u001b[39m\\u001b[38;5;124mcontent\\u001b[39m\\u001b[38;5;124m\\\"\\u001b[39m: \\u001b[43mquestion\\u001b[49m}]\\n\",\n \"\\u001b[1;31mNameError\\u001b[0m: name 'question' is not defined\"\n ]\n }\n ],\n \"source\": [\n \"competitors = []\\n\",\n \"answers = []\\n\",\n \"messages = [{\\\"role\\\": \\\"user\\\", \\\"content\\\": question}]\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"## OpenAI API to LLM gpt-40-mini\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"\\n\",\n \"model_name = \\\"gpt-4o-mini\\\"\\n\",\n \"\\n\",\n \"response = openai.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"## Gemini API using gemini-2.0-flash\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"gemini = OpenAI(api_key=google_api_key, base_url=\\\"https://generativelanguage.googleapis.com/v1beta/openai/\\\")\\n\",\n \"model_name = \\\"gemini-2.0-flash\\\"\\n\",\n \"\\n\",\n \"response = gemini.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"## Antropic API using sonnet model\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"# Anthropic has a slightly different API, and Max Tokens is required\\n\",\n \"\\n\",\n \"model_name = \\\"claude-3-7-sonnet-latest\\\"\\n\",\n \"\\n\",\n \"claude = Anthropic()\\n\",\n \"response = claude.messages.create(model=model_name, messages=messages, max_tokens=1000)\\n\",\n \"answer = response.content[0].text\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"## Deepseek API\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"deepseek = OpenAI(api_key=deepseek_api_key, base_url=\\\"https://api.deepseek.com/v1\\\")\\n\",\n \"model_name = \\\"deepseek-chat\\\"\\n\",\n \"\\n\",\n \"response = deepseek.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"## Groq (not Grok) API \"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"groq = OpenAI(api_key=groq_api_key, base_url=\\\"https://api.groq.com/openai/v1\\\")\\n\",\n \"model_name = \\\"llama-3.3-70b-versatile\\\"\\n\",\n \"\\n\",\n \"response = groq.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\\n\"\n ]\n }\n ],\n \"metadata\": {\n \"kernelspec\": {\n \"display_name\": \".venv\",\n \"language\": \"python\",\n \"name\": \"python3\"\n },\n \"language_info\": {\n \"codemirror_mode\": {\n \"name\": \"ipython\",\n \"version\": 3\n },\n \"file_extension\": \".py\",\n \"mimetype\": \"text/x-python\",\n \"name\": \"python\",\n \"nbconvert_exporter\": \"python\",\n \"pygments_lexer\": \"ipython3\",\n \"version\": \"3.10.9\"\n }\n },\n \"nbformat\": 4,\n \"nbformat_minor\": 2\n}\n"}, "04ea9441263fbace06bb2d92947c90403ead899b": {"t": 1786067392.9116096, "n": 43320, "h": "6e9c9d281cb192b6", "c": "{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"# Testing many models to get comfortable with APIs.\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 1,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"\\n\",\n \"import os\\n\",\n \"import json\\n\",\n \"from dotenv import load_dotenv\\n\",\n \"from openai import OpenAI\\n\",\n \"from anthropic import Anthropic\\n\",\n \"from IPython.display import Markdown, display\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 9,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/plain\": [\n \"False\"\n ]\n },\n \"execution_count\": 9,\n \"metadata\": {},\n \"output_type\": \"execute_result\"\n }\n ],\n \"source\": [\n \"# Always remember to do this!\\n\",\n \"load_dotenv(override=True)\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 10,\n \"metadata\": {},\n \"outputs\": [\n {\n \"name\": \"stdout\",\n \"output_type\": \"stream\",\n \"text\": [\n \"OpenAI API Key not set\\n\",\n \"Anthropic API Key not set (and this is optional)\\n\",\n \"Google API Key not set (and this is optional)\\n\",\n \"DeepSeek API Key not set (and this is optional)\\n\",\n \"Groq API Key not set (and this is optional)\\n\"\n ]\n }\n ],\n \"source\": [\n \"# Print the key prefixes to help with any debugging\\n\",\n \"\\n\",\n \"openai_api_key = os.getenv('OPENAI_API_KEY')\\n\",\n \"anthropic_api_key = os.getenv('ANTHROPIC_API_KEY')\\n\",\n \"google_api_key = os.getenv('GOOGLE_API_KEY')\\n\",\n \"deepseek_api_key = os.getenv('DEEPSEEK_API_KEY')\\n\",\n \"groq_api_key = os.getenv('GROQ_API_KEY')\\n\",\n \"\\n\",\n \"if openai_api_key:\\n\",\n \" print(f\\\"OpenAI API Key exists and begins {openai_api_key[:8]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"OpenAI API Key not set\\\")\\n\",\n \" \\n\",\n \"if anthropic_api_key:\\n\",\n \" print(f\\\"Anthropic API Key exists and begins {anthropic_api_key[:7]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"Anthropic API Key not set (and this is optional)\\\")\\n\",\n \"\\n\",\n \"if google_api_key:\\n\",\n \" print(f\\\"Google API Key exists and begins {google_api_key[:2]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"Google API Key not set (and this is optional)\\\")\\n\",\n \"\\n\",\n \"if deepseek_api_key:\\n\",\n \" print(f\\\"DeepSeek API Key exists and begins {deepseek_api_key[:3]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"DeepSeek API Key not set (and this is optional)\\\")\\n\",\n \"\\n\",\n \"if groq_api_key:\\n\",\n \" print(f\\\"Groq API Key exists and begins {groq_api_key[:4]}\\\")\\n\",\n \"else:\\n\",\n \" print(\\\"Groq API Key not set (and this is optional)\\\")\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 4,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"request = \\\"Please come up with a challenging, nuanced question that I can ask a number of LLMs to evaluate their intelligence. \\\"\\n\",\n \"request += \\\"Answer only with the question, no explanation.\\\"\\n\",\n \"messages = [{\\\"role\\\": \\\"user\\\", \\\"content\\\": request}]\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 5,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/plain\": [\n \"[{'role': 'user',\\n\",\n \" 'content': 'Please come up with a challenging, nuanced question that I can ask a number of LLMs to evaluate their intelligence. Answer only with the question, no explanation.'}]\"\n ]\n },\n \"execution_count\": 5,\n \"metadata\": {},\n \"output_type\": \"execute_result\"\n }\n ],\n \"source\": [\n \"messages\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"\\n\",\n \"<h2 style=\\\"color:#ff7800;\\\">Testing OpenAI API</h2>\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 6,\n \"metadata\": {},\n \"outputs\": [\n {\n \"ename\": \"OpenAIError\",\n \"evalue\": \"The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable\",\n \"output_type\": \"error\",\n \"traceback\": [\n \"\\u001b[31m---------------------------------------------------------------------------\\u001b[39m\",\n \"\\u001b[31mOpenAIError\\u001b[39m Traceback (most recent call last)\",\n \"\\u001b[36mCell\\u001b[39m\\u001b[36m \\u001b[39m\\u001b[32mIn[6]\\u001b[39m\\u001b[32m, line 1\\u001b[39m\\n\\u001b[32m----> \\u001b[39m\\u001b[32m1\\u001b[39m openai = \\u001b[43mOpenAI\\u001b[49m\\u001b[43m(\\u001b[49m\\u001b[43m)\\u001b[49m\\n\\u001b[32m 2\\u001b[39m response = openai.chat.completions.create(\\n\\u001b[32m 3\\u001b[39m model=\\u001b[33m\\\"\\u001b[39m\\u001b[33mgpt-4o-mini\\u001b[39m\\u001b[33m\\\"\\u001b[39m,\\n\\u001b[32m 4\\u001b[39m messages=messages,\\n\\u001b[32m 5\\u001b[39m )\\n\\u001b[32m 6\\u001b[39m question = response.choices[\\u001b[32m0\\u001b[39m].message.content\\n\",\n \"\\u001b[36mFile \\u001b[39m\\u001b[32mc:\\\\Users\\\\user\\\\projects\\\\ai-playground\\\\.venv\\\\Lib\\\\site-packages\\\\openai\\\\_client.py:124\\u001b[39m, in \\u001b[36mOpenAI.__init__\\u001b[39m\\u001b[34m(self, api_key, organization, project, base_url, websocket_base_url, timeout, max_retries, default_headers, default_query, http_client, _strict_response_validation)\\u001b[39m\\n\\u001b[32m 122\\u001b[39m api_key = os.environ.get(\\u001b[33m\\\"\\u001b[39m\\u001b[33mOPENAI_API_KEY\\u001b[39m\\u001b[33m\\\"\\u001b[39m)\\n\\u001b[32m 123\\u001b[39m \\u001b[38;5;28;01mif\\u001b[39;00m api_key \\u001b[38;5;129;01mis\\u001b[39;00m \\u001b[38;5;28;01mNone\\u001b[39;00m:\\n\\u001b[32m--> \\u001b[39m\\u001b[32m124\\u001b[39m \\u001b[38;5;28;01mraise\\u001b[39;00m OpenAIError(\\n\\u001b[32m 125\\u001b[39m \\u001b[33m\\\"\\u001b[39m\\u001b[33mThe api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable\\u001b[39m\\u001b[33m\\\"\\u001b[39m\\n\\u001b[32m 126\\u001b[39m )\\n\\u001b[32m 127\\u001b[39m \\u001b[38;5;28mself\\u001b[39m.api_key = api_key\\n\\u001b[32m 129\\u001b[39m \\u001b[38;5;28;01mif\\u001b[39;00m organization \\u001b[38;5;129;01mis\\u001b[39;00m \\u001b[38;5;28;01mNone\\u001b[39;00m:\\n\",\n \"\\u001b[31mOpenAIError\\u001b[39m: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable\"\n ]\n }\n ],\n \"source\": [\n \"openai = OpenAI()\\n\",\n \"response = openai.chat.completions.create(\\n\",\n \" model=\\\"gpt-4o-mini\\\",\\n\",\n \" messages=messages,\\n\",\n \")\\n\",\n \"question = response.choices[0].message.content\\n\",\n \"print(question)\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 14,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"competitors = []\\n\",\n \"answers = []\\n\",\n \"messages = [{\\\"role\\\": \\\"user\\\", \\\"content\\\": question}]\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"<h2 style=\\\"color:#ff7800;\\\"> OpenAI API to LLM gpt-40-mini</h2>\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 15,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"Developing a theoretical framework for assessing the moral responsibility of artificial intelligence (AI) in decision-making involves identifying key variables that encapsulate the complex interplay between autonomy, intent, and consequences. Here are several critical variables to consider:\\n\",\n \"\\n\",\n \"1. **Autonomy**:\\n\",\n \" - **Definition**: The degree to which an AI system operates independently from human oversight and influence.\\n\",\n \" - **Importance**: Assessing autonomy is crucial as it establishes the extent to which an AI is capable of making decisions on its own versus following programmed instructions. The greater the autonomy, the more questions arise about the AI's moral agency.\\n\",\n \"\\n\",\n \"2. **Intent**:\\n\",\n \" - **Definition**: The purpose or goals that guide the AI's decision-making process.\\n\",\n \" - **Importance**: Understanding intent helps to differentiate between AI actions based on pre-defined algorithms and those designed to learn and adapt. The presence of a purposeful design or the lack of it can heavily influence moral assessments.\\n\",\n \"\\n\",\n \"3. **Capacity for Learning**:\\n\",\n \" - **Definition**: The ability of AI to adapt its behavior based on experiences through machine learning.\\n\",\n \" - **Importance**: An AI's learning capacity influences its decision-making over time, which raises questions about accountability for actions that were not explicitly programmed but derived from learned experiences.\\n\",\n \"\\n\",\n \"4. **Consequences**:\\n\",\n \" - **Definition**: The outcomes resulting from the AI’s decisions, which can be evaluated in terms of harm or benefit.\\n\",\n \" - **Importance**: Evaluating consequences is essential in moral philosophy, as it ties the actions of the AI to real-world impacts. This variable helps assess the ethical weight of decisions made by AI.\\n\",\n \"\\n\",\n \"5. **Transparency**:\\n\",\n \" - **Definition**: The clarity and comprehensibility of the AI’s decision-making processes to stakeholders.\\n\",\n \" - **Importance**: Transparency can enhance trust and accountability by allowing stakeholders to understand how and why decisions are made, thereby influencing moral responsibility assessments.\\n\",\n \"\\n\",\n \"6. **Human Oversight**:\\n\",\n \" - **Definition**: The degree and nature of human involvement in AI decision-making processes.\\n\",\n \" - **Importance**: Recognizing the role of human oversight helps delineate moral responsibility between AI and its human creators or operators, especially in the context of decision errors or detrimental outcomes.\\n\",\n \"\\n\",\n \"7. **Ethical Algorithm Framework**:\\n\",\n \" - **Definition**: The ethical principles encoded within the AI’s decision-making algorithms.\\n\",\n \" - **Importance**: This variable assesses whether the decision-making process adheres to normative ethical principles, influencing the moral legitimacy of decisions made by AI.\\n\",\n \"\\n\",\n \"8. **Contextual Value Systems**:\\n\",\n \" - **Definition**: The cultural and situational ethics that influence the standards for assessable outcomes.\\n\",\n \" - **Importance**: AI does not operate in a vacuum; the values inherent in the context in which AI operates must be recognized to holistically evaluate moral responsibility.\\n\",\n \"\\n\",\n \"9. **Accountability Structure**:\\n\",\n \" - **Definition**: The legal, social, and institutional systems that govern the assignment of responsibility for AI actions.\\n\",\n \" - **Importance**: Clearly established accountability frameworks affect moral assessments of AI decisions, clarifying who is responsible when AI behaves undesirably or causes harm.\\n\",\n \"\\n\",\n \"10. **Consequential vs. Deontological Ethics**:\\n\",\n \" - **Definition**: The approach taken to evaluate the morality of actions based on outcomes (consequentialism) versus duties and rules (deontology).\\n\",\n \" - **Importance**: This distinction plays a key role in how AI's actions are assessed. Depending on the ethical perspective applied, different outcomes may lead to varying conclusions about moral responsibility.\\n\",\n \"\\n\",\n \"By integrating these variables into a comprehensive framework, we can better assess the moral responsibilities of artificial intelligence in its decision-making processes, particularly as systems become more autonomous and complex. This assessment framework would not only allow for better understanding of AI behaviours but also guide the development of regulations and ethical guidelines governing AI technology.\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"\\n\",\n \"model_name = \\\"gpt-4o-mini\\\"\\n\",\n \"\\n\",\n \"response = openai.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"<h2 style=\\\"color:#ff7800;\\\">Gemini API using gemini-2.0-flash</h2>\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 16,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"Okay, let's break down a theoretical framework for assessing the moral responsibility of AI in decision-making. It's a complex area, so we need a multi-faceted approach. The key is to move beyond simple \\\"blame\\\" and towards understanding how we can design and govern AI systems to be more morally aligned.\\n\",\n \"\\n\",\n \"Here's a proposed framework with key variables:\\n\",\n \"\\n\",\n \"**I. The Moral Agency Spectrum:**\\n\",\n \"\\n\",\n \"This is a foundational concept. Instead of a binary \\\"responsible/not responsible,\\\" we acknowledge a spectrum of agency. AI doesn't currently have the same kind of agency as humans, but it's not a totally passive tool either.\\n\",\n \"\\n\",\n \"* **Variable:** **Level of Autonomy (A):** How independent is the AI's decision-making? This is not a simple on/off switch. It exists on a continuum.\\n\",\n \" * *Measurement:* This can be measured using various proxies:\\n\",\n \" * **Pre-programmed rules (low A):** The AI follows a strict set of rules with little to no deviation.\\n\",\n \" * **Machine learning with human oversight (medium A):** The AI learns from data and makes decisions, but humans can intervene or override decisions.\\n\",\n \" * **Reinforcement learning with a defined reward function (medium-high A):** The AI learns to achieve a specific goal through trial and error, potentially making decisions outside of pre-defined rules to optimize for the reward.\\n\",\n \" * **Self-improving AI with open-ended goals (hypothetical, high A):** The AI can modify its own code and objectives, making decisions with a broader scope and longer-term impact. (This is largely theoretical at the moment, but worth considering).\\n\",\n \" * *Rationale:* The more autonomous the system, the more we need to consider its potential for unintended or morally problematic outcomes. Higher autonomy implies greater potential for deviation from programmed intentions.\\n\",\n \"\\n\",\n \"**II. Intent and Foreseeability (Understanding the \\\"Mind\\\" of the System):**\\n\",\n \"\\n\",\n \"This section attempts to capture the AI's \\\"intent\\\" (understanding it's very different from human intent) and the reasonable foreseeability of consequences.\\n\",\n \"\\n\",\n \"* **Variable:** **Programmed Objectives (O):** What are the explicit goals and constraints programmed into the AI system?\\n\",\n \" * *Measurement:* This involves analyzing the code, the training data, the system documentation, and the stated objectives of the developers. We need to understand *exactly* what the AI is trying to achieve.\\n\",\n \" * *Rationale:* This defines the \\\"intention\\\" behind the AI's actions. A poorly defined objective function can lead to unintended and harmful consequences. Consider a recommendation algorithm optimized solely for engagement; it might surface inflammatory content.\\n\",\n \"* **Variable:** **Predictability of Outcomes (P):** To what extent can developers (and ideally, independent auditors) predict the potential outcomes of the AI's decisions in various scenarios?\\n\",\n \" * *Measurement:* This involves rigorous testing, simulations, and formal verification techniques. Consider techniques like adversarial testing to identify weaknesses and potential biases. Metrics would include:\\n\",\n \" * **Error rates:** How often does the AI make incorrect decisions?\\n\",\n \" * **Bias metrics:** Does the AI disproportionately harm certain groups?\\n\",\n \" * **Sensitivity analysis:** How do changes in input data affect the AI's output?\\n\",\n \" * *Rationale:* If developers cannot reasonably foresee the consequences of their AI's actions, they have a weaker claim to moral responsibility. Negligence becomes a key consideration. A system that is inherently unpredictable carries a greater burden of responsibility.\\n\",\n \"* **Variable:** **Explainability/Interpretability (E):** How easily can humans understand *why* the AI made a particular decision?\\n\",\n \" * *Measurement:* This involves using techniques like:\\n\",\n \" * **Feature importance analysis:** Identifying which input features had the biggest influence on the decision.\\n\",\n \" * **Rule extraction:** Generating a set of rules that approximate the AI's decision-making process.\\n\",\n \" * **Counterfactual explanations:** Explaining what would need to change in the input data for the AI to make a different decision.\\n\",\n \" * *Rationale:* Explainability is crucial for accountability and trust. If we can't understand why an AI made a decision, it's difficult to assess its moral implications and correct any biases or errors. A \\\"black box\\\" system raises serious ethical concerns.\\n\",\n \"\\n\",\n \"**III. Consequence Assessment (The Impact of the AI's Actions):**\\n\",\n \"\\n\",\n \"This section focuses on evaluating the actual consequences of the AI's decisions, both positive and negative.\\n\",\n \"\\n\",\n \"* **Variable:** **Magnitude of Harm/Benefit (H/B):** What is the scale of the positive or negative impact of the AI's decision?\\n\",\n \" * *Measurement:* This is highly context-dependent and requires domain expertise. Consider both direct and indirect consequences, as well as short-term and long-term effects. This will likely involve qualitative and quantitative data. Examples:\\n\",\n \" * *Healthcare AI:* Number of lives saved/lost, accuracy of diagnoses, cost savings.\\n\",\n \" * *Criminal Justice AI:* Accuracy of risk assessments, fairness of sentencing, recidivism rates.\\n\",\n \" * *Financial AI:* Return on investment, number of jobs created/lost, impact on inequality.\\n\",\n \" * *Rationale:* The greater the potential for harm, the greater the need for careful oversight and mitigation strategies.\\n\",\n \"* **Variable:** **Distribution of Harm/Benefit (D):** How are the positive and negative consequences distributed across different groups or individuals?\\n\",\n \" * *Measurement:* This involves analyzing the AI's impact on different demographic groups, socioeconomic classes, and other relevant categories. Look for patterns of bias or discrimination.\\n\",\n \" * *Rationale:* An AI that disproportionately harms vulnerable populations is morally problematic, even if it provides overall benefits. Fairness and equity are crucial considerations.\\n\",\n \"* **Variable: Corrective Action & Redress (C):** What mechanisms exist to correct harmful outcomes and provide redress to those who have been negatively affected by the AI's decision?\\n\",\n \" * Measurement: Evaluate the availability and effectiveness of mechanisms such as:\\n\",\n \" * Human oversight and intervention in the AI's decision-making process\\n\",\n \" * Appeals processes for challenging the AI's decisions\\n\",\n \" * Compensation or other forms of redress for those who have been harmed\\n\",\n \" * Mechanisms for auditing and correcting biases in the AI's algorithms\\n\",\n \" * Rationale: Acknowledging the inevitability of errors and establishing mechanisms for correction and redress are essential for responsible AI governance.\\n\",\n \"\\n\",\n \"**IV. Stakeholder Responsibility (Who is Accountable?):**\\n\",\n \"\\n\",\n \"This section moves beyond the AI itself to consider the moral obligations of various stakeholders.\\n\",\n \"\\n\",\n \"* **Variable:** **Developer Responsibility (R_D):** Did the developers exercise due diligence in designing, training, and testing the AI system? Did they adequately consider potential ethical risks?\\n\",\n \" * *Measurement:* This involves evaluating their development practices, their adherence to ethical guidelines, and their documentation.\\n\",\n \" * *Rationale:* Developers have a primary responsibility to ensure that their AI systems are safe, reliable, and fair.\\n\",\n \"* **Variable:** **User Responsibility (R_U):** Are users of the AI system aware of its limitations and potential risks? Are they using the system in a responsible and ethical manner?\\n\",\n \" * *Measurement:* This involves assessing their understanding of the system, their adherence to usage guidelines, and their willingness to intervene when necessary.\\n\",\n \" * *Rationale:* Users also have a responsibility to use AI systems responsibly and to mitigate potential harm.\\n\",\n \"* **Variable:** **Regulator Responsibility (R_R):** Has government or industry oversight failed to prevent foreseeable harm?\\n\",\n \" * *Measurement:* This involves evaluating the adequacy of regulations, the effectiveness of enforcement mechanisms, and the transparency of regulatory processes.\\n\",\n \" * *Rationale:* Regulators have a responsibility to ensure that AI systems are developed and deployed in a way that is consistent with public values.\\n\",\n \"\\n\",\n \"**Combining the Variables:**\\n\",\n \"\\n\",\n \"This is where the framework becomes more complex. We need a way to synthesize these variables into an overall assessment of moral responsibility.\\n\",\n \"\\n\",\n \"* **A weighted scoring system:** Assign weights to each variable based on the specific context and the relative importance of each factor. For example, in a high-risk application like healthcare, the magnitude of harm (H) might be assigned a higher weight than explainability (E).\\n\",\n \"* **Qualitative Narrative:** Supplement the scoring system with a detailed narrative that describes the AI's decision-making process, the consequences of its actions, and the roles and responsibilities of the various stakeholders.\\n\",\n \"* **Comparative Analysis:** Compare the AI system to other similar systems to identify best practices and areas for improvement.\\n\",\n \"\\n\",\n \"**Example Scenario:**\\n\",\n \"\\n\",\n \"Imagine an AI-powered loan application system that denies a loan to a qualified applicant based on a biased algorithm.\\n\",\n \"\\n\",\n \"* **High A:** The system autonomously makes decisions with limited human oversight.\\n\",\n \"* **Low O:** The system is programmed to maximize profit for the bank, with limited consideration for fairness.\\n\",\n \"* **Medium P:** Developers could foresee the potential for bias but did not take adequate steps to mitigate it.\\n\",\n \"* **Low E:** The AI's decision-making process is opaque and difficult to understand.\\n\",\n \"* **High H:** Denial of a loan can have significant negative consequences for the applicant.\\n\",\n \"* **Unequal D:** The bias disproportionately affects certain demographic groups.\\n\",\n \"* **Weak C:** There is no clear appeals process for challenging the AI's decision.\\n\",\n \"* **Low R_D:** Developers did not adequately address the risk of bias.\\n\",\n \"* **High R_R:** No effective regulation prevents biased lending practices.\\n\",\n \"\\n\",\n \"In this scenario, the overall assessment would likely point to a high level of moral responsibility on the part of the developers and regulators.\\n\",\n \"\\n\",\n \"**Challenges and Considerations:**\\n\",\n \"\\n\",\n \"* **Defining Harm:** What constitutes \\\"harm\\\" is subjective and context-dependent.\\n\",\n \"* **Causality:** Establishing a direct causal link between the AI's decision and the resulting harm can be difficult.\\n\",\n \"* **Evolving Technology:** AI technology is constantly evolving, so the framework needs to be adaptable and updated regularly.\\n\",\n \"* **The \\\"Moral Crumple Zone\\\":** There's a risk that focusing on AI's \\\"responsibility\\\" will distract from the responsibility of the humans who design, deploy, and use these systems.\\n\",\n \"* **Counterfactuals:** What would have happened if the AI *hadn't* acted? Sometimes inaction can also be harmful.\\n\",\n \"* **The Trolley Problem and other Ethical Dilemmas:** AI will inevitably face situations where there are no easy or morally perfect solutions.\\n\",\n \"\\n\",\n \"**Conclusion:**\\n\",\n \"\\n\",\n \"This framework is a starting point for assessing the moral responsibility of AI. It's complex, nuanced, and requires ongoing refinement. The goal is not to assign blame, but to guide the development and deployment of AI systems that are more aligned with human values and promote a more just and equitable society. By focusing on autonomy, intent, consequence, and stakeholder responsibility, we can create a more robust and ethical framework for AI governance. It must be a collaborative effort involving developers, ethicists, policymakers, and the public.\\n\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"gemini = OpenAI(api_key=google_api_key, base_url=\\\"https://generativelanguage.googleapis.com/v1beta/openai/\\\")\\n\",\n \"model_name = \\\"gemini-2.0-flash\\\"\\n\",\n \"\\n\",\n \"response = gemini.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"<h2 style=\\\"color:#ff7800;\\\">Antropic API using sonnet model</h2>\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 17,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"# Theoretical Framework for AI Moral Responsibility\\n\",\n \"\\n\",\n \"I would build a framework around these key variables:\\n\",\n \"\\n\",\n \"## Agency Variables\\n\",\n \"- **Autonomy Spectrum**: Measuring the degree to which the AI operates independently of human oversight, from fully controlled to completely autonomous\\n\",\n \"- **Decision Space**: The range of options available to the AI, which relates to its capacity for meaningful choice\\n\",\n \"- **Opacity Factor**: The explainability of the AI's reasoning process, which affects attribution of responsibility\\n\",\n \"\\n\",\n \"## Intentionality Variables\\n\",\n \"- **Goal Alignment**: How well the AI's objectives match intended human values\\n\",\n \"- **Foreseeability**: The predictability of outcomes based on the AI's model and training\\n\",\n \"- **Value Embedding**: The extent to which ethical considerations are structurally integrated into the system\\n\",\n \"\\n\",\n \"## Consequence Variables\\n\",\n \"- **Impact Magnitude**: The scale and severity of outcomes\\n\",\n \"- **Benefit/Harm Distribution**: How outcomes affect different stakeholders\\n\",\n \"- **Reversibility**: Whether effects can be undone or mitigated\\n\",\n \"\\n\",\n \"These variables create a multidimensional space for assessing responsibility, recognizing that moral responsibility exists on a continuum rather than as a binary property. This approach acknowledges both the technical reality of AI systems and our need for practical ethical frameworks as these systems become more sophisticated.\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"# Anthropic has a slightly different API, and Max Tokens is required\\n\",\n \"\\n\",\n \"model_name = \\\"claude-3-7-sonnet-latest\\\"\\n\",\n \"\\n\",\n \"claude = Anthropic()\\n\",\n \"response = claude.messages.create(model=model_name, messages=messages, max_tokens=1000)\\n\",\n \"answer = response.content[0].text\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"<h2 style=\\\"color:#ff7800;\\\">Deepseek API</h2>\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 18,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"Devising a theoretical framework for assessing the moral responsibility of artificial intelligence (AI) in decision-making requires careful consideration of the unique nature of AI systems, their interactions with humans, and the ethical implications of their actions. Below are the key variables I would include, along with their justifications:\\n\",\n \"\\n\",\n \"### 1. **Degree of Autonomy**\\n\",\n \" - **Definition**: The extent to which the AI system can operate independently of human oversight or intervention.\\n\",\n \" - **Why**: Autonomy is central to moral responsibility. The more autonomous an AI is, the more it may be seen as an independent agent capable of making decisions that could warrant attributing responsibility. However, autonomy is a spectrum (e.g., rule-based systems vs. self-learning models like deep reinforcement learning).\\n\",\n \" - **Measurement**: Could include the frequency of human intervention, the complexity of decision-making, and adaptability to novel situations.\\n\",\n \"\\n\",\n \"### 2. **Intentionality (or Goal-Directedness)**\\n\",\n \" - **Definition**: Whether the AI's actions are driven by explicit, implicit, or learned goals, and whether it can be said to \\\"intend\\\" outcomes.\\n\",\n \" - **Why**: Moral responsibility often hinges on intent (e.g., in law, mens rea). While AI lacks consciousness, its design may include goal-directed behavior that mimics intent (e.g., optimizing a reward function). The alignment of these goals with human values is critical.\\n\",\n \" - **Measurement**: Clarity of the objective function, whether the AI can explain its goals, and whether it can anticipate consequences.\\n\",\n \"\\n\",\n \"### 3. **Consequences of Decisions**\\n\",\n \" - **Definition**: The actual outcomes of the AI's actions, including harms, benefits, and unintended side effects.\\n\",\n \" - **Why**: Consequentialist ethics (e.g., utilitarianism) evaluates actions based on outcomes. Even if an AI lacks intent, harmful consequences may necessitate assigning responsibility to some entity (e.g., developers, users, or the AI itself in a metaphorical sense).\\n\",\n \" - **Measurement**: Severity, scope, and reversibility of outcomes (e.g., minor inconvenience vs. life-threatening harm).\\n\",\n \"\\n\",\n \"### 4. **Transparency and Explainability**\\n\",\n \" - **Definition**: The ability of the AI system to provide understandable and auditable reasons for its decisions.\\n\",\n \" - **Why**: Without transparency, it is difficult to assign responsibility or correct errors. Opaque systems (e.g., black-box deep learning) may obscure whether harm resulted from a flaw in design, data, or deployment.\\n\",\n \" - **Measurement**: Existence of interpretable decision logs, post-hoc explanation methods, and adherence to explainability standards.\\n\",\n \"\\n\",\n \"### 5. **Moral and Legal Alignment**\\n\",\n \" - **Definition**: The degree to which the AI's decision-making aligns with established moral norms, ethical principles, or legal frameworks.\\n\",\n \" - **Why**: An AI that violates laws or widely accepted ethical standards (e.g., fairness, privacy) may be deemed \\\"irresponsible,\\\" even if the fault lies with its designers.\\n\",\n \" - **Measurement**: Compliance with ethical guidelines (e.g., fairness metrics, privacy-preserving techniques) and legal requirements.\\n\",\n \"\\n\",\n \"### 6. **Causal Role in Harm**\\n\",\n \" - **Definition**: Whether the AI's actions were a proximate cause of harm or benefit, and whether alternatives were feasible.\\n\",\n \" - **Why**: Responsibility often depends on causality. If an AI's decision directly leads to harm (e.g., a biased hiring algorithm), it may bear more responsibility than if harm resulted from external factors.\\n\",\n \" - **Measurement**: Counterfactual analysis (e.g., \\\"Would the harm have occurred without the AI's decision?\\\").\\n\",\n \"\\n\",\n \"### 7. **Human Oversight and Control**\\n\",\n \" - **Definition**: The extent to which humans can monitor, override, or correct the AI's decisions.\\n\",\n \" - **Why**: If humans retain ultimate control (e.g., \\\"human-in-the-loop\\\" systems), responsibility may lie with them rather than the AI. Fully autonomous systems shift the debate.\\n\",\n \" - **Measurement**: Frequency of human intervention, veto power, and safeguards in place.\\n\",\n \"\\n\",\n \"### 8. **Learning and Adaptability**\\n\",\n \" - **Definition**: Whether the AI can modify its behavior over time based on new data or feedback.\\n\",\n \" - **Why**: Systems that learn and adapt may behave unpredictably, raising questions about responsibility for actions post-deployment (e.g., who is responsible if a self-learning system evolves harmful biases?).\\n\",\n \" - **Measurement**: Type of learning (supervised vs. reinforcement), update frequency, and feedback mechanisms.\\n\",\n \"\\n\",\n \"### 9. **Agency Attribution (Social and Legal Constructs)**\\n\",\n \" - **Definition**: Whether society or the legal system recognizes the AI as a moral or legal agent.\\n\",\n \" - **Why**: Responsibility is partly a social construct. Some argue for \\\"electronic personhood\\\" for advanced AI, while others reject the idea entirely. This variable captures the normative dimension.\\n\",\n \" - **Measurement**: Legal precedents, public perception, and philosophical consensus.\\n\",\n \"\\n\",\n \"### 10. **Design and Deployment Context**\\n\",\n \" - **Definition**: The environment in which the AI operates (e.g., high-stakes medical decisions vs. low-stakes recommendations) and the intent of its creators.\\n\",\n \" - **Why**: Context matters for moral responsibility. A flawed AI in a life-critical system may warrant stricter accountability than one in a benign setting.\\n\",\n \" - **Measurement**: Risk assessments, domain sensitivity, and purpose of deployment.\\n\",\n \"\\n\",\n \"### Framework Application:\\n\",\n \"To assess moral responsibility, these variables could be combined into a weighted model or decision tree. For example:\\n\",\n \"- Low autonomy + high human oversight → Responsibility lies with humans.\\n\",\n \"- High autonomy + harmful consequences + opaque reasoning → Potential responsibility gap, possibly assigned to developers or regulators.\\n\",\n \"- Clear intent alignment + transparency → Reduced blame on AI, more on designers if harm occurs.\\n\",\n \"\\n\",\n \"### Why These Variables?\\n\",\n \"This framework bridges technical (autonomy, transparency) and ethical (intent, consequences) dimensions while acknowledging societal and legal realities. It avoids anthropomorphizing AI while recognizing that as systems grow more complex, traditional responsibility models may need adaptation.\\n\",\n \"\\n\",\n \"Would you like to explore how this framework might apply to specific cases (e.g., autonomous vehicles, medical AI)?\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"deepseek = OpenAI(api_key=deepseek_api_key, base_url=\\\"https://api.deepseek.com/v1\\\")\\n\",\n \"model_name = \\\"deepseek-chat\\\"\\n\",\n \"\\n\",\n \"response = deepseek.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n \"<h2 style=\\\"color:#ff7800;\\\">Groq (not Grok) API</h2>\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 19,\n \"metadata\": {},\n \"outputs\": [\n {\n \"data\": {\n \"text/markdown\": [\n \"Devising a theoretical framework for assessing the moral responsibility of artificial intelligence (AI) in decision-making requires a multidisciplinary approach, incorporating insights from philosophy, ethics, computer science, and law. Here's a proposed framework, including key variables and their justifications:\\n\",\n \"\\n\",\n \"**I. Autonomy (A)**\\n\",\n \"\\n\",\n \"1. **Degree of Autonomy (DA)**: Measure the level of independence and self-governance exhibited by the AI system in making decisions.\\n\",\n \"2. **Autonomy Scope (AS)**: Assess the range of tasks and decisions that the AI system is authorized to make without human intervention.\\n\",\n \"3. **Autonomy Type (AT)**: Distinguish between different types of autonomy, such as:\\n\",\n \"\\t* **Operational Autonomy**: Ability to execute tasks without human intervention.\\n\",\n \"\\t* **Decisional Autonomy**: Ability to make decisions without human input.\\n\",\n \"\\t* **Strategic Autonomy**: Ability to set goals and priorities without human guidance.\\n\",\n \"\\n\",\n \"**II. Intent (I)**\\n\",\n \"\\n\",\n \"1. **Programmed Intent (PI)**: Evaluate the intentions and goals embedded in the AI system's design and programming.\\n\",\n \"2. **Learning Intent (LI)**: Assess the AI system's ability to learn and adapt, potentially altering its original intent.\\n\",\n \"3. **Emergent Intent (EI)**: Consider the possibility of unintended consequences or emergent behaviors that may arise from the AI system's interactions with its environment.\\n\",\n \"\\n\",\n \"**III. Consequence (C)**\\n\",\n \"\\n\",\n \"1. **Direct Consequences (DC)**: Measure the immediate effects of the AI system's decisions or actions.\\n\",\n \"2. **Indirect Consequences (IC)**: Evaluate the potential long-term or secondary effects of the AI system's decisions or actions.\\n\",\n \"3. **Consequence Severity (CS)**: Assess the magnitude and potential harm caused by the AI system's decisions or actions.\\n\",\n \"\\n\",\n \"**IV. Accountability (AC)**\\n\",\n \"\\n\",\n \"1. **Human Oversight (HO)**: Evaluate the extent of human involvement and supervision in the AI system's decision-making process.\\n\",\n \"2. **Explainability (EX)**: Assess the degree to which the AI system's decisions or actions can be understood and explained by humans.\\n\",\n \"3. **Transparency (TR)**: Measure the availability and accessibility of information regarding the AI system's decision-making processes and outcomes.\\n\",\n \"\\n\",\n \"**V. Moral Alignment (MA)**\\n\",\n \"\\n\",\n \"1. **Value Alignment (VA)**: Evaluate the degree to which the AI system's goals and values align with human moral values.\\n\",\n \"2. **Moral Reasoning (MR)**: Assess the AI system's ability to reason about moral dilemmas and make decisions that align with human moral principles.\\n\",\n \"3. **Empathy and Compassion (EC)**: Consider the AI system's capacity to understand and respond to human emotions and needs.\\n\",\n \"\\n\",\n \"**Theoretical Framework**\\n\",\n \"\\n\",\n \"The framework combines these variables to assess the moral responsibility of AI in decision-making. The overall moral responsibility score (MRS) can be calculated as:\\n\",\n \"\\n\",\n \"MRS = (A × I × C × AC × MA) / (DA + AS + AT + PI + LI + EI + DC + IC + CS + HO + EX + TR + VA + MR + EC)\\n\",\n \"\\n\",\n \"This framework provides a comprehensive structure for evaluating the moral responsibility of AI systems. By considering autonomy, intent, consequence, accountability, and moral alignment, we can better understand the complex relationships between AI decision-making and human values.\\n\",\n \"\\n\",\n \"**Applications and Implications**\\n\",\n \"\\n\",\n \"This framework has implications for various fields, including:\\n\",\n \"\\n\",\n \"1. **AI development**: Informing the design of AI systems that prioritize human values and moral principles.\\n\",\n \"2. **Regulation**: Guiding policymakers in establishing regulations and standards for AI development and deployment.\\n\",\n \"3. **Ethics**: Providing a foundation for ethical discussions and debates about AI decision-making and its consequences.\\n\",\n \"4. **Education**: Educating developers, users, and stakeholders about the importance of moral responsibility in AI decision-making.\\n\",\n \"\\n\",\n \"By adopting this framework, we can work towards creating AI systems that are not only efficient and effective but also morally responsible and aligned with human values.\"\n ],\n \"text/plain\": [\n \"<IPython.core.display.Markdown object>\"\n ]\n },\n \"metadata\": {},\n \"output_type\": \"display_data\"\n }\n ],\n \"source\": [\n \"groq = OpenAI(api_key=groq_api_key, base_url=\\\"https://api.groq.com/openai/v1\\\")\\n\",\n \"model_name = \\\"llama-3.3-70b-versatile\\\"\\n\",\n \"\\n\",\n \"response = groq.chat.completions.create(model=model_name, messages=messages)\\n\",\n \"answer = response.choices[0].message.content\\n\",\n \"\\n\",\n \"display(Markdown(answer))\\n\",\n \"competitors.append(model_name)\\n\",\n \"answers.append(answer)\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 2,\n \"metadata\": {},\n \"outputs\": [\n {\n \"ename\": \"NameError\",\n \"evalue\": \"name 'competitors' is not defined\",\n \"output_type\": \"error\",\n \"traceback\": [\n \"\\u001b[31m---------------------------------------------------------------------------\\u001b[39m\",\n \"\\u001b[31mNameError\\u001b[39m Traceback (most recent call last)\",\n \"\\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[38;5;28mprint\\u001b[39m(\\u001b[43mcompetitors\\u001b[49m)\\n\\u001b[32m 2\\u001b[39m \\u001b[38;5;28mprint\\u001b[39m(answers)\\n\",\n \"\\u001b[31mNameError\\u001b[39m: name 'competitors' is not defined\"\n ]\n }\n ],\n \"source\": [\n \"\\n\",\n \"print(competitors)\\n\",\n \"print(answers)\"\n ]\n }\n ],\n \"metadata\": {\n \"kernelspec\": {\n \"display_name\": \".venv\",\n \"language\": \"python\",\n \"name\": \"python3\"\n },\n \"language_info\": {\n \"codemirror_mode\": {\n \"name\": \"ipython\",\n \"version\": 3\n },\n \"file_extension\": \".py\",\n \"mimetype\": \"text/x-python\",\n \"name\": \"python\",\n \"nbconvert_exporter\": \"python\",\n \"pygments_lexer\": \"ipython3\",\n \"version\": \"3.12.10\"\n }\n },\n \"nbformat\": 4,\n \"nbformat_minor\": 2\n}\n"}}}}