How vishwavardhan33-arch/financial-intelligence-agent works
The Financial Intelligence Agent accepts a financial question, plans an ordered set of RAG, SQL, and calculation steps, resolves dependent inputs, and synthesizes an answer with validated filing citations. Invoices are loaded into normalized PostgreSQL tables; filings are parsed, chunked, embedded, and indexed for hybrid retrieval. The API and agent graph form the query entry path, with SQL and calculation nodes providing structured-data and metric stages. README documents evaluation capabilities, but their wiring was not sampled, so they are omitted. Some internal links follow documented architecture because their source was not sampled.
Main entry points: sql_node.py SQL node · graph.py Agent graph · index_filings.py Filing indexer · dispatch.py Step dispatcher
Components 28
Query interface
- Query API
api/main.py
Agent orchestration
- Agent graph
agent/graph.py - Plan builder
agent/planner.py - Plan schema
agent/plan.py - Step resolver
agent/resolve.py - Step dispatcher
agent/dispatch.py - Answer synthesis
agent/synthesizer.py
Analysis nodes
- SQL node
sql_node/sql_node.py - SQL prompt
sql_node/prompts.py - SQL schema context
sql_node/schema_context.py - SQL validator
sql_node/validator.py - SQL executor
sql_node/executor.py - Calculation node
calc/calc_node.py - Metric functions
calc/metrics.py - Metric dispatch
calc/deterministic.py - Safe evaluator
calc/safe_eval.py
Financial data
- Invoice ingestion
ingestion/load_invoices.py - Invoice database
db/schema.sql - Filing parser
retrieval/parse_filing.py - Filing chunker
retrieval/chunker.py - Embeddings
retrieval/embeddings.py - Filing indexer
retrieval/index_filings.py - Hybrid retrieval
retrieval/vector_store.py - Qdrant index
Model provider
- Local LLM adapter
api/llm_provider.py
Other components
- User
- Filing PDFs
- Ollama
Connections 30
- User → Query API: submits query
- Query API → Agent graph: runs agent
- Agent graph → Plan builder: requests plan
- Plan builder → Plan schema: validates against
- Agent graph → Step dispatcher: executes steps
- Agent graph → Step resolver: resolves inputs
- Step dispatcher → SQL node: runs SQL
- Step dispatcher → Calculation node: runs calculation
- Step dispatcher → Hybrid retrieval: searches filings
- Agent graph → Answer synthesis: synthesizes results
- SQL node → SQL prompt: builds prompt
- SQL node → SQL schema context: uses schema
- SQL node → SQL validator: validates SQL
- SQL node → SQL executor: executes validated SQL
- SQL executor → Invoice database: reads rows
- Calculation node → Metric dispatch: dispatches metrics
- Metric dispatch → Metric functions: calls functions
- Calculation node → Safe evaluator: evaluates expressions
- Invoice ingestion → Invoice database: writes invoices
- Filing PDFs → Filing indexer: provides filings
- Filing indexer → Filing parser: parses documents
- Filing indexer → Filing chunker: chunks text
- Filing indexer → Embeddings: embeds chunks
- Filing indexer → Hybrid retrieval: builds index
- Hybrid retrieval → Embeddings: embeds queries
- Hybrid retrieval → Qdrant index: searches and indexes
- Plan builder → Local LLM adapter: calls model
- SQL node → Local LLM adapter: generates SQL
- Answer synthesis → Local LLM adapter: generates answer
- Local LLM adapter → Ollama: sends prompts