FinAIAgent / README.md
Sbboss's picture
Update README.md
0e07197 unverified

A newer version of the Streamlit SDK is available: 1.56.0

Upgrade
metadata
title: FinAI-Agent
emoji: πŸ’°
colorFrom: indigo
colorTo: green
sdk: streamlit
app_file: app.py
python_version: '3.13'
pinned: false

Finance-Agent πŸ€–πŸ’°

Python Streamlit License: MIT


πŸš€ What Is This?

Finance-Agent is your chat-native CFO co-pilot.
Ask plain-English questions about your company’s Excel ledger, and get instant answers with context + charts.


TRY IT NOW!!

https://huggingface.co/spaces/Sbboss/FinAIAgent

Demo


Example

You ➜ β€œCompare EBITDA and cash runway for Q1 vs Q2, convert EUR to USD.”

Agent ➜ β€œEBITDA Q1: $1.42 M, Q2: $1.65 M (+16.4 %).

Cash runway improved from 7.1 β†’ 8.3 months.”


✨ Feature Tour

  • Natural-Language Querying β€” Gemini 2.5 Flash interprets finance jargon and casual questions alike.
  • Dynamic Tool Routing β€” LangChain React agent picks one or more of 7 custom Python tools (revenue variance, gross-margin %, OpEx breakdown…).
  • Smart Currency Handling β€” Detects EUR rows, fetches FX sheet, normalizes to USD.
  • Date Inference β€” β€œThis year”, β€œlast 3 months”, β€œJun’25” β†’ precise periods.
  • Chart Factory β€” Generates PNGs via Matplotlib (line, bar, area, stacked).
  • Streamlit UI β€” Slack-style sidebar, message persistence, spinner feedback.
  • Excel Plug-and-Play β€” Works with a single data.xlsx containing 4 sheets: actuals, budget, cash, fx.
  • Fallback PythonREPL β€” If no tool fits, agent writes ad-hoc Pandas code.
  • Pytest Suite β€” Automated tests for tool selection, calc accuracy, caching, and rendering.
  • One-click Deploy β€” Just streamlit run app.py.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€ Chat UI (Streamlit) ───────┐
β”‚  User Input + Chat History         β”‚
β”‚      ↓ finance_agent.invoke()      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                β”‚
                β–Ό
β”Œβ”€β”€ LangChain AgentExecutor ──────────────┐
β”‚  Prompt (system + history + input)      β”‚
β”‚  LLM: Gemini 2.5 Flash                  β”‚
β”‚  React tool-calling loop                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚ selects & runs
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Custom Tools                           β”‚
β”‚  β€’ get_revenue_variance                 β”‚
β”‚  β€’ get_gross_margin_pct                 β”‚
β”‚  β€’ get_opex_breakdown                   β”‚
β”‚  β€’ get_ebitda_proxy                     β”‚
β”‚  β€’ get_cash_runway                      β”‚
β”‚  β€’ plot_chart                           β”‚
β”‚  β€’ code_analysis (PythonREPL)           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“‚ Folder Structure

finance-agent/
β”œβ”€ agent/
β”‚  β”œβ”€ agent.py        # creates cached AgentExecutor
β”‚  β”œβ”€ utils.py        # numeric calculations
β”‚  └─ tests/          # pytest suite
β”œβ”€ data.xlsx          # sample ledger
β”œβ”€ app.py             # Streamlit front-end
β”œβ”€ requirements.txt
└─ .streamlit/
   └─ secrets.toml    # custom theme & font

βš™οΈ Installation

git clone https://github.com/Sbboss/FinAIAgent.git
cd FinAIAgent
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
streamlit run app.py

πŸƒ Quick Start

Drop your company ledger into data.xlsx with sheets: actuals, budget, cash, fx.

  1. Run the app:
streamlit run app.py
  1. Ask away:
β€œTrend gross margin % monthly for 2024.”
β€œWhy did revenue miss budget in Nov 25?”
β€œHow many months of runway if burn stays flat?”

πŸ‘‰ Charts appear inline; numeric answers include deltas vs budget and YOY.


πŸ”¬ Testing

pytest -v

Covers: Tool parameter validation Correct tool selection via intermediate steps Currency conversion accuracy Streamlit image rendering Caching behaviour (st.cache_resource)


πŸ› οΈ Configuration

Setting File / Env Default
Google Gemini API key GOOGLE_API_KEY put in secrets.toml
Excel file path data.xlsx β€”
LLM temperature agent 0.2

πŸŒ… Roadmap

  • πŸ”„ CSV and SQL connectors
  • πŸ—ƒοΈ Vector memory for conversation continuity
  • 🌐 Multi-LLM failover (Gemini β†’ GPT-4o)
  • πŸ“ˆ Automatic dashboard snapshots to PDF
  • πŸ’¬ Slack / Teams integration
  • πŸŽ₯ Demo GIF: live chat β†’ chart β†’ answer

πŸ™Œ Contributing

  1. Fork & branch (feat/your-feature)
  2. Add tests (pytest -k your_test)
  3. Submit PR with concise description

βœ… All significant changes must pass CI and keep coverage β‰₯ 95%.


πŸ“ License MIT β€” see LICENSE Finance-Agent turns spreadsheets into strategy. Ask. Analyze. Act. ⚑