Week 1 Learnings (#1)

* Add day 1
* Add day 2
* Add day 4
* Add day 5
* Add week 1 exercise
This commit is contained in:
Stephen Muthama
2025-10-22 09:58:16 +03:00
committed by GitHub
parent ef34387aee
commit a9e9453e57
6 changed files with 1873 additions and 725 deletions

View File

@@ -12,7 +12,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 2,
"id": "7dc1c1d9",
"metadata": {},
"outputs": [],
@@ -21,22 +21,22 @@
"\n",
"encoding = tiktoken.encoding_for_model(\"gpt-4.1-mini\")\n",
"\n",
"tokens = encoding.encode(\"Hi my name is Ed and I like banoffee pie\")"
"tokens = encoding.encode(\"Hi my name is Stephen\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 3,
"id": "7632966c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[12194, 922, 1308, 382, 6117, 326, 357, 1299, 9171, 26458, 5148]"
"[12194, 922, 1308, 382, 34231]"
]
},
"execution_count": 6,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
@@ -47,7 +47,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 4,
"id": "cce0c188",
"metadata": {},
"outputs": [
@@ -59,13 +59,7 @@
"922 = my\n",
"1308 = name\n",
"382 = is\n",
"6117 = Ed\n",
"326 = and\n",
"357 = I\n",
"1299 = like\n",
"9171 = ban\n",
"26458 = offee\n",
"5148 = pie\n"
"34231 = Stephen\n"
]
}
],
@@ -77,7 +71,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 5,
"id": "98e3bbd2",
"metadata": {},
"outputs": [
@@ -87,7 +81,7 @@
"' and'"
]
},
"execution_count": 8,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
@@ -110,10 +104,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"id": "83a4b3eb",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"API key found and looks good so far!\n"
]
}
],
"source": [
"import os\n",
"from dotenv import load_dotenv\n",
@@ -141,7 +143,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"id": "b959be3b",
"metadata": {},
"outputs": [],
@@ -161,23 +163,34 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"id": "97298fea",
"metadata": {},
"outputs": [],
"source": [
"messages = [\n",
" {\"role\": \"system\", \"content\": \"You are a helpful assistant\"},\n",
" {\"role\": \"user\", \"content\": \"Hi! I'm Ed!\"}\n",
" {\"role\": \"user\", \"content\": \"Hi! I'm Stephen!\"}\n",
" ]"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"id": "3475a36d",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"'Hello, Stephen! How can I assist you today?'"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"response = openai.chat.completions.create(model=\"gpt-4.1-mini\", messages=messages)\n",
"response.choices[0].message.content"
@@ -193,7 +206,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"id": "6bce2208",
"metadata": {},
"outputs": [],
@@ -206,10 +219,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"id": "404462f5",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"'Im sorry, but I dont know your name. Could you please tell me?'"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"response = openai.chat.completions.create(model=\"gpt-4.1-mini\", messages=messages)\n",
"response.choices[0].message.content"
@@ -231,25 +255,36 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"id": "b6d43f92",
"metadata": {},
"outputs": [],
"source": [
"messages = [\n",
" {\"role\": \"system\", \"content\": \"You are a helpful assistant\"},\n",
" {\"role\": \"user\", \"content\": \"Hi! I'm Ed!\"},\n",
" {\"role\": \"assistant\", \"content\": \"Hi Ed! How can I assist you today?\"},\n",
" {\"role\": \"user\", \"content\": \"Hi! I'm Stephen!\"},\n",
" {\"role\": \"assistant\", \"content\": \"Hi Stephen! How can I assist you today?\"},\n",
" {\"role\": \"user\", \"content\": \"What's my name?\"}\n",
" ]"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"id": "e7ac742c",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"'Your name is Stephen. How can I help you today, Stephen?'"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"response = openai.chat.completions.create(model=\"gpt-4.1-mini\", messages=messages)\n",
"response.choices[0].message.content"
@@ -295,7 +330,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.9"
"version": "3.12.12"
}
},
"nbformat": 4,