Files
LLM_Engineering_OLD/week1/community-contributions/day1-financial-analyst.ipynb
2025-09-10 07:29:41 +01:00

70 lines
3.0 KiB
Plaintext

{
"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
}