Browse Source

Week 2 Anatomy AI Tutor

pull/61/head
Yifan Wei 5 months ago
parent
commit
49dded60ef
  1. 2
      week1/day1.ipynb
  2. 2
      week1/troubleshooting.ipynb
  3. 137
      week1/week1 EXERCISE.ipynb
  4. 606
      week2/day1.ipynb
  5. 539
      week2/day2.ipynb
  6. 188
      week2/day3.ipynb
  7. 123
      week2/day4.ipynb
  8. 286
      week2/day5.ipynb
  9. 937
      week2/week2 Excercise.ipynb

2
week1/day1.ipynb

@ -802,7 +802,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.12.7" "version": "3.11.11"
} }
}, },
"nbformat": 4, "nbformat": 4,

2
week1/troubleshooting.ipynb

@ -365,7 +365,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.12.7" "version": "3.11.11"
} }
}, },
"nbformat": 4, "nbformat": 4,

137
week1/week1 EXERCISE.ipynb

@ -830,6 +830,143 @@
"create_translate_page(\"Learning Notebook: National Cancer Institute - Anatomy & Physiology\", content_page_to_be_translate)" "create_translate_page(\"Learning Notebook: National Cancer Institute - Anatomy & Physiology\", content_page_to_be_translate)"
] ]
}, },
{
"cell_type": "markdown",
"id": "11ea28ae-da40-4dc6-b798-58dc469dddd7",
"metadata": {},
"source": [
"## Add Gradio UI"
]
},
{
"cell_type": "code",
"execution_count": 197,
"id": "2e5ea0f5-8b5a-401e-b4a7-571a9cb33644",
"metadata": {},
"outputs": [],
"source": [
"import gradio as gr"
]
},
{
"cell_type": "code",
"execution_count": 203,
"id": "9bf4ffee-1203-48d4-98dc-5d1a7208855d",
"metadata": {},
"outputs": [],
"source": [
"def create_learning_notebook_without_format(research_institue_name, url):\n",
" response = openai.chat.completions.create(\n",
" model=MODEL_GPT,\n",
" messages=[\n",
" {\"role\": \"system\", \"content\": system_prompt},\n",
" {\"role\": \"user\", \"content\": get_learning_notebook_user_prompt(research_institue_name, url)}\n",
" ],\n",
" )\n",
" result = response.choices[0].message.content\n",
" return result"
]
},
{
"cell_type": "code",
"execution_count": 205,
"id": "6a92e003-4c96-4301-8ec7-50d7da3ba4b7",
"metadata": {},
"outputs": [],
"source": [
"def summary_and_translate_anatomy_online_resources_stream_gpt(name, url):\n",
" messages=[\n",
" {\"role\": \"system\", \"content\": system_translation_prompt},\n",
" {\"role\": \"user\", \"content\": get_learning_notebook_translate_user_prompt(name, create_learning_notebook_without_format(name, url))}\n",
" ]\n",
" stream = openai.chat.completions.create(\n",
" model=MODEL_GPT,\n",
" messages=messages,\n",
" stream=True\n",
" )\n",
" result = \"\"\n",
" for chunk in stream:\n",
" result += chunk.choices[0].delta.content or \"\"\n",
" yield result"
]
},
{
"cell_type": "code",
"execution_count": 209,
"id": "6b40a0a1-2c08-40ac-8442-9f7367e8a4dc",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7876\n",
"* Running on public URL: https://efca7dbc932ecd5a15.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://efca7dbc932ecd5a15.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": 209,
"metadata": {},
"output_type": "execute_result"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Found links: {'links': [{'type': 'anatomy page', 'url': 'https://training.seer.cancer.gov/anatomy/'}, {'type': 'body anatomy page', 'url': 'https://training.seer.cancer.gov/anatomy/body/'}, {'type': 'functions page', 'url': 'https://training.seer.cancer.gov/anatomy/body/functions.html'}, {'type': 'terminology page', 'url': 'https://training.seer.cancer.gov/anatomy/body/terminology.html'}, {'type': 'review page', 'url': 'https://training.seer.cancer.gov/anatomy/body/review.html'}, {'type': 'cells, tissues, membranes page', 'url': 'https://training.seer.cancer.gov/anatomy/cells_tissues_membranes/'}, {'type': 'skeletal system page', 'url': 'https://training.seer.cancer.gov/anatomy/skeletal/'}, {'type': 'muscular system page', 'url': 'https://training.seer.cancer.gov/anatomy/muscular/'}, {'type': 'nervous system page', 'url': 'https://training.seer.cancer.gov/anatomy/nervous/'}, {'type': 'endocrine system page', 'url': 'https://training.seer.cancer.gov/anatomy/endocrine/'}, {'type': 'cardiovascular system page', 'url': 'https://training.seer.cancer.gov/anatomy/cardiovascular/'}, {'type': 'lymphatic system page', 'url': 'https://training.seer.cancer.gov/anatomy/lymphatic/'}, {'type': 'respiratory system page', 'url': 'https://training.seer.cancer.gov/anatomy/respiratory/'}, {'type': 'digestive system page', 'url': 'https://training.seer.cancer.gov/anatomy/digestive/'}, {'type': 'urinary system page', 'url': 'https://training.seer.cancer.gov/anatomy/urinary/'}, {'type': 'reproductive system page', 'url': 'https://training.seer.cancer.gov/anatomy/reproductive/'}]}\n"
]
}
],
"source": [
"view = gr.Interface(\n",
" fn=summary_and_translate_anatomy_online_resources_stream_gpt,\n",
" inputs=[\n",
" gr.Textbox(label=\"Anatomy Online Resource:\"),\n",
" gr.Textbox(label=\"Anatomy Online resource page URL including http:// or https://\")],\n",
" outputs=[gr.Markdown(label=\"Anatomy Summary & Translation:\")],\n",
" flagging_mode=\"never\"\n",
")\n",
"view.launch(share=True)"
]
},
{
"cell_type": "code",
"execution_count": 206,
"id": "83c7cbf0-40a4-4edb-a678-8cb76390cc0a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<generator object summary_and_translate_anatomy_online_resources_stream_gpt at 0x12f55e200>"
]
},
"execution_count": 206,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"summary_and_translate_anatomy_online_resources_stream_gpt(\"Learning Notebook: National Cancer Institute - Anatomy & Physiology\", \"https://training.seer.cancer.gov/anatomy/body/terminology.html\")"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "57b8b1cd-5018-46d8-8159-d87ce04b246c", "id": "57b8b1cd-5018-46d8-8159-d87ce04b246c",

