Skip to content

Repository files navigation

GLaDOS

GLaDOS is an automated financial assistant that uses Gemini AI and SQLite to process expense messages from Telegram and answer financial questions.

GLaDOS preview on Telegram

How it works

  1. Message Classification (entry-or-question?)

Determines if a message is:

  • An expense entry (e.g., "Paid 50 at the grocery store")
  • A financial query (e.g., "How much did I spend this month?")
  1. Expense Structuring (for new expense entries) (structured-expense)

It converts natural language text into a structured JSON to be inserted into the database, adhering to the schema and helping classifying the category and type.

Spent 120 on groceries today using a credit card.

Generated JSON:

{
  "amount": 120.00,
  "description": "groceries",
  "type": "credit_card",
  "category": "market",
  "date": "2025-03-08"
}
  1. Query Generation (for financial questions) (querier)

Converts user questions into SQLite queries based on the expenses table schema.

Which day did I spend the most money?

Generated SQL:

SELECT date, SUM(amount) AS total_spent
FROM expenses
WHERE date LIKE substr(date('now', '-3 hours'), 1, 7) || '%'
GROUP BY date
ORDER BY total_spent DESC
LIMIT 1;
  1. Humanized Responses (humanize)

It combines the question, database schema, query, additional prompt instructions, database response, and returns a humanized message to the user.

The day you spent the most money was 03/08/2025, with a total of R$1469.31.

Setup

  1. Make sure you have sqlite installed:
$ sudo apt install sqlite3    # Linux
$ brew install sqlite3        # MacOs
  1. Clone the repository:
$ git clone https://github.com/lucianocarvalho/glados.git
$ cd glados
  1. Make sure you set the right env values .env:
$ cp .env.example .env
TELEGRAM_TOKEN=foobar
TELEGRAM_CHAT_ID=foobar
GEMINI_API_URL=foobar
GEMINI_API_KEY=foobar
  1. Run the following commands to create the database and table:
$ mkdir sqlite
$ sqlite3 sqlite/glados.db "
CREATE TABLE IF NOT EXISTS expenses (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    date TEXT NOT NULL,
    amount REAL NOT NULL,
    category TEXT NOT NULL,
    description TEXT NOT NULL,
    type TEXT NOT NULL
);"

To verify that the table was created successfully, run:

sqlite3 sqlite/glados.db "PRAGMA table_info(expenses);"
  1. Build and run:
# Build the Docker image
docker build -t glados .

# Run the container
docker run -it --rm -p 3000:3000 -v ./sqlite:/app/sqlite/ --env-file .env --name glados glados

# Alternatively, use Docker Compose
docker-compose up -d

Running locally:

lein deps
lein run
lein test

About

GLaDOS is an AI-powered financial assistant that processes expense messages from Telegram, categorizes them, and stores data in SQLite. It also supports natural language queries to retrieve financial insights.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages