Skip to content
All projects

Personal Finance Chatbot

GPT-4o chatbot that answers plain-English questions about bank accounts, spending, and recurring bills.

Role
AI / Backend Developer
Timeframe
June 2024
Stack
  • Python
  • LangChain
  • OpenAI GPT-4o
  • ChromaDB
  • OpenAI Embeddings

Problem

The goal was a chat assistant that answers questions about a person’s finances: account balances, individual transactions, and recurring income and bills. The data arrives as nested JSON exports, not as rows in a database. The hard part is accuracy. A finance answer with a made-up amount or merchant is worse than no answer, and questions like “how much did I spend on food” need every transaction, not just the few that look similar to the question.

Architecture

The assistant is a Python command-line chat loop. On start, a loader reads every JSON file in a data folder and merges them into one context keyed by file name. Each question goes through a LangChain prompt chain that combines the full data with the question and sends it to OpenAI GPT-4o at temperature 0. A LangChain OpenAI callback wraps each turn and records prompt tokens, completion tokens, and cost. The first version retrieved context from a Chroma vector store instead; the final version sends the full data.

  1. App loads every JSON file in the folder into one context
  2. User types a question in the terminal chat loop
  3. LangChain builds the prompt, GPT-4o answers from the data
  4. Callback records tokens and cost for the question

What I built

  • Built the chat assistant in Python with LangChain and GPT-4o, answering questions over account, transaction, and recurring-payment JSON.
  • Wrote a grounded prompt: answer only from the supplied data, say “I don’t know” instead of guessing, quote dates, amounts, merchants, and categories, and total categories when asked.
  • Built the first version as a RAG pipeline on ChromaDB with OpenAI embeddings. Chroma and LangChain RAG were both early at the time, and retrieval returned partial context: answers had wrong totals, missed transactions, and frequent hallucinations.
  • Migrated from retrieval to full-context prompting, so totals and category summaries see every transaction.
  • Wrote a folder-based JSON loader, so a new export is picked up by dropping the file in the folder, with no code or schema change.
  • Added per-question token and cost tracking with LangChain’s OpenAI callback, printed after every answer.

Interactive project lab

Run a synthetic workflow

Inspect how a request moves through the system using synthetic data. Live model work, local processing, provider fallback, and deterministic simulation are labeled explicitly.

Interactive project lab

Ask a synthetic household finance export

See how full-context analysis answers bounded questions over a small financial dataset.

SIMULATED EXECUTION

Your request

Execution mode
Scenario

Result

Run a scenario to see its result.

Execution stages

Ready to run.

This reconstruction uses fictional transactions only. Do not enter real financial, personal, or confidential information. Live model requests use shared, rate-limited capacity. Provider and model metadata is shown only when a key was actually used.

Results

  • Delivered a working prototype that answers balance, transaction, and recurring-bill questions straight from raw JSON exports, with no database or ETL step.
  • Replaced the RAG pipeline after comparing it with full-context prompting, which removed the wrong totals and missed transactions that retrieval caused on a small per-user dataset.
  • Made LLM cost visible per question from the first version, so the client could see what each answer costs.