Skip to main content

AI Agent Extension for Fava

Project description

favai

AI Agent Extension for Fava. favai lets you interact with your Beancount ledger through natural language — import transactions, analyze income and expenses, and explore more agent-driven workflows.

Features

  • Import bills — paste bank statement text, upload screenshots or PDFs, and let an LLM agent extract transactions and map them to your ledger accounts
  • Chat with your ledger — ask questions in natural language using BQL queries ("What was my food spend this month?")
  • Multi-turn editing — give feedback to refine the proposed transactions before writing
  • Any LLM provider — OpenAI-compatible or Anthropic-compatible APIs (supports custom endpoints and $ENV_VAR API keys)
  • OCR fallback — PaddleOCR extracts text from bill images for non-vision models (optional)

How it works

favai runs the agent loop directly in your browser using pi-agent-core + pi-ai. The LLM agent is embedded in the extension's JavaScript bundle — no external subprocess, no Node.js dependency at runtime.

Browser (FavaAI.js)
  ├── pi-agent-core Agent (unified: import + chat)
  ├── pi-ai provider → favai llm_proxy → your LLM API
  ├── propose_transactions tool (import) — updates proposal table
  ├── bql_query tool (chat) — queries fava's built-in BQL API
  └── import_confirm → writes entries via fava's existing write path

favai backend (Flask, stateless)
  ├── config (GET/POST) — provider settings
  ├── ingest (POST) — file/text processing (text/image/PDF)
  ├── llm_proxy (POST) — forwards LLM requests with injected API key
  └── import_confirm (POST) — validates and writes entries to ledger

Installation

Prerequisites

  • Python >= 3.12
  • Fava >= 1.30.14
  • An LLM API key (OpenAI, Anthropic, or any compatible endpoint)

Install from PyPI

pip install favai

With OCR fallback for image-based bills:

pip install "favai[ocr]"

Install from source (development)

# Clone the repo
git clone https://github.com/theodoretsui/favai.git
cd favai

# Install Python dependencies
uv sync

# Build the frontend
cd frontend && npm install && npm run build && cd ..

Configure Fava

Add the extension to your Beancount file:

2026-01-01 custom "fava-extension" "favai"

The extension page will appear at /<your-ledger>/extension/FavaAI/.

Optional: OCR support

pip install "favai[ocr]"
# or: uv sync --extra ocr

Usage

1. Configure an LLM provider

Click the gear icon (top-right) and enter:

  • Provider preset: OpenAI, Anthropic, OpenCode Zen, LiteLLM, DeepSeek, or Kimi Coding Plan
  • API type: OpenAI Compatible or Anthropic Compatible
  • Base URL: your endpoint (e.g. https://api.openai.com/v1 or a custom proxy)
  • Model: the model identifier (e.g. gpt-4o, claude-sonnet-4-6)
  • API Key: a literal key or an $ENV_VAR reference (recommended)

Use Fetch models to load the provider's model list. A model can also be selected above the chat before the first message. The selected model is stored with the session and cannot be changed after that session starts, which keeps multimodal message history compatible with the model that created it.

Provider settings are stored as a list in .favai/config.json. The Test connection & save action writes or replaces one provider only after its Models API succeeds. Every saved provider and its discovered models then appears in the new-session model selector.

2. Import bills

In the chat interface, paste text or upload files (.txt, .csv, .png, .jpg, .pdf, etc.) and press Enter. The LLM agent extracts transactions and presents them in an editable table. You can:

  • Edit cells directly in the table
  • Send natural-language feedback ("change this one to Dining")
  • Confirm to write, or discard

3. Chat with your ledger

Type questions like:

  • "What was my food spend last month?"
  • "Show me all transactions to Alipay in July"
  • "How much did I spend on utilities this year?"

The agent translates your questions into BQL queries and summarises the results.

Security

  • API keys are stored next to your Beancount file in .favai/config.json (git-ignored by default)
  • Environment variable references are recommended: $MY_API_KEY
  • The browser never has access to the real API key — LLM requests pass through the backend proxy
  • No file-system or shell access is granted to the LLM agent (only the registered tools)

Development

# Install dependencies
make deps

# Run tests
make test

# Lint
make lint

# Build frontend
make build

# Serve the example ledger
make run

See also AGENTS.md for architecture details and code conventions.

License

favai is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

favai-0.1.0.tar.gz (824.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

favai-0.1.0-py3-none-any.whl (530.9 kB view details)

Uploaded Python 3

File details

Details for the file favai-0.1.0.tar.gz.

File metadata

  • Download URL: favai-0.1.0.tar.gz
  • Upload date:
  • Size: 824.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for favai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7c28148b2ed36f26cf90f63741deeb420086709d6ee8a096ecfe68799632ca36
MD5 946d9be4b12f821366b69a9f3c82e906
BLAKE2b-256 49e676cd677a50ceb529b46e5a051828f0650b2da715638bf43a95fe6eaf0f22

See more details on using hashes here.

Provenance

The following attestation bundles were made for favai-0.1.0.tar.gz:

Publisher: publish.yml on theodoretsui/favai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file favai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: favai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 530.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for favai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d03ee49e19a278a3706708876ec5971e8529b05c91d496bdbb63f3e64a4a26ad
MD5 933e28df2083ba24ae8d6973e416d502
BLAKE2b-256 99c4dd1f0083f678ef7d8ada43e4a6718923e977f79b98e2d499ca1341d38496

See more details on using hashes here.

Provenance

The following attestation bundles were made for favai-0.1.0-py3-none-any.whl:

Publisher: publish.yml on theodoretsui/favai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page