Revert "Week 1 Learnings (#1)" (#4)

This reverts commit a9e9453e57.
This commit is contained in:
Stephen Muthama
2025-10-23 13:45:43 +03:00
committed by GitHub
parent 1e0cafd7d6
commit 45e35425a9
6 changed files with 725 additions and 1873 deletions

View File

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