AI Chatbot and Personal Story Writer

AI Chatbot and Personal Story Writer
This commit is contained in:
arunabeshc
2025-04-06 21:48:44 +05:30
parent 0fc1ff6f58
commit 64c1acf9b8
2 changed files with 178 additions and 59 deletions

View File

@@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "a07e7793-b8f5-44f4-aded-5562f633271a",
"metadata": {},
"outputs": [],
@@ -43,10 +43,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "717ea9d4-1e72-4035-b7c5-5d61da5b8ea3",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"OpenAI API Key exists and begins sk-proj-\n"
]
}
],
"source": [
"# Initialization\n",
"\n",
@@ -67,7 +75,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"id": "cc78f4fd-9920-4872-9117-90cd2aeb2a06",
"metadata": {},
"outputs": [],
@@ -79,7 +87,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "b2701cc0-6403-4880-9b31-e6e39e89feb4",
"metadata": {},
"outputs": [],
@@ -96,7 +104,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"id": "5e33902f-c2c3-4fb0-b01d-a346a4dff811",
"metadata": {},
"outputs": [],
@@ -106,7 +114,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"id": "27dfca47-2a38-49f3-8905-f583d98710a5",
"metadata": {},
"outputs": [],
@@ -120,7 +128,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"id": "6ae7371b-031e-47d7-afaf-42d6758ccd92",
"metadata": {},
"outputs": [],
@@ -134,7 +142,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"id": "c919b13a-50b6-4510-8e9d-02cdfd95cb98",
"metadata": {},
"outputs": [],
@@ -157,7 +165,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"id": "d2628781-6f5e-4ac1-bbe3-2e08aa0aae0d",
"metadata": {},
"outputs": [],
@@ -191,7 +199,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"id": "480de296-4a36-4ec4-a5f6-149fc198c7a8",
"metadata": {},
"outputs": [],
@@ -200,7 +208,7 @@
"\n",
"price_function = {\n",
" \"name\": \"get_ticket_price\",\n",
" \"description\": \"Get the price of a return ticket to the destination city. Call this whenever you need to know the ticket price, for example when a customer asks 'How much is a ticket to this city'\",\n",
" \"description\": \"Get the price of a one_way ticket to the destination city. Call this whenever you need to know the ticket price, for example when a customer asks 'How much is a ticket to this city'\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
@@ -217,7 +225,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"id": "cf1b3e35-08ee-478e-aa1c-534418d78daf",
"metadata": {},
"outputs": [],
@@ -241,7 +249,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"id": "73e4c8a2-c034-41a4-9b97-7b2aa4aca504",
"metadata": {},
"outputs": [],
@@ -266,7 +274,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"id": "1d5d74a0-9c25-46a4-84ee-1f700bd55fa7",
"metadata": {},
"outputs": [],
@@ -281,7 +289,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"id": "fa18f535-f8a7-4386-b39a-df0f84d23406",
"metadata": {},
"outputs": [],
@@ -318,7 +326,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"id": "b588d711-5f20-4a3a-9422-81a1fda8d5b0",
"metadata": {},
"outputs": [],
@@ -360,7 +368,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 16,
"id": "e74eee70-f89e-4c03-922c-74f9ab567a4c",
"metadata": {},
"outputs": [],
@@ -413,7 +421,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 17,
"id": "b8f25812-2609-4e26-b929-9cee2d1e4467",
"metadata": {},
"outputs": [],
@@ -440,7 +448,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 18,
"id": "1728e70b-596c-4048-8c02-ac3c26756470",
"metadata": {},
"outputs": [],
@@ -503,7 +511,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 19,
"id": "a2547bb0-43a5-4b1d-8b9a-95da15a11040",
"metadata": {},
"outputs": [],
@@ -519,7 +527,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 20,
"id": "23b102a4-e544-4560-acc8-a15620478582",
"metadata": {},
"outputs": [],
@@ -556,10 +564,40 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 21,
"id": "133904cf-4d72-4552-84a8-76650f334857",
"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": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with gr.Blocks() as ui:\n",
" with gr.Row():\n",
@@ -598,10 +636,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 22,
"id": "dc4a3844-194c-4af7-8ca8-2fc4edb74c11",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'london': '20', 'paris': '90', 'tokyo': '100', 'berlin': '2'}\n"
]
}
],
"source": [
"print(ticket_availability)"
]