Browse Source

week 2 changes

pull/34/head
MuhammedDele 5 months ago
parent
commit
c86856f02c
  1. 4
      week1/day1.ipynb
  2. 6
      week2/day1.ipynb
  3. 288
      week2/day2.ipynb

4
week1/day1.ipynb

@ -478,7 +478,7 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3 (ipykernel)", "display_name": "llms",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },
@ -492,7 +492,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.11.4" "version": "3.11.10"
} }
}, },
"nbformat": 4, "nbformat": 4,

6
week2/day1.ipynb

@ -82,7 +82,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 1,
"id": "de23bb9e-37c5-4377-9a82-d7b6c648eeb6", "id": "de23bb9e-37c5-4377-9a82-d7b6c648eeb6",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -602,7 +602,7 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3 (ipykernel)", "display_name": "llms",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },
@ -616,7 +616,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.11.11" "version": "3.11.10"
} }
}, },
"nbformat": 4, "nbformat": 4,

288
week2/day2.ipynb

@ -16,7 +16,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 1,
"id": "c44c5494-950d-4d2f-8d4f-b87b57c5b330", "id": "c44c5494-950d-4d2f-8d4f-b87b57c5b330",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -35,7 +35,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 2,
"id": "d1715421-cead-400b-99af-986388a97aff", "id": "d1715421-cead-400b-99af-986388a97aff",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -45,10 +45,20 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 3,
"id": "337d5dfc-0181-4e3b-8ab9-e78e0c3f657b", "id": "337d5dfc-0181-4e3b-8ab9-e78e0c3f657b",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"OpenAI API Key exists and begins sk-proj-\n",
"Anthropic API Key not set\n",
"Google API Key not set\n"
]
}
],
"source": [ "source": [
"# Load environment variables in a file called .env\n", "# Load environment variables in a file called .env\n",
"# Print the key prefixes to help with any debugging\n", "# Print the key prefixes to help with any debugging\n",
@ -76,7 +86,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 4,
"id": "22586021-1795-4929-8079-63f5bb4edd4c", "id": "22586021-1795-4929-8079-63f5bb4edd4c",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -85,14 +95,14 @@
"\n", "\n",
"openai = OpenAI()\n", "openai = OpenAI()\n",
"\n", "\n",
"claude = anthropic.Anthropic()\n", "# claude = anthropic.Anthropic()\n",
"\n", "\n",
"google.generativeai.configure()" "# google.generativeai.configure()"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 5,
"id": "b16e6021-6dc4-4397-985a-6679d6c8ffd5", "id": "b16e6021-6dc4-4397-985a-6679d6c8ffd5",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -104,7 +114,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 6,
"id": "02ef9b69-ef31-427d-86d0-b8c799e1c1b1", "id": "02ef9b69-ef31-427d-86d0-b8c799e1c1b1",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -125,10 +135,21 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 7,
"id": "aef7d314-2b13-436b-b02d-8de3b72b193f", "id": "aef7d314-2b13-436b-b02d-8de3b72b193f",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/plain": [
"\"Today's date is October 1, 2023.\""
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"message_gpt(\"What is today's date?\")" "message_gpt(\"What is today's date?\")"
] ]
@ -143,7 +164,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 8,
"id": "bc664b7a-c01d-4fea-a1de-ae22cdd5141a", "id": "bc664b7a-c01d-4fea-a1de-ae22cdd5141a",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -157,20 +178,68 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 9,
"id": "083ea451-d3a0-4d13-b599-93ed49b975e4", "id": "083ea451-d3a0-4d13-b599-93ed49b975e4",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Shout has been called with input hello\n"
]
},
{
"data": {
"text/plain": [
"'HELLO'"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"shout(\"hello\")" "shout(\"hello\")"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 10,
"id": "08f1f15a-122e-4502-b112-6ee2817dda32", "id": "08f1f15a-122e-4502-b112-6ee2817dda32",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7860\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7860/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"# The simplicty of gradio. This might appear in \"light mode\" - I'll show you how to make this in dark mode later.\n", "# The simplicty of gradio. This might appear in \"light mode\" - I'll show you how to make this in dark mode later.\n",
"\n", "\n",
@ -179,10 +248,48 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 11,
"id": "c9a359a4-685c-4c99-891c-bb4d1cb7f426", "id": "c9a359a4-685c-4c99-891c-bb4d1cb7f426",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7861\n",
"* Running on public URL: https://2446dac02d10f0eeb6.gradio.live\n",
"\n",
"This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from the terminal in the working directory to deploy to Hugging Face Spaces (https://huggingface.co/spaces)\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"https://2446dac02d10f0eeb6.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Shout has been called with input karam\n"
]
}
],
"source": [ "source": [
"# Adding share=True means that it can be accessed publically\n", "# Adding share=True means that it can be accessed publically\n",
"# A more permanent hosting is available using a platform called Spaces from HuggingFace, which we will touch on next week\n", "# A more permanent hosting is available using a platform called Spaces from HuggingFace, which we will touch on next week\n",
@ -193,10 +300,40 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 17,
"id": "cd87533a-ff3a-4188-8998-5bedd5ba2da3", "id": "cd87533a-ff3a-4188-8998-5bedd5ba2da3",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7865\n",
"\n",
"Could not create share link. Please check your internet connection or our status page: https://status.gradio.app.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7865/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"# Adding inbrowser=True opens up a new browser window automatically\n", "# Adding inbrowser=True opens up a new browser window automatically\n",
"\n", "\n",
@ -254,10 +391,40 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 12,
"id": "f235288e-63a2-4341-935b-1441f9be969b", "id": "f235288e-63a2-4341-935b-1441f9be969b",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7862\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7862/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"# And now - changing the function from \"shout\" to \"message_gpt\"\n", "# And now - changing the function from \"shout\" to \"message_gpt\"\n",
"\n", "\n",
@ -272,10 +439,40 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 13,
"id": "af9a3262-e626-4e4b-80b0-aca152405e63", "id": "af9a3262-e626-4e4b-80b0-aca152405e63",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7863\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7863/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"# Let's use Markdown\n", "# Let's use Markdown\n",
"# Are you wondering why it makes any difference to set system_message when it's not referred to in the code below it?\n", "# Are you wondering why it makes any difference to set system_message when it's not referred to in the code below it?\n",
@ -295,7 +492,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 14,
"id": "88c04ebf-0671-4fea-95c9-bc1565d4bb4f", "id": "88c04ebf-0671-4fea-95c9-bc1565d4bb4f",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -322,10 +519,41 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 15,
"id": "0bb1f789-ff11-4cba-ac67-11b815e29d09", "id": "0bb1f789-ff11-4cba-ac67-11b815e29d09",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7864\n",
"* Running on public URL: https://8d928a85414ef00ff6.gradio.live\n",
"\n",
"This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from the terminal in the working directory to deploy to Hugging Face Spaces (https://huggingface.co/spaces)\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"https://8d928a85414ef00ff6.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"view = gr.Interface(\n", "view = gr.Interface(\n",
" fn=stream_gpt,\n", " fn=stream_gpt,\n",
@ -333,7 +561,7 @@
" outputs=[gr.Markdown(label=\"Response:\")],\n", " outputs=[gr.Markdown(label=\"Response:\")],\n",
" flagging_mode=\"never\"\n", " flagging_mode=\"never\"\n",
")\n", ")\n",
"view.launch()" "view.launch(share=True)"
] ]
}, },
{ {
@ -552,7 +780,7 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3 (ipykernel)", "display_name": "venv",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },
@ -566,7 +794,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.11.11" "version": "3.11.4"
} }
}, },
"nbformat": 4, "nbformat": 4,

Loading…
Cancel
Save