Revert "Week 2 Learnings (#2)" (#5)

This reverts commit a63143df82.
This commit is contained in:
Stephen Muthama
2025-10-23 13:46:18 +03:00
committed by GitHub
parent 45e35425a9
commit e82c606080
6 changed files with 167 additions and 1845 deletions

View File

@@ -12,7 +12,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "8b50bbe2-c0b1-49c3-9a5c-1ba7efa2bcb4",
"metadata": {},
"outputs": [],
@@ -26,18 +26,10 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "747e8786-9da8-4342-b6c9-f5f69c2e22ae",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"OpenAI API Key exists and begins sk-proj-\n"
]
}
],
"outputs": [],
"source": [
"# Initialization\n",
"\n",
@@ -60,7 +52,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "0a521d84-d07c-49ab-a0df-d6451499ed97",
"metadata": {},
"outputs": [],
@@ -74,39 +66,10 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "61a2a15d-b559-4844-b377-6bd5cb4949f6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7866\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": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"def chat(message, history):\n",
" history = [{\"role\":h[\"role\"], \"content\":h[\"content\"]} for h in history]\n",
@@ -135,7 +98,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "0696acb1-0b05-4dc2-80d5-771be04f1fb2",
"metadata": {},
"outputs": [],
@@ -152,35 +115,17 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "80ca4e09-6287-4d3f-997d-fa6afbcf6c85",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Tool called for city London\n"
]
},
{
"data": {
"text/plain": [
"'The price of a ticket to London is $799'"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"get_ticket_price(\"London\")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "4afceded-7178-4c05-8fa6-9f2085e6a344",
"metadata": {},
"outputs": [],
@@ -206,7 +151,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "bdca8679-935f-4e7f-97e6-e71a4d4f228c",
"metadata": {},
"outputs": [],
@@ -218,28 +163,10 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"id": "818b4b2b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'type': 'function',\n",
" 'function': {'name': 'get_ticket_price',\n",
" 'description': 'Get the price of a return ticket to the destination city.',\n",
" 'parameters': {'type': 'object',\n",
" 'properties': {'destination_city': {'type': 'string',\n",
" 'description': 'The city that the customer wants to travel to'}},\n",
" 'required': ['destination_city'],\n",
" 'additionalProperties': False}}}]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"tools"
]
@@ -260,7 +187,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"id": "ce9b0744-9c78-408d-b9df-9f6fd9ed78cf",
"metadata": {},
"outputs": [],
@@ -282,7 +209,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"id": "b0992986-ea09-4912-a076-8e5603ee631f",
"metadata": {},
"outputs": [],
@@ -305,46 +232,10 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"id": "f4be8a71-b19e-4c2f-80df-f59ff2661f14",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7867\n",
"* To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7867/\" 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 called for city London\n"
]
}
],
"outputs": [],
"source": [
"gr.ChatInterface(fn=chat, type=\"messages\").launch()"
]
@@ -363,7 +254,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"id": "b6f5c860",
"metadata": {},
"outputs": [],
@@ -385,7 +276,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"id": "9c46a861",
"metadata": {},
"outputs": [],
@@ -417,7 +308,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": null,
"id": "cf262abc",
"metadata": {},
"outputs": [],
@@ -439,7 +330,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"id": "47d50e70",
"metadata": {},
"outputs": [],
@@ -449,7 +340,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": null,
"id": "bb61a45d",
"metadata": {},
"outputs": [],
@@ -464,7 +355,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": null,
"id": "12c73b6a",
"metadata": {},
"outputs": [],
@@ -480,35 +371,17 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": null,
"id": "7cb2e079",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"DATABASE TOOL CALLED: Getting price for London\n"
]
},
{
"data": {
"text/plain": [
"'No price data available for this city'"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"get_ticket_price(\"London\")"
]
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": null,
"id": "46e43463",
"metadata": {},
"outputs": [],
@@ -522,7 +395,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": null,
"id": "9185228e",
"metadata": {},
"outputs": [],
@@ -534,28 +407,10 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": null,
"id": "cda459b9",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"DATABASE TOOL CALLED: Getting price for Tokyo\n"
]
},
{
"data": {
"text/plain": [
"'Ticket price to Tokyo is $1420.0'"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"get_ticket_price(\"Tokyo\")"
]
@@ -565,44 +420,7 @@
"execution_count": null,
"id": "bfbfa251",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7868\n",
"* To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7868/\" 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": 23,
"metadata": {},
"output_type": "execute_result"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"DATABASE TOOL CALLED: Getting price for London\n",
"DATABASE TOOL CALLED: Getting price for tokyo\n"
]
}
],
"outputs": [],
"source": [
"gr.ChatInterface(fn=chat, type=\"messages\").launch()"
]
@@ -652,7 +470,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.12"
"version": "3.12.9"
}
},
"nbformat": 4,