From 05ce428f51da4e1a4d5761d82774a0f2ec661a72 Mon Sep 17 00:00:00 2001 From: Shiv Konar Date: Wed, 10 Sep 2025 07:29:41 +0100 Subject: [PATCH 1/2] adding new day 1 exercise --- .../day1-financial-analyst.ipynb | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 week1/community-contributions/day1-financial-analyst.ipynb diff --git a/week1/community-contributions/day1-financial-analyst.ipynb b/week1/community-contributions/day1-financial-analyst.ipynb new file mode 100644 index 0000000..0889b1f --- /dev/null +++ b/week1/community-contributions/day1-financial-analyst.ipynb @@ -0,0 +1,69 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "89fd124d-5e7b-4e61-af85-2fe978c688f2", + "metadata": {}, + "outputs": [], + "source": [ + "system_prompt = \"You are an analyst that analyzes the financial transactions data and provides summary of where the money has been spent, where money can be cut back so savings be increased\"\n", + "user_prompt = \"\"\"\n", + " data = [\n", + " {\"transaction_id\": 1, \"date\": \"2025-01-05\", \"merchant\": \"Amazon\", \"category\": \"Shopping\", \"amount\": -120.50, \"currency\": \"GBP\"},\n", + " {\"transaction_id\": 2, \"date\": \"2025-01-07\", \"merchant\": \"Starbucks\", \"category\": \"Food & Drink\", \"amount\": -4.75, \"currency\": \"GBP\"},\n", + " {\"transaction_id\": 3, \"date\": \"2025-01-09\", \"merchant\": \"Tesco\", \"category\": \"Groceries\", \"amount\": -56.20, \"currency\": \"GBP\"},\n", + " {\"transaction_id\": 4, \"date\": \"2025-01-10\", \"merchant\": \"Uber\", \"category\": \"Transport\", \"amount\": -15.80, \"currency\": \"GBP\"},\n", + " {\"transaction_id\": 5, \"date\": \"2025-01-15\", \"merchant\": \"Apple\", \"category\": \"Electronics\", \"amount\": -899.00, \"currency\": \"GBP\"},\n", + " {\"transaction_id\": 6, \"date\": \"2025-01-18\", \"merchant\": \"Netflix\", \"category\": \"Subscription\", \"amount\": -9.99, \"currency\": \"GBP\"},\n", + " {\"transaction_id\": 7, \"date\": \"2025-01-20\", \"merchant\": \"Salary\", \"category\": \"Income\", \"amount\": 2500.00, \"currency\": \"GBP\"},\n", + " {\"transaction_id\": 8, \"date\": \"2025-01-22\", \"merchant\": \"British Airways\", \"category\": \"Travel\", \"amount\": -450.00, \"currency\": \"GBP\"},\n", + " {\"transaction_id\": 9, \"date\": \"2025-01-25\", \"merchant\": \"Marks & Spencer\", \"category\": \"Shopping\", \"amount\": -75.30, \"currency\": \"GBP\"},\n", + " {\"transaction_id\": 10, \"date\": \"2025-01-30\", \"merchant\": \"HMRC\", \"category\": \"Tax\", \"amount\": -320.00, \"currency\": \"GBP\"},\n", + "]\n", + "\n", + "\n", + "\"\"\"\n", + "\n", + "# Step 2: Make the messages list\n", + "\n", + "messages = [\n", + " {\"role\": \"system\", \"content\": system_prompt},\n", + " {\"role\": \"user\", \"content\": user_prompt}\n", + "] # fill this in\n", + "\n", + "# Step 3: Call OpenAI\n", + "\n", + "response = openai.chat.completions.create(\n", + " model = \"gpt-4o-mini\",\n", + " messages = messages\n", + " )\n", + "\n", + "# Step 4: print the result\n", + "\n", + "display(Markdown(response.choices[0].message.content))" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.13" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 5a0c3ad064431602fcad825939dbd7095a01b4c1 Mon Sep 17 00:00:00 2001 From: Shiv Konar Date: Wed, 10 Sep 2025 08:01:22 +0100 Subject: [PATCH 2/2] updating financial analyst code --- .../day1-financial-analyst.ipynb | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/week1/community-contributions/day1-financial-analyst.ipynb b/week1/community-contributions/day1-financial-analyst.ipynb index 0889b1f..dd00477 100644 --- a/week1/community-contributions/day1-financial-analyst.ipynb +++ b/week1/community-contributions/day1-financial-analyst.ipynb @@ -1,5 +1,26 @@ { "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "4a9842d0-2465-4c0a-9f08-3c23f4202c3a", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "from dotenv import load_dotenv\n", + "from IPython.display import Markdown, display\n", + "from openai import OpenAI" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7fcfe08c-d074-41f5-befe-24358c967e1b", + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, @@ -43,6 +64,22 @@ "\n", "display(Markdown(response.choices[0].message.content))" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "12d6642e-a4d4-49c7-a14b-8c8200dd210c", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d5fccacf-ddb4-4076-87cc-0ffe6a4d64a4", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": {