606
week2/day1.ipynb

File diff suppressed because one or more lines are too long

539
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 exists and begins sk-ant-\n",
"Google API Key exists and begins AIzaSyBw\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": [],
@ -92,7 +102,7 @@
}, },
{ {
"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 22, 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": 9,
"id": "bc664b7a-c01d-4fea-a1de-ae22cdd5141a", "id": "bc664b7a-c01d-4fea-a1de-ae22cdd5141a",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -157,32 +178,128 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 10,
"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": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"shout(\"hello\")" "shout(\"hello\")"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 12,
"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:7861\n",
"* Running on public URL: https://ffdaeb77f01dfb1ef4.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://ffdaeb77f01dfb1ef4.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": 12,
"metadata": {},
"output_type": "execute_result"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Shout has been called with input sports science\n",
"Shout has been called with input medical school\n"
]
}
],
"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",
"gr.Interface(fn=shout, inputs=\"textbox\", outputs=\"textbox\").launch()" "gr.Interface(fn=shout, inputs=\"textbox\", outputs=\"textbox\").launch(share=True)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 13,
"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:7862\n",
"* Running on public URL: https://ffa17661a0b7475b95.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://ffa17661a0b7475b95.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": 13,
"metadata": {},
"output_type": "execute_result"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Shout has been called with input I love myself\n",
"Shout has been called with input I trust myself\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 +310,48 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 14,
"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: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": 14,
"metadata": {},
"output_type": "execute_result"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Shout has been called with input growth\n",
"Shout has been called with input muscle grow\n"
]
}
],
"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",
@ -215,10 +370,40 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 15,
"id": "e8129afa-532b-4b15-b93c-aa9cca23a546", "id": "e8129afa-532b-4b15-b93c-aa9cca23a546",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7864\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7864/\" 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": [
"# Define this variable and then pass js=force_dark_mode when creating the Interface\n", "# Define this variable and then pass js=force_dark_mode when creating the Interface\n",
"\n", "\n",
@ -236,10 +421,40 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 16,
"id": "3cc67b26-dd5f-406d-88f6-2306ee2950c0", "id": "3cc67b26-dd5f-406d-88f6-2306ee2950c0",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7865\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\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": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"# Inputs and Outputs\n", "# Inputs and Outputs\n",
"\n", "\n",
@ -254,10 +469,40 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 17,
"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:7866\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7866/\" 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": [
"# And now - changing the function from \"shout\" to \"message_gpt\"\n", "# And now - changing the function from \"shout\" to \"message_gpt\"\n",
"\n", "\n",
@ -270,12 +515,77 @@
"view.launch()" "view.launch()"
] ]
}, },
{
"cell_type": "markdown",
"id": "79943e09-9b02-4228-9884-7ad031138b6d",
"metadata": {},
"source": [
"Prompt: who is the most prestigious scientist in sport science at UT Austin?\n",
"Give me a list of professor names, their research interests and their current work.\n",
"\n",
"Response: As of my last update in October 2023, I don't have access to real-time databases or specific personnel lists at universities, including the University of Texas at Austin (UT Austin). However, I can provide an overview of prominent figures in the field of sport science at UT Austin based on known faculty and their general research interests. For the most updated information, I recommend checking the university's official website or the specific department's faculty page.\n",
"\n",
"Here are a few notable faculty members who have had significant contributions in sport science at UT Austin:\n",
"\n",
"1. **Dr. Darin A. C. J. R. H. McGowan**\n",
" - **Research Interests**: Exercise physiology, biomechanics, and the effects of exercise on mental health.\n",
" - **Current Work**: Investigating how different types of exercise impact cognitive functioning, especially in different populations.\n",
"\n",
"2. **Dr. Brian S. H. McAuley**\n",
" - **Research Interests**: Motor control and learning, postural stability, and athlete training.\n",
" - **Current Work**: Focusing on the mechanics of human movement and how training programs can be optimized for performance enhancement and injury prevention.\n",
"\n",
"3. **Dr. J. W. \"Bill\" Whiting**\n",
" - **Research Interests**: Exercise biomechanics, strength training, and injury prevention.\n",
" - **Current Work**: Studying the kinematics and kinetics of various sports movements and developing strategies to prevent athletic injuries.\n",
"\n",
"4. **Dr. David W. Stodden**\n",
" - **Research Interests**: Motor development, physical activity for children, and foundational motor skills.\n",
" - **Current Work**: Exploring how early physical education impacts lifelong sports participation and physical health in children.\n",
"\n",
"5. **Dr. Joseph L. Hornsby**\n",
" - **Research Interests**: Sport psychology, performance enhancement strategies, and motivation in sports.\n",
" - **Current Work**: Examining mental training techniques and their effectiveness in high-pressure sporting environments.\n",
"\n",
"For detailed and current information, including their specific areas of research and projects, visiting the UT Austin Department of Kinesiology and Health Education or the College of Education's website would be beneficial, as they typically provide profiles for their faculty members, including their latest research publications and ongoing work."
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 22,
"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:7869\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7869/\" 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": 22,
"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 +605,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 23,
"id": "88c04ebf-0671-4fea-95c9-bc1565d4bb4f", "id": "88c04ebf-0671-4fea-95c9-bc1565d4bb4f",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -322,10 +632,40 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 24,
"id": "0bb1f789-ff11-4cba-ac67-11b815e29d09", "id": "de689927-0d71-443d-931a-3bbaf30ca923",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7870\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7870/\" 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": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"view = gr.Interface(\n", "view = gr.Interface(\n",
" fn=stream_gpt,\n", " fn=stream_gpt,\n",
@ -336,9 +676,62 @@
"view.launch()" "view.launch()"
] ]
}, },
{
"cell_type": "markdown",
"id": "71b1eb34-7360-4096-a2cb-a88157c86e87",
"metadata": {},
"source": [
"I'm unable to create or display illustrations directly. However, I can provide a detailed description of the Krebs cycle (also known as the citric acid cycle or TCA cycle) that you can use to find or create an illustration.\n",
"\n",
"### Illustration Description of the Krebs Cycle\n",
"\n",
"1. **Starting Compound**: \n",
" - **Acetyl-CoA** (2-carbon molecule) enters the cycle.\n",
"\n",
"2. **Citrate Formation**:\n",
" - Acetyl-CoA combines with **Oxaloacetate** (4-carbon molecule) to form **Citrate** (6-carbon molecule).\n",
" \n",
"3. **Citrate Isomerization**:\n",
" - Citrate is converted into **Isocitrate**.\n",
"\n",
"4. **First Decarboxylation**:\n",
" - Isocitrate is oxidized and decarboxylated to form **α-Ketoglutarate** (5-carbon molecule) and one molecule of **NADH** and **CO₂** is released.\n",
" \n",
"5. **Second Decarboxylation**:\n",
" - α-Ketoglutarate undergoes decarboxylation to form **Succinyl-CoA** (4-carbon molecule). This step produces another molecule of **NADH** and releases another CO₂.\n",
"\n",
"6. **Conversion to Succinate**:\n",
" - Succinyl-CoA is converted to **Succinate**, which generates **GTP (or ATP)** through substrate-level phosphorylation.\n",
"\n",
"7. **Succinate Conversion**:\n",
" - Succinate is oxidized to **Fumarate**, generating **FADH₂**.\n",
"\n",
"8. **Fumarate Hydration**:\n",
" - Fumarate is converted to **Malate** by the addition of water.\n",
"\n",
"9. **Final Oxidation**:\n",
" - Malate is oxidized back to **Oxaloacetate**, producing one more **NADH**.\n",
"\n",
"10. **Return to Starting Point**:\n",
" - Oxaloacetate is ready to combine with another Acetyl-CoA, completing the cycle.\n",
"\n",
"### Energy Molecules Produced\n",
"- **3 NADH**\n",
"- **1 FADH₂**\n",
"- **1 GTP (or ATP)**\n",
"\n",
"### Diagram Elements\n",
"- Arrows should indicate the flow from one compound to another.\n",
"- Circles or ovals to represent each molecule.\n",
"- Label each molecule clearly.\n",
"- Include the enzymes that catalyze each step, if needed.\n",
"\n",
"You can use this description to create your own diagram or search for images online using keywords like \"Krebs cycle\" or \"citric acid cycle diagram\". Websites like educational platforms, textbooks, or online biology resources will likely have detailed illustrations of the Krebs cycle."
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 25,
"id": "bbc8e930-ba2a-4194-8f7c-044659150626", "id": "bbc8e930-ba2a-4194-8f7c-044659150626",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -362,10 +755,40 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 26,
"id": "a0066ffd-196e-4eaf-ad1e-d492958b62af", "id": "a0066ffd-196e-4eaf-ad1e-d492958b62af",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7871\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7871/\" 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": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"view = gr.Interface(\n", "view = gr.Interface(\n",
" fn=stream_claude,\n", " fn=stream_claude,\n",
@ -401,7 +824,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 27,
"id": "0087623a-4e31-470b-b2e6-d8d16fc7bcf5", "id": "0087623a-4e31-470b-b2e6-d8d16fc7bcf5",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -418,10 +841,40 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 28,
"id": "8d8ce810-997c-4b6a-bc4f-1fc847ac8855", "id": "8d8ce810-997c-4b6a-bc4f-1fc847ac8855",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7872\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7872/\" 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": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"view = gr.Interface(\n", "view = gr.Interface(\n",
" fn=stream_model,\n", " fn=stream_model,\n",
@ -464,7 +917,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 29,
"id": "1626eb2e-eee8-4183-bda5-1591b58ae3cf", "id": "1626eb2e-eee8-4183-bda5-1591b58ae3cf",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -492,7 +945,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 30,
"id": "c701ec17-ecd5-4000-9f68-34634c8ed49d", "id": "c701ec17-ecd5-4000-9f68-34634c8ed49d",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -505,7 +958,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 31,
"id": "5def90e0-4343-4f58-9d4a-0e36e445efa4", "id": "5def90e0-4343-4f58-9d4a-0e36e445efa4",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -523,11 +976,9 @@
] ]
}, },
{ {
"cell_type": "code", "cell_type": "raw",
"execution_count": null, "id": "6b60e7df-3db5-4c2b-9c6c-9a8f16ff4cb5",
"id": "66399365-5d67-4984-9d47-93ed26c0bd3d",
"metadata": {}, "metadata": {},
"outputs": [],
"source": [ "source": [
"view = gr.Interface(\n", "view = gr.Interface(\n",
" fn=stream_brochure,\n", " fn=stream_brochure,\n",

188
week2/day3.ipynb

File diff suppressed because one or more lines are too long

123
week2/day4.ipynb

@ -12,7 +12,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 1,
"id": "8b50bbe2-c0b1-49c3-9a5c-1ba7efa2bcb4", "id": "8b50bbe2-c0b1-49c3-9a5c-1ba7efa2bcb4",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -28,10 +28,18 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 2,
"id": "747e8786-9da8-4342-b6c9-f5f69c2e22ae", "id": "747e8786-9da8-4342-b6c9-f5f69c2e22ae",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"OpenAI API Key exists and begins sk-proj-\n"
]
}
],
"source": [ "source": [
"# Initialization\n", "# Initialization\n",
"\n", "\n",
@ -54,7 +62,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 3,
"id": "0a521d84-d07c-49ab-a0df-d6451499ed97", "id": "0a521d84-d07c-49ab-a0df-d6451499ed97",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -66,10 +74,40 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 4,
"id": "61a2a15d-b559-4844-b377-6bd5cb4949f6", "id": "61a2a15d-b559-4844-b377-6bd5cb4949f6",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7881\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7881/\" 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": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"# This function looks rather simpler than the one from my video, because we're taking advantage of the latest Gradio updates\n", "# This function looks rather simpler than the one from my video, because we're taking advantage of the latest Gradio updates\n",
"\n", "\n",
@ -99,7 +137,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 5,
"id": "0696acb1-0b05-4dc2-80d5-771be04f1fb2", "id": "0696acb1-0b05-4dc2-80d5-771be04f1fb2",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -116,17 +154,35 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 6,
"id": "80ca4e09-6287-4d3f-997d-fa6afbcf6c85", "id": "80ca4e09-6287-4d3f-997d-fa6afbcf6c85",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Tool get_ticket_price called for Berlin\n"
]
},
{
"data": {
"text/plain": [
"'$499'"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"get_ticket_price(\"Berlin\")" "get_ticket_price(\"Berlin\")"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 7,
"id": "4afceded-7178-4c05-8fa6-9f2085e6a344", "id": "4afceded-7178-4c05-8fa6-9f2085e6a344",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -152,7 +208,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 8,
"id": "bdca8679-935f-4e7f-97e6-e71a4d4f228c", "id": "bdca8679-935f-4e7f-97e6-e71a4d4f228c",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -178,7 +234,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 10,
"id": "ce9b0744-9c78-408d-b9df-9f6fd9ed78cf", "id": "ce9b0744-9c78-408d-b9df-9f6fd9ed78cf",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -199,7 +255,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 11,
"id": "b0992986-ea09-4912-a076-8e5603ee631f", "id": "b0992986-ea09-4912-a076-8e5603ee631f",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -221,10 +277,47 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 12,
"id": "f4be8a71-b19e-4c2f-80df-f59ff2661f14", "id": "f4be8a71-b19e-4c2f-80df-f59ff2661f14",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7882\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7882/\" 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"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Tool get_ticket_price called for Salt Lake City\n"
]
}
],
"source": [ "source": [
"gr.ChatInterface(fn=chat, type=\"messages\").launch()" "gr.ChatInterface(fn=chat, type=\"messages\").launch()"
] ]

286
week2/day5.ipynb

File diff suppressed because one or more lines are too long

937
week2/week2 Excercise.ipynb

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save