Spaces:
Sleeping
A newer version of the Streamlit SDK is available: 1.56.0
title: FinAI-Agent
emoji: π°
colorFrom: indigo
colorTo: green
sdk: streamlit
app_file: app.py
python_version: '3.13'
pinned: false
Finance-Agent π€π°
π 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
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.xlsxcontaining 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.
- Run the app:
streamlit run app.py
- 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
- Fork & branch (feat/your-feature)
- Add tests (pytest -k your_test)
- 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. β‘
