Merge pull request #551 from leonid08/community-contributions-branch

Added my day 1 exercise - creating a subject line for an email text
This commit is contained in:
Ed Donner
2025-08-01 08:15:50 -04:00
committed by GitHub

View File

@@ -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",
" Whats 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 doesnt rest. It doesnt 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? Thats cognitive fatigue. And even if your body hasnt moved much, the exhaustion is very real.\n",
"\n",
"The brains quiet hustle\n",
"\n",
"Cognitive fatigue happens when the mental load were 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",
"Thats not just because were thinking deeply or making big decisions. Its 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 havent “done anything” if we havent physically moved or checked something off a list. But the brain doesnt lift weights to get tired. Its heavy lifting is invisible.\n",
"\n",
"The myth: Motion = accomplishment\n",
"\n",
"Theres 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 youve ever said, “Why am I so tired? I didnt 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 youre 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 isnt laziness—its repair\n",
"\n",
"This isnt meant to sound hopeless. In fact, its the opposite.\n",
"\n",
" \n",
"\n",
"Recognizing that your brain works hard—even when you dont 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. Youre not lazy. Youre human. And youve 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
}