From 1c6a744d812f9bd31f248f94384d643947c203a3 Mon Sep 17 00:00:00 2001 From: leonid08 Date: Thu, 31 Jul 2025 14:06:02 -0400 Subject: [PATCH] Added my day 1 exercise - creating a subject line for an email text --- .../day01_email_subjectLine_creator.ipynb | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 week1/community-contributions/day01_email_subjectLine_creator.ipynb diff --git a/week1/community-contributions/day01_email_subjectLine_creator.ipynb b/week1/community-contributions/day01_email_subjectLine_creator.ipynb new file mode 100644 index 0000000..5ff45d4 --- /dev/null +++ b/week1/community-contributions/day01_email_subjectLine_creator.ipynb @@ -0,0 +1,124 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "36ef4c36-2905-4485-a46e-dead68cc2dcb", + "metadata": {}, + "outputs": [], + "source": [ + "from openai import OpenAI\n", + "from dotenv import load_dotenv\n", + "from IPython.display import Markdown\n", + "\n", + "# Step 1: Create your prompts\n", + "\n", + "load_dotenv(override=True)\n", + "\n", + "system_prompt = \"You are an assistant that analyzes the contents of \\\n", + " email texts and suggests short subject lines for the email based \\\n", + " on the requested tone and language. Respond in markdown.\"\n", + "user_prompt = \"\"\"\n", + " What’s the hardest-working organ in your body? A lot of people will say the heart. After all, it beats 100,000 times a day. It doesn’t rest. It doesn’t sleep. And it keeps you alive.\n", + "\n", + "\n", + "But we wanted a second opinion. For this edition of From the Armchair, our monthly mental health newsletter, we asked our psychiatrists. Some of them had a different answer: The brain.\n", + "\n", + "\n", + "If that surprises you, think about how your body feels after a long workout—then compare it to how your brain feels after a day of meetings, emails, problem-solving, or just trying to hold it all together. That drained, foggy, overstimulated sensation? That’s cognitive fatigue. And even if your body hasn’t moved much, the exhaustion is very real.\n", + "\n", + "The brain’s quiet hustle\n", + "\n", + "Cognitive fatigue happens when the mental load we’re carrying uses up more fuel than we realize. And the brain is a gas-guzzler. It makes up only 2% of our body weight but consumes about 20% of our energy—just to keep us functioning.\n", + "\n", + "That’s not just because we’re thinking deeply or making big decisions. It’s because the brain is always on: Absorbing information, interpreting social cues, navigating ambiguity, switching between tasks, and trying to make sense of a noisy world. All of that takes effort.\n", + "\n", + "Which brings us to a fallacy: We sometimes think we haven’t “done anything” if we haven’t physically moved or checked something off a list. But the brain doesn’t lift weights to get tired. Its heavy lifting is invisible.\n", + "\n", + "The myth: Motion = accomplishment\n", + "\n", + "There’s a cultural bias that equates movement with productivity. A tired body is seen as earned. A tired mind is often seen as weakness—or worse. Neuroscience disagrees.\n", + "\n", + "The truth is, mental labor—especially the constant decision-making, emotional regulation, and alertness that life demands—can be deeply taxing. Unlike a workout, there's often no clear beginning, middle, or end. Just a low-grade hum that builds over time.\n", + "\n", + "So if you’ve ever said, “Why am I so tired? I didn’t even do anything today,” this could be your answer: Your brain has been sprinting in place.\n", + "\n", + "Mental health and the weight of thinking\n", + "\n", + "Talkiatry psychiatrists note that if you’re living with a mental health condition, this load can feel even heavier. Decisions feel high stakes. Basic tasks can turn into uphill climbs. We can get overloaded with competing signals. Every day stress taxes the circuits we rely on to cope.\n", + "\n", + "While the brain is incredibly resilient, nearly every mental health condition adds friction to thought. That friction requires effort to overcome. That effort burns fuel. And that fuel runs out faster than we expect.\n", + "\n", + "Rest isn’t laziness—it’s repair\n", + "\n", + "This isn’t meant to sound hopeless. In fact, it’s the opposite.\n", + "\n", + " \n", + "\n", + "Recognizing that your brain works hard—even when you don’t realize it—is the first step towards giving it the care it deserves. That might mean rest. It might mean therapy or medication to help you find balance. It might just mean giving yourself credit for the things no one else can see.\n", + "\n", + "\n", + "So if your mind feels tired, believe it. You’re not lazy. You’re human. And you’ve probably done a lot more than you think.\n", + "\"\"\"\n", + "\n", + "# Step 2: Make the messages list\n", + "\n", + "AIInputMessages = [\n", + " {\"role\": \"system\", \"content\": system_prompt},\n", + " {\"role\": \"user\", \"content\": user_prompt}\n", + "] # fill this in\n", + "\n", + "# Step 3: Call OpenAI\n", + "openAI = OpenAI()\n", + "\n", + "response = openAI.chat.completions.create(\n", + " model=\"gpt-4o-mini\",\n", + " messages = AIInputMessages\n", + ")\n", + "\n", + "responseString = response.choices[0].message.content\n", + "# Step 4: print the result\n", + "\n", + "print(\"Printing....\")\n", + "print(responseString)\n", + "\n", + "print(\"\\n\")\n", + "print(\"Displaying....\")\n", + "display(responseString)\n", + "\n", + "print(\"\\n\")\n", + "print(\"Displaying Markdown....\")\n", + "display(Markdown(responseString))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0f8cc568-428d-4ff3-988d-6a31c35db5ba", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.13" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}