Browse Source

Update day 1 to include the exercise to suggest email subject line.

pull/52/head
Madhul Sachdeva 5 months ago
parent
commit
dc457dab4d
  1. 44
      week1/day1.ipynb

44
week1/day1.ipynb

@ -3,7 +3,13 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "d15d8294-3328-4e07-ad16-8a03e9bbfdb9", "id": "d15d8294-3328-4e07-ad16-8a03e9bbfdb9",
"metadata": {}, "metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [ "source": [
"# Instant Gratification\n", "# Instant Gratification\n",
"\n", "\n",
@ -213,7 +219,7 @@
"source": [ "source": [
"# Let's try one out. Change the website and add print statements to follow along.\n", "# Let's try one out. Change the website and add print statements to follow along.\n",
"\n", "\n",
"ed = Website(\"https://edwarddonner.com\")\n", "ed = Website(\"https://technicallysimple.me/\")\n",
"print(ed.title)\n", "print(ed.title)\n",
"print(ed.text)" "print(ed.text)"
] ]
@ -392,7 +398,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"summarize(\"https://edwarddonner.com\")" "summarize(\"https://technicallysimple.me\")"
] ]
}, },
{ {
@ -416,7 +422,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"display_summary(\"https://edwarddonner.com\")" "display_summary(\"https://technicallysimple.me\")"
] ]
}, },
{ {
@ -442,7 +448,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"display_summary(\"https://cnn.com\")" "display_summary(\"https://woodleighwatersdentalsurgery.com.au\")"
] ]
}, },
{ {
@ -452,7 +458,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"display_summary(\"https://anthropic.com\")" "display_summary(\"https://amazon.com\")"
] ]
}, },
{ {
@ -496,23 +502,31 @@
"source": [ "source": [
"# Step 1: Create your prompts\n", "# Step 1: Create your prompts\n",
"\n", "\n",
"system_prompt = \"something here\"\n", "#Import get pass to revire the contents as a hidden input field\n",
"user_prompt = \"\"\"\n", "from getpass import getpass as secret\n",
" Lots of text\n",
" Can be pasted here\n",
"\"\"\"\n",
"\n", "\n",
"# Step 2: Make the messages list\n", "system_prompt = \"You are a professional technical writer that is tasked with reviewing the contents of emails \\\n",
"and provide appropriate and impactful subject line for the email, ignoring and personal identifable infromation and text that might be a signature or navigation related. \\\n",
"Respond in markdown.\"\n",
"\n",
"# Read email body as input from user:\n",
"email_body = secret(\"Please enter contents of the email to be analysed: \\n\")\n",
"\n", "\n",
"messages = [] # fill this in\n", "user_prompt = str({email_body})\n",
"\n", "\n",
"# Step 2: Make the messages list\n",
"messages = [\n",
" {\"role\": \"system\", \"content\": system_prompt},\n",
" {\"role\": \"user\", \"content\": user_prompt}\n",
"]\n",
"# Step 3: Call OpenAI\n", "# Step 3: Call OpenAI\n",
"\n", "\n",
"response =\n", "response = openai.chat.completions.create(model=\"gpt-4o-mini\", messages=messages)\n",
"\n", "\n",
"# Step 4: print the result\n", "# Step 4: print the result\n",
"\n", "\n",
"print(" "print(response.choices[0].message.content)\n",
"#display(Markdown(response.choices[0].message.content))"
] ]
}, },
{ {

Loading…
Cancel
Save