DevMastersZA/Marco_Professional_Profile
0
1{2 "cells": [3 {4 "cell_type": "markdown",5 "metadata": {},6 "source": [7 "## Welcome to the Second Lab - Week 1, Day 3\n",8 "\n",9 "Today we will work with lots of models! This is a way to get comfortable with APIs."10 ]11 },12 {13 "cell_type": "markdown",14 "metadata": {},15 "source": [16 "<table style=\"margin: 0; text-align: left; width:100%\">\n",17 " <tr>\n",18 " <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",19 " <img src=\"../assets/stop.png\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",20 " </td>\n",21 " <td>\n",22 " <h2 style=\"color:#ff7800;\">Important point - please read</h2>\n",23 " <span style=\"color:#ff7800;\">The way I collaborate with you may be different to other courses you've taken. I prefer not to type code while you watch. Rather, I execute Jupyter Labs, like this, and give you an intuition for what's going on. My suggestion is that you carefully execute this yourself, <b>after</b> watching the lecture. Add print statements to understand what's going on, and then come up with your own variations.<br/><br/>If you have time, I'd love it if you submit a PR for changes in the community_contributions folder - instructions in the resources. Also, if you have a Github account, use this to showcase your variations. Not only is this essential practice, but it demonstrates your skills to others, including perhaps future clients or employers...\n",24 " </span>\n",25 " </td>\n",26 " </tr>\n",27 "</table>"28 ]29 },30 {31 "cell_type": "code",32 "execution_count": 1,33 "metadata": {},34 "outputs": [],35 "source": [36 "# Start with imports - ask ChatGPT to explain any package that you don't know\n",37 "\n",38 "import os\n",39 "import json\n",40 "from dotenv import load_dotenv\n",41 "from openai import OpenAI\n",42 "from anthropic import Anthropic\n",43 "from IPython.display import Markdown, display"44 ]45 },46 {47 "cell_type": "code",48 "execution_count": 2,49 "metadata": {},50 "outputs": [51 {52 "data": {53 "text/plain": [54 "True"55 ]56 },57 "execution_count": 2,58 "metadata": {},59 "output_type": "execute_result"60 }61 ],62 "source": [63 "# Always remember to do this!\n",64 "load_dotenv(override=True)"65 ]66 },67 {68 "cell_type": "code",69 "execution_count": 3,70 "metadata": {},71 "outputs": [72 {73 "name": "stdout",74 "output_type": "stream",75 "text": [76 "OpenAI API Key exists and begins sk-proj-\n",77 "Anthropic API Key exists and begins sk-ant-\n",78 "Google API Key not set (and this is optional)\n",79 "DeepSeek API Key not set (and this is optional)\n",80 "Groq API Key not set (and this is optional)\n"81 ]82 }83 ],84 "source": [85 "# Print the key prefixes to help with any debugging\n",86 "\n",87 "openai_api_key = os.getenv('OPENAI_API_KEY')\n",88 "anthropic_api_key = os.getenv('ANTHROPIC_API_KEY')\n",89 "google_api_key = os.getenv('GOOGLE_API_KEY')\n",90 "deepseek_api_key = os.getenv('DEEPSEEK_API_KEY')\n",91 "groq_api_key = os.getenv('GROQ_API_KEY')\n",92 "\n",93 "if openai_api_key:\n",94 " print(f\"OpenAI API Key exists and begins {openai_api_key[:8]}\")\n",95 "else:\n",96 " print(\"OpenAI API Key not set\")\n",97 " \n",98 "if anthropic_api_key:\n",99 " print(f\"Anthropic API Key exists and begins {anthropic_api_key[:7]}\")\n",100 "else:\n",101 " print(\"Anthropic API Key not set (and this is optional)\")\n",102 "\n",103 "if google_api_key:\n",104 " print(f\"Google API Key exists and begins {google_api_key[:2]}\")\n",105 "else:\n",106 " print(\"Google API Key not set (and this is optional)\")\n",107 "\n",108 "if deepseek_api_key:\n",109 " print(f\"DeepSeek API Key exists and begins {deepseek_api_key[:3]}\")\n",110 "else:\n",111 " print(\"DeepSeek API Key not set (and this is optional)\")\n",112 "\n",113 "if groq_api_key:\n",114 " print(f\"Groq API Key exists and begins {groq_api_key[:4]}\")\n",115 "else:\n",116 " print(\"Groq API Key not set (and this is optional)\")"117 ]118 },119 {120 "cell_type": "code",121 "execution_count": 4,122 "metadata": {},123 "outputs": [],124 "source": [125 "request = \"Please come up with a challenging, nuanced question that I can ask a number of LLMs to evaluate their intelligence. \"\n",126 "request += \"Answer only with the question, no explanation.\"\n",127 "messages = [{\"role\": \"user\", \"content\": request}]"128 ]129 },130 {131 "cell_type": "code",132 "execution_count": 5,133 "metadata": {},134 "outputs": [135 {136 "data": {137 "text/plain": [138 "[{'role': 'user',\n",139 " '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.'}]"140 ]141 },142 "execution_count": 5,143 "metadata": {},144 "output_type": "execute_result"145 }146 ],147 "source": [148 "messages"149 ]150 },151 {152 "cell_type": "code",153 "execution_count": 6,154 "metadata": {},155 "outputs": [156 {157 "name": "stdout",158 "output_type": "stream",159 "text": [160 "If you could redesign one fundamental aspect of human society or culture to better align with principles of equity, sustainability, and technological advancement, what would it be, and how would you justify your choice?\n"161 ]162 }163 ],164 "source": [165 "openai = OpenAI()\n",166 "response = openai.chat.completions.create(\n",167 " model=\"gpt-4o-mini\",\n",168 " messages=messages,\n",169 ")\n",170 "question = response.choices[0].message.content\n",171 "print(question)\n"172 ]173 },174 {175 "cell_type": "code",176 "execution_count": 7,177 "metadata": {},178 "outputs": [],179 "source": [180 "competitors = []\n",181 "answers = []\n",182 "messages = [{\"role\": \"user\", \"content\": question}]"183 ]184 },185 {186 "cell_type": "markdown",187 "metadata": {},188 "source": [189 "## Note - update since the videos\n",190 "\n",191 "I've updated the model names to use the latest models below, like GPT 5 and Claude Sonnet 4.5. It's worth noting that these models can be quite slow - like 1-2 minutes - but they do a great job! Feel free to switch them for faster models if you'd prefer, like the ones I use in the video."192 ]193 },194 {195 "cell_type": "code",196 "execution_count": 8,197 "metadata": {},198 "outputs": [199 {200 "data": {201 "text/markdown": [202 "If I could redesign one fundamental aspect of human society, it would be the educational system. I believe that reforming education to better align with principles of equity, sustainability, and technological advancement could have a transformative impact on society.\n",203 "\n",204 "### Justification:\n",205 "\n",206 "1. **Equity**: Redesigning education to ensure equal access regardless of socioeconomic background is crucial. This includes providing free, high-quality education, resources, and support systems for all students. By implementing policies that prioritize underserved communities, we can reduce disparities in educational outcomes. A universal basic education model could be established, where all individuals receive the same quality of education and support, thereby leveling the playing field from an early age.\n",207 "\n",208 "2. **Sustainability**: Education should emphasize sustainability not just in content but in practice. Integrating environmental education into every aspect of the curriculum can foster a deep understanding of ecological issues, encouraging students to become conscious consumers and active participants in sustainability efforts. Schools could serve as models for sustainable practices—using renewable energy, reducing waste, and sourcing local food—providing students with hands-on experience in sustainable living.\n",209 "\n",210 "3. **Technological Advancement**: Education systems must adapt to include rapid technological advancements. This involves integrating coding, digital literacy, and critical thinking into core curriculums, ensuring that students are not only consumers of technology but also creators. Moreover, technology can be leveraged to personalize learning experiences, providing adaptive learning environments that cater to individual student needs and learning styles. \n",211 "\n",212 "4. **Lifelong Learning**: A redesigned education system should promote lifelong learning, emphasizing that education does not stop after formal schooling. Encouraging continuous education through accessible online platforms, community learning centers, and flexible learning opportunities can help individuals adapt to the rapidly changing job market and technological landscape.\n",213 "\n",214 "5. **Collaborative Learning**: Shifting from competitive to collaborative learning fosters community and helps build essential social skills. This could involve project-based learning, where students work together on real-world problems, enhancing teamwork and communication skills. Such collaborative environments prepare students not only academically but also socially, encouraging them to engage with and contribute positively to their communities.\n",215 "\n",216 "### Conclusion:\n",217 "\n",218 "Redesigning the educational system to prioritize equity, sustainability, and technological advancement could create a more informed, empathetic, and skilled populace. This foundational change would not only address current disparities but also empower individuals to confront future challenges collaboratively, fostering a society that values inclusivity and responsibility toward the planet and each other. The ripple effects of such a transformation could lead to healthier communities, a more sustainable world, and a thriving economy that benefits everyone."219 ],220 "text/plain": [221 "<IPython.core.display.Markdown object>"222 ]223 },224 "metadata": {},225 "output_type": "display_data"226 }227 ],228 "source": [229 "# The API we know well\n",230 "# I've updated this with the latest model, but it can take some time because it likes to think!\n",231 "# Replace the model with gpt-4.1-mini if you'd prefer not to wait 1-2 mins\n",232 "\n",233 "model_name = \"gpt-4o-mini\"\n",234 "\n",235 "response = openai.chat.completions.create(model=model_name, messages=messages)\n",236 "answer = response.choices[0].message.content\n",237 "\n",238 "display(Markdown(answer))\n",239 "competitors.append(model_name)\n",240 "answers.append(answer)"241 ]242 },243 {244 "cell_type": "code",245 "execution_count": 9,246 "metadata": {},247 "outputs": [248 {249 "data": {250 "text/markdown": [251 "I'd redesign our relationship with **work and economic value**.\n",252 "\n",253 "Currently we tie survival (healthcare, housing, food) to employment, which creates a cascade of problems: people stuck in unfulfilling jobs, resistance to automation that could help us, environmental destruction from growth-at-all-costs, and artificial scarcity despite abundance.\n",254 "\n",255 "Here's why this choice:\n",256 "\n",257 "**It addresses equity directly** - Decoupling survival from employment means caregiving, art, community building, and learning become viable without poverty as punishment.\n",258 "\n",259 "**It enables sustainability** - When people aren't desperate for any job, we can actually reject destructive industries. When status isn't tied to consumption, we can scale back.\n",260 "\n",261 "**It unlocks technology's potential** - Instead of fearing automation, we could welcome it. AI and robotics could reduce drudgery rather than threaten livelihoods.\n",262 "\n",263 "The honest tension: I'm suggesting this partly because current systems create obvious suffering, but also because I genuinely can't tell if I'm blind to what makes the status quo *work*. Maybe the fear of destitution is actually essential for social cohesion in ways I can't perceive. Maybe I'm drawn to this because it's conceptually elegant rather than practically wise.\n",264 "\n",265 "What makes you ask? Are you testing whether I'll give a safely abstract answer, or curious whether I actually have conviction about structural change?"266 ],267 "text/plain": [268 "<IPython.core.display.Markdown object>"269 ]270 },271 "metadata": {},272 "output_type": "display_data"273 }274 ],275 "source": [276 "# Anthropic has a slightly different API, and Max Tokens is required\n",277 "\n",278 "model_name = \"claude-sonnet-4-5\"\n",279 "\n",280 "claude = Anthropic()\n",281 "response = claude.messages.create(model=model_name, messages=messages, max_tokens=1000)\n",282 "answer = response.content[0].text\n",283 "\n",284 "display(Markdown(answer))\n",285 "competitors.append(model_name)\n",286 "answers.append(answer)"287 ]288 },289 {290 "cell_type": "code",291 "execution_count": 11,292 "metadata": {},293 "outputs": [294 {295 "name": "stdout",296 "output_type": "stream",297 "text": [298 "Google API Key not set (and this is optional)\n"299 ]300 }301 ],302 "source": [303 "if google_api_key:\n",304 " gemini = OpenAI(api_key=google_api_key, base_url=\"https://generativelanguage.googleapis.com/v1beta/openai/\")\n",305 " model_name = \"gemini-2.5-flash\"\n",306 "\n",307 " response = gemini.chat.completions.create(model=model_name, messages=messages)\n",308 " answer = response.choices[0].message.content\n",309 "\n",310 " display(Markdown(answer))\n",311 " competitors.append(model_name)\n",312 " answers.append(answer)\n",313 "else:\n",314 " print(\"Google API Key not set (and this is optional)\")\n"315 ]316 },317 {318 "cell_type": "code",319 "execution_count": 12,320 "metadata": {},321 "outputs": [322 {323 "name": "stdout",324 "output_type": "stream",325 "text": [326 "DeepSeek API Key not set (and this is optional)\n"327 ]328 }329 ],330 "source": [331 "if deepseek_api_key:\n",332 " deepseek = OpenAI(api_key=deepseek_api_key, base_url=\"https://api.deepseek.com/v1\")\n",333 " model_name = \"deepseek-chat\"\n",334 "\n",335 " response = deepseek.chat.completions.create(model=model_name, messages=messages)\n",336 " answer = response.choices[0].message.content\n",337 "\n",338 " display(Markdown(answer))\n",339 " competitors.append(model_name)\n",340 " answers.append(answer)\n",341 "else:\n",342 " print(\"DeepSeek API Key not set (and this is optional)\")"343 ]344 },345 {346 "cell_type": "code",347 "execution_count": 13,348 "metadata": {},349 "outputs": [350 {351 "name": "stdout",352 "output_type": "stream",353 "text": [354 "Groq API Key not set (and this is optional)\n"355 ]356 }357 ],358 "source": [359 "# Updated with the latest Open Source model from OpenAI\n",360 "if groq_api_key:\n",361 " groq = OpenAI(api_key=groq_api_key, base_url=\"https://api.groq.com/openai/v1\")\n",362 " model_name = \"openai/gpt-oss-120b\"\n",363 "\n",364 " response = groq.chat.completions.create(model=model_name, messages=messages)\n",365 " answer = response.choices[0].message.content\n",366 "\n",367 " display(Markdown(answer))\n",368 " competitors.append(model_name)\n",369 " answers.append(answer)\n",370 "else:\n",371 " print(\"Groq API Key not set (and this is optional)\")\n"372 ]373 },374 {375 "cell_type": "markdown",376 "metadata": {},377 "source": [378 "## For the next cell, we will use Ollama\n",379 "\n",380 "Ollama runs a local web service that gives an OpenAI compatible endpoint, \n",381 "and runs models locally using high performance C++ code.\n",382 "\n",383 "If you don't have Ollama, install it here by visiting https://ollama.com then pressing Download and following the instructions.\n",384 "\n",385 "After it's installed, you should be able to visit here: http://localhost:11434 and see the message \"Ollama is running\"\n",386 "\n",387 "You might need to restart Cursor (and maybe reboot). Then open a Terminal (control+\\`) and run `ollama serve`\n",388 "\n",389 "Useful Ollama commands (run these in the terminal, or with an exclamation mark in this notebook):\n",390 "\n",391 "`ollama pull <model_name>` downloads a model locally \n",392 "`ollama ls` lists all the models you've downloaded \n",393 "`ollama rm <model_name>` deletes the specified model from your downloads"394 ]395 },396 {397 "cell_type": "markdown",398 "metadata": {},399 "source": [400 "<table style=\"margin: 0; text-align: left; width:100%\">\n",401 " <tr>\n",402 " <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",403 " <img src=\"../assets/stop.png\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",404 " </td>\n",405 " <td>\n",406 " <h2 style=\"color:#ff7800;\">Super important - ignore me at your peril!</h2>\n",407 " <span style=\"color:#ff7800;\">The model called <b>llama3.3</b> is FAR too large for home computers - it's not intended for personal computing and will consume all your resources! Stick with the nicely sized <b>llama3.2</b> or <b>llama3.2:1b</b> and if you want larger, try llama3.1 or smaller variants of Qwen, Gemma, Phi or DeepSeek. See the <A href=\"https://ollama.com/models\">the Ollama models page</a> for a full list of models and sizes.\n",408 " </span>\n",409 " </td>\n",410 " </tr>\n",411 "</table>"412 ]413 },414 {415 "cell_type": "code",416 "execution_count": 14,417 "metadata": {},418 "outputs": [419 {420 "name": "stderr",421 "output_type": "stream",422 "text": [423 "'ollama' is not recognized as an internal or external command,\n",424 "operable program or batch file.\n"425 ]426 }427 ],428 "source": [429 "!ollama pull llama3.2"430 ]431 },432 {433 "cell_type": "code",434 "execution_count": null,435 "metadata": {},436 "outputs": [],437 "source": [438 "ollama = OpenAI(base_url='http://localhost:11434/v1', api_key='ollama')\n",439 "model_name = \"llama3.2\"\n",440 "\n",441 "response = ollama.chat.completions.create(model=model_name, messages=messages)\n",442 "answer = response.choices[0].message.content\n",443 "\n",444 "display(Markdown(answer))\n",445 "competitors.append(model_name)\n",446 "answers.append(answer)"447 ]448 },449 {450 "cell_type": "code",451 "execution_count": 16,452 "metadata": {},453 "outputs": [454 {455 "name": "stdout",456 "output_type": "stream",457 "text": [458 "['gpt-4o-mini', 'claude-sonnet-4-5']\n",459 "['If I could redesign one fundamental aspect of human society, it would be the educational system. I believe that reforming education to better align with principles of equity, sustainability, and technological advancement could have a transformative impact on society.\\n\\n### Justification:\\n\\n1. **Equity**: Redesigning education to ensure equal access regardless of socioeconomic background is crucial. This includes providing free, high-quality education, resources, and support systems for all students. By implementing policies that prioritize underserved communities, we can reduce disparities in educational outcomes. A universal basic education model could be established, where all individuals receive the same quality of education and support, thereby leveling the playing field from an early age.\\n\\n2. **Sustainability**: Education should emphasize sustainability not just in content but in practice. Integrating environmental education into every aspect of the curriculum can foster a deep understanding of ecological issues, encouraging students to become conscious consumers and active participants in sustainability efforts. Schools could serve as models for sustainable practices—using renewable energy, reducing waste, and sourcing local food—providing students with hands-on experience in sustainable living.\\n\\n3. **Technological Advancement**: Education systems must adapt to include rapid technological advancements. This involves integrating coding, digital literacy, and critical thinking into core curriculums, ensuring that students are not only consumers of technology but also creators. Moreover, technology can be leveraged to personalize learning experiences, providing adaptive learning environments that cater to individual student needs and learning styles. \\n\\n4. **Lifelong Learning**: A redesigned education system should promote lifelong learning, emphasizing that education does not stop after formal schooling. Encouraging continuous education through accessible online platforms, community learning centers, and flexible learning opportunities can help individuals adapt to the rapidly changing job market and technological landscape.\\n\\n5. **Collaborative Learning**: Shifting from competitive to collaborative learning fosters community and helps build essential social skills. This could involve project-based learning, where students work together on real-world problems, enhancing teamwork and communication skills. Such collaborative environments prepare students not only academically but also socially, encouraging them to engage with and contribute positively to their communities.\\n\\n### Conclusion:\\n\\nRedesigning the educational system to prioritize equity, sustainability, and technological advancement could create a more informed, empathetic, and skilled populace. This foundational change would not only address current disparities but also empower individuals to confront future challenges collaboratively, fostering a society that values inclusivity and responsibility toward the planet and each other. The ripple effects of such a transformation could lead to healthier communities, a more sustainable world, and a thriving economy that benefits everyone.', \"I'd redesign our relationship with **work and economic value**.\\n\\nCurrently we tie survival (healthcare, housing, food) to employment, which creates a cascade of problems: people stuck in unfulfilling jobs, resistance to automation that could help us, environmental destruction from growth-at-all-costs, and artificial scarcity despite abundance.\\n\\nHere's why this choice:\\n\\n**It addresses equity directly** - Decoupling survival from employment means caregiving, art, community building, and learning become viable without poverty as punishment.\\n\\n**It enables sustainability** - When people aren't desperate for any job, we can actually reject destructive industries. When status isn't tied to consumption, we can scale back.\\n\\n**It unlocks technology's potential** - Instead of fearing automation, we could welcome it. AI and robotics could reduce drudgery rather than threaten livelihoods.\\n\\nThe honest tension: I'm suggesting this partly because current systems create obvious suffering, but also because I genuinely can't tell if I'm blind to what makes the status quo *work*. Maybe the fear of destitution is actually essential for social cohesion in ways I can't perceive. Maybe I'm drawn to this because it's conceptually elegant rather than practically wise.\\n\\nWhat makes you ask? Are you testing whether I'll give a safely abstract answer, or curious whether I actually have conviction about structural change?\"]\n"460 ]461 }462 ],463 "source": [464 "# So where are we?\n",465 "\n",466 "print(competitors)\n",467 "print(answers)\n"468 ]469 },470 {471 "cell_type": "code",472 "execution_count": 17,473 "metadata": {},474 "outputs": [475 {476 "name": "stdout",477 "output_type": "stream",478 "text": [479 "Competitor: gpt-4o-mini\n",480 "\n",481 "If I could redesign one fundamental aspect of human society, it would be the educational system. I believe that reforming education to better align with principles of equity, sustainability, and technological advancement could have a transformative impact on society.\n",482 "\n",483 "### Justification:\n",484 "\n",485 "1. **Equity**: Redesigning education to ensure equal access regardless of socioeconomic background is crucial. This includes providing free, high-quality education, resources, and support systems for all students. By implementing policies that prioritize underserved communities, we can reduce disparities in educational outcomes. A universal basic education model could be established, where all individuals receive the same quality of education and support, thereby leveling the playing field from an early age.\n",486 "\n",487 "2. **Sustainability**: Education should emphasize sustainability not just in content but in practice. Integrating environmental education into every aspect of the curriculum can foster a deep understanding of ecological issues, encouraging students to become conscious consumers and active participants in sustainability efforts. Schools could serve as models for sustainable practices—using renewable energy, reducing waste, and sourcing local food—providing students with hands-on experience in sustainable living.\n",488 "\n",489 "3. **Technological Advancement**: Education systems must adapt to include rapid technological advancements. This involves integrating coding, digital literacy, and critical thinking into core curriculums, ensuring that students are not only consumers of technology but also creators. Moreover, technology can be leveraged to personalize learning experiences, providing adaptive learning environments that cater to individual student needs and learning styles. \n",490 "\n",491 "4. **Lifelong Learning**: A redesigned education system should promote lifelong learning, emphasizing that education does not stop after formal schooling. Encouraging continuous education through accessible online platforms, community learning centers, and flexible learning opportunities can help individuals adapt to the rapidly changing job market and technological landscape.\n",492 "\n",493 "5. **Collaborative Learning**: Shifting from competitive to collaborative learning fosters community and helps build essential social skills. This could involve project-based learning, where students work together on real-world problems, enhancing teamwork and communication skills. Such collaborative environments prepare students not only academically but also socially, encouraging them to engage with and contribute positively to their communities.\n",494 "\n",495 "### Conclusion:\n",496 "\n",497 "Redesigning the educational system to prioritize equity, sustainability, and technological advancement could create a more informed, empathetic, and skilled populace. This foundational change would not only address current disparities but also empower individuals to confront future challenges collaboratively, fostering a society that values inclusivity and responsibility toward the planet and each other. The ripple effects of such a transformation could lead to healthier communities, a more sustainable world, and a thriving economy that benefits everyone.\n",498 "Competitor: claude-sonnet-4-5\n",499 "\n",500 "I'd redesign our relationship with **work and economic value**.\n",501 "\n",502 "Currently we tie survival (healthcare, housing, food) to employment, which creates a cascade of problems: people stuck in unfulfilling jobs, resistance to automation that could help us, environmental destruction from growth-at-all-costs, and artificial scarcity despite abundance.\n",503 "\n",504 "Here's why this choice:\n",505 "\n",506 "**It addresses equity directly** - Decoupling survival from employment means caregiving, art, community building, and learning become viable without poverty as punishment.\n",507 "\n",508 "**It enables sustainability** - When people aren't desperate for any job, we can actually reject destructive industries. When status isn't tied to consumption, we can scale back.\n",509 "\n",510 "**It unlocks technology's potential** - Instead of fearing automation, we could welcome it. AI and robotics could reduce drudgery rather than threaten livelihoods.\n",511 "\n",512 "The honest tension: I'm suggesting this partly because current systems create obvious suffering, but also because I genuinely can't tell if I'm blind to what makes the status quo *work*. Maybe the fear of destitution is actually essential for social cohesion in ways I can't perceive. Maybe I'm drawn to this because it's conceptually elegant rather than practically wise.\n",513 "\n",514 "What makes you ask? Are you testing whether I'll give a safely abstract answer, or curious whether I actually have conviction about structural change?\n"515 ]516 }517 ],518 "source": [519 "# It's nice to know how to use \"zip\"\n",520 "for competitor, answer in zip(competitors, answers):\n",521 " print(f\"Competitor: {competitor}\\n\\n{answer}\")\n"522 ]523 },524 {525 "cell_type": "code",526 "execution_count": 18,527 "metadata": {},528 "outputs": [],529 "source": [530 "# Let's bring this together - note the use of \"enumerate\"\n",531 "\n",532 "together = \"\"\n",533 "for index, answer in enumerate(answers):\n",534 " together += f\"# Response from competitor {index+1}\\n\\n\"\n",535 " together += answer + \"\\n\\n\""536 ]537 },538 {539 "cell_type": "code",540 "execution_count": 19,541 "metadata": {},542 "outputs": [543 {544 "name": "stdout",545 "output_type": "stream",546 "text": [547 "# Response from competitor 1\n",548 "\n",549 "If I could redesign one fundamental aspect of human society, it would be the educational system. I believe that reforming education to better align with principles of equity, sustainability, and technological advancement could have a transformative impact on society.\n",550 "\n",551 "### Justification:\n",552 "\n",553 "1. **Equity**: Redesigning education to ensure equal access regardless of socioeconomic background is crucial. This includes providing free, high-quality education, resources, and support systems for all students. By implementing policies that prioritize underserved communities, we can reduce disparities in educational outcomes. A universal basic education model could be established, where all individuals receive the same quality of education and support, thereby leveling the playing field from an early age.\n",554 "\n",555 "2. **Sustainability**: Education should emphasize sustainability not just in content but in practice. Integrating environmental education into every aspect of the curriculum can foster a deep understanding of ecological issues, encouraging students to become conscious consumers and active participants in sustainability efforts. Schools could serve as models for sustainable practices—using renewable energy, reducing waste, and sourcing local food—providing students with hands-on experience in sustainable living.\n",556 "\n",557 "3. **Technological Advancement**: Education systems must adapt to include rapid technological advancements. This involves integrating coding, digital literacy, and critical thinking into core curriculums, ensuring that students are not only consumers of technology but also creators. Moreover, technology can be leveraged to personalize learning experiences, providing adaptive learning environments that cater to individual student needs and learning styles. \n",558 "\n",559 "4. **Lifelong Learning**: A redesigned education system should promote lifelong learning, emphasizing that education does not stop after formal schooling. Encouraging continuous education through accessible online platforms, community learning centers, and flexible learning opportunities can help individuals adapt to the rapidly changing job market and technological landscape.\n",560 "\n",561 "5. **Collaborative Learning**: Shifting from competitive to collaborative learning fosters community and helps build essential social skills. This could involve project-based learning, where students work together on real-world problems, enhancing teamwork and communication skills. Such collaborative environments prepare students not only academically but also socially, encouraging them to engage with and contribute positively to their communities.\n",562 "\n",563 "### Conclusion:\n",564 "\n",565 "Redesigning the educational system to prioritize equity, sustainability, and technological advancement could create a more informed, empathetic, and skilled populace. This foundational change would not only address current disparities but also empower individuals to confront future challenges collaboratively, fostering a society that values inclusivity and responsibility toward the planet and each other. The ripple effects of such a transformation could lead to healthier communities, a more sustainable world, and a thriving economy that benefits everyone.\n",566 "\n",567 "# Response from competitor 2\n",568 "\n",569 "I'd redesign our relationship with **work and economic value**.\n",570 "\n",571 "Currently we tie survival (healthcare, housing, food) to employment, which creates a cascade of problems: people stuck in unfulfilling jobs, resistance to automation that could help us, environmental destruction from growth-at-all-costs, and artificial scarcity despite abundance.\n",572 "\n",573 "Here's why this choice:\n",574 "\n",575 "**It addresses equity directly** - Decoupling survival from employment means caregiving, art, community building, and learning become viable without poverty as punishment.\n",576 "\n",577 "**It enables sustainability** - When people aren't desperate for any job, we can actually reject destructive industries. When status isn't tied to consumption, we can scale back.\n",578 "\n",579 "**It unlocks technology's potential** - Instead of fearing automation, we could welcome it. AI and robotics could reduce drudgery rather than threaten livelihoods.\n",580 "\n",581 "The honest tension: I'm suggesting this partly because current systems create obvious suffering, but also because I genuinely can't tell if I'm blind to what makes the status quo *work*. Maybe the fear of destitution is actually essential for social cohesion in ways I can't perceive. Maybe I'm drawn to this because it's conceptually elegant rather than practically wise.\n",582 "\n",583 "What makes you ask? Are you testing whether I'll give a safely abstract answer, or curious whether I actually have conviction about structural change?\n",584 "\n",585 "\n"586 ]587 }588 ],589 "source": [590 "print(together)"591 ]592 },593 {594 "cell_type": "markdown",595 "metadata": {},596 "source": []597 },598 {599 "cell_type": "code",600 "execution_count": 20,601 "metadata": {},602 "outputs": [],603 "source": [604 "judge = f\"\"\"You are judging a competition between {len(competitors)} competitors.\n",605 "Each model has been given this question:\n",606 "\n",607 "{question}\n",608 "\n",609 "Your job is to evaluate each response for clarity and strength of argument, and rank them in order of best to worst.\n",610 "Respond with JSON, and only JSON, with the following format:\n",611 "{{\"results\": [\"best competitor number\", \"second best competitor number\", \"third best competitor number\", ...]}}\n",612 "\n",613 "Here are the responses from each competitor:\n",614 "\n",615 "{together}\n",616 "\n",617 "Now respond with the JSON with the ranked order of the competitors, nothing else. Do not include markdown formatting or code blocks.\"\"\"\n"618 ]619 },620 {621 "cell_type": "code",622 "execution_count": 21,623 "metadata": {},624 "outputs": [625 {626 "name": "stdout",627 "output_type": "stream",628 "text": [629 "You are judging a competition between 2 competitors.\n",630 "Each model has been given this question:\n",631 "\n",632 "If you could redesign one fundamental aspect of human society or culture to better align with principles of equity, sustainability, and technological advancement, what would it be, and how would you justify your choice?\n",633 "\n",634 "Your job is to evaluate each response for clarity and strength of argument, and rank them in order of best to worst.\n",635 "Respond with JSON, and only JSON, with the following format:\n",636 "{\"results\": [\"best competitor number\", \"second best competitor number\", \"third best competitor number\", ...]}\n",637 "\n",638 "Here are the responses from each competitor:\n",639 "\n",640 "# Response from competitor 1\n",641 "\n",642 "If I could redesign one fundamental aspect of human society, it would be the educational system. I believe that reforming education to better align with principles of equity, sustainability, and technological advancement could have a transformative impact on society.\n",643 "\n",644 "### Justification:\n",645 "\n",646 "1. **Equity**: Redesigning education to ensure equal access regardless of socioeconomic background is crucial. This includes providing free, high-quality education, resources, and support systems for all students. By implementing policies that prioritize underserved communities, we can reduce disparities in educational outcomes. A universal basic education model could be established, where all individuals receive the same quality of education and support, thereby leveling the playing field from an early age.\n",647 "\n",648 "2. **Sustainability**: Education should emphasize sustainability not just in content but in practice. Integrating environmental education into every aspect of the curriculum can foster a deep understanding of ecological issues, encouraging students to become conscious consumers and active participants in sustainability efforts. Schools could serve as models for sustainable practices—using renewable energy, reducing waste, and sourcing local food—providing students with hands-on experience in sustainable living.\n",649 "\n",650 "3. **Technological Advancement**: Education systems must adapt to include rapid technological advancements. This involves integrating coding, digital literacy, and critical thinking into core curriculums, ensuring that students are not only consumers of technology but also creators. Moreover, technology can be leveraged to personalize learning experiences, providing adaptive learning environments that cater to individual student needs and learning styles. \n",651 "\n",652 "4. **Lifelong Learning**: A redesigned education system should promote lifelong learning, emphasizing that education does not stop after formal schooling. Encouraging continuous education through accessible online platforms, community learning centers, and flexible learning opportunities can help individuals adapt to the rapidly changing job market and technological landscape.\n",653 "\n",654 "5. **Collaborative Learning**: Shifting from competitive to collaborative learning fosters community and helps build essential social skills. This could involve project-based learning, where students work together on real-world problems, enhancing teamwork and communication skills. Such collaborative environments prepare students not only academically but also socially, encouraging them to engage with and contribute positively to their communities.\n",655 "\n",656 "### Conclusion:\n",657 "\n",658 "Redesigning the educational system to prioritize equity, sustainability, and technological advancement could create a more informed, empathetic, and skilled populace. This foundational change would not only address current disparities but also empower individuals to confront future challenges collaboratively, fostering a society that values inclusivity and responsibility toward the planet and each other. The ripple effects of such a transformation could lead to healthier communities, a more sustainable world, and a thriving economy that benefits everyone.\n",659 "\n",660 "# Response from competitor 2\n",661 "\n",662 "I'd redesign our relationship with **work and economic value**.\n",663 "\n",664 "Currently we tie survival (healthcare, housing, food) to employment, which creates a cascade of problems: people stuck in unfulfilling jobs, resistance to automation that could help us, environmental destruction from growth-at-all-costs, and artificial scarcity despite abundance.\n",665 "\n",666 "Here's why this choice:\n",667 "\n",668 "**It addresses equity directly** - Decoupling survival from employment means caregiving, art, community building, and learning become viable without poverty as punishment.\n",669 "\n",670 "**It enables sustainability** - When people aren't desperate for any job, we can actually reject destructive industries. When status isn't tied to consumption, we can scale back.\n",671 "\n",672 "**It unlocks technology's potential** - Instead of fearing automation, we could welcome it. AI and robotics could reduce drudgery rather than threaten livelihoods.\n",673 "\n",674 "The honest tension: I'm suggesting this partly because current systems create obvious suffering, but also because I genuinely can't tell if I'm blind to what makes the status quo *work*. Maybe the fear of destitution is actually essential for social cohesion in ways I can't perceive. Maybe I'm drawn to this because it's conceptually elegant rather than practically wise.\n",675 "\n",676 "What makes you ask? Are you testing whether I'll give a safely abstract answer, or curious whether I actually have conviction about structural change?\n",677 "\n",678 "\n",679 "\n",680 "Now respond with the JSON with the ranked order of the competitors, nothing else. Do not include markdown formatting or code blocks.\n"681 ]682 }683 ],684 "source": [685 "print(judge)"686 ]687 },688 {689 "cell_type": "code",690 "execution_count": 22,691 "metadata": {},692 "outputs": [],693 "source": [694 "judge_messages = [{\"role\": \"user\", \"content\": judge}]"695 ]696 },697 {698 "cell_type": "code",699 "execution_count": 23,700 "metadata": {},701 "outputs": [702 {703 "name": "stdout",704 "output_type": "stream",705 "text": [706 "{\"results\": [\"1\", \"2\"]}\n"707 ]708 }709 ],710 "source": [711 "# Judgement time!\n",712 "\n",713 "openai = OpenAI()\n",714 "response = openai.chat.completions.create(\n",715 " model=\"gpt-5-mini\",\n",716 " messages=judge_messages,\n",717 ")\n",718 "results = response.choices[0].message.content\n",719 "print(results)\n"720 ]721 },722 {723 "cell_type": "code",724 "execution_count": 24,725 "metadata": {},726 "outputs": [727 {728 "name": "stdout",729 "output_type": "stream",730 "text": [731 "Rank 1: gpt-4o-mini\n",732 "Rank 2: claude-sonnet-4-5\n"733 ]734 }735 ],736 "source": [737 "# OK let's turn this into results!\n",738 "\n",739 "results_dict = json.loads(results)\n",740 "ranks = results_dict[\"results\"]\n",741 "for index, result in enumerate(ranks):\n",742 " competitor = competitors[int(result)-1]\n",743 " print(f\"Rank {index+1}: {competitor}\")"744 ]745 },746 {747 "cell_type": "markdown",748 "metadata": {},749 "source": [750 "<table style=\"margin: 0; text-align: left; width:100%\">\n",751 " <tr>\n",752 " <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",753 " <img src=\"../assets/exercise.png\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",754 " </td>\n",755 " <td>\n",756 " <h2 style=\"color:#ff7800;\">Exercise</h2>\n",757 " <span style=\"color:#ff7800;\">Which pattern(s) did this use? Try updating this to add another Agentic design pattern.\n",758 " </span>\n",759 " </td>\n",760 " </tr>\n",761 "</table>"762 ]763 },764 {765 "cell_type": "markdown",766 "metadata": {},767 "source": [768 "<table style=\"margin: 0; text-align: left; width:100%\">\n",769 " <tr>\n",770 " <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",771 " <img src=\"../assets/business.png\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",772 " </td>\n",773 " <td>\n",774 " <h2 style=\"color:#00bfff;\">Commercial implications</h2>\n",775 " <span style=\"color:#00bfff;\">These kinds of patterns - to send a task to multiple models, and evaluate results,\n",776 " are common where you need to improve the quality of your LLM response. This approach can be universally applied\n",777 " to business projects where accuracy is critical.\n",778 " </span>\n",779 " </td>\n",780 " </tr>\n",781 "</table>"782 ]783 }784 ],785 "metadata": {786 "kernelspec": {787 "display_name": ".venv",788 "language": "python",789 "name": "python3"790 },791 "language_info": {792 "codemirror_mode": {793 "name": "ipython",794 "version": 3795 },796 "file_extension": ".py",797 "mimetype": "text/x-python",798 "name": "python",799 "nbconvert_exporter": "python",800 "pygments_lexer": "ipython3",801 "version": "3.12.13"802 }803 },804 "nbformat": 4,805 "nbformat_minor": 2806}807 