CoolFace
Apppublic

sykang16/agentic-wealth-intelligence

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
README.md184 linesDownload Raw Back to root
1---2title: Agentic Wealth Intelligence3emoji: πŸ“ˆ4colorFrom: blue5colorTo: purple6sdk: streamlit7sdk_version: 1.55.08app_file: ui/streamlit_app.py9pinned: false10---11 12# Agentic Wealth Intelligence13 14AI-powered wealth management system with multi-agent orchestration, conversational profiling, RAG-enhanced recommendations, and real-time market data integration.15 16## Architecture17 18**LangGraph Hybrid Supervisor Routing** β€” two-tier intent classification feeds into a flat outer graph; the Recommend node embeds a Supervisor subgraph for multi-step context gathering.19 20### Outer Orchestrator Graph21 22```23                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”24     User ──────►│             Router                   β”‚25                 β”‚  Tier 1: Keyword match  (fast path)  β”‚26                 β”‚  Tier 2: LLM fallback   (T=0)        β”‚27                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜28                                β”‚ conditional routing29       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”30       β–Ό                        β–Ό                  β–Ό              β–Ό31β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”32β”‚ Portfolio  β”‚       β”‚  Profiling   β”‚   β”‚  Recommend   β”‚  β”‚ General  β”‚33β”‚  Module A  β”‚       β”‚   Module B   β”‚   β”‚  [Subgraph]  β”‚  β”‚  (LLM)   β”‚34β”‚ AssetAgent β”‚       β”‚ slot-filling β”‚   β”‚  Supervisor  β”‚  β”‚          β”‚35β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜36       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜37                                                β”‚38                                         β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”39                                         β”‚   Respond   │──► END40                                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜41```42 43### Recommendation Supervisor Subgraph44 45```46β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”47β”‚             Supervisor  (LLM decision Β· guard: steps <= 5)    β”‚48β”‚        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”‚49β”‚        β–Ό                    β–Ό                  β–Ό              β”‚50β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚51β”‚ β”‚portfolio_   β”‚   β”‚profiling_    β”‚   β”‚  recommend   β”‚        β”‚52β”‚ β”‚fetch        β”‚   β”‚fetch         β”‚   β”‚  synthesis   β”‚        β”‚53β”‚ β”‚AssetAgent   β”‚   β”‚get_profile_  β”‚   β”‚  RAG + MCP   β”‚        β”‚54β”‚ β”‚.process()   β”‚   β”‚  summary()   β”‚   β”‚              β”‚        β”‚55β”‚ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚56β”‚        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β”‚57β”‚                    loops back to Supervisor                    β”‚58β”‚                                          finish ─────► Respond β”‚59β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜60```61 62**Modules:**63- **Portfolio Analysis** β€” Natural language queries about your holdings, net worth, allocation, gains/losses64- **Investment Profiling** β€” Conversational slot-filling to build your risk/preference profile65- **Recommendations** β€” AI-generated investment advice using portfolio data, RAG knowledge base, and live market data66- **AI Advisor** β€” Unified chat interface that automatically routes to the right module67 68## Quick Start69 70### 1. Install Dependencies71 72```bash73pip install -r requirements.txt74```75 76### 2. Configure Environment77 78Copy `.env.example` to `.env` and set your API keys:79 80```bash81cp .env.example .env82```83 84Required (at least one LLM provider):85- `OPENAI_API_KEY` β€” OpenAI GPT-4o86- `ANTHROPIC_API_KEY` β€” Anthropic Claude87- `GEMINI_API_KEY` β€” Google Gemini88 89Optional (for live data):90- `ALPHA_VANTAGE_API_KEY` β€” Market quotes and financial news91- `NEWS_API_KEY` β€” Business news92- `SEC_USER_AGENT` β€” SEC EDGAR filings93 94### 3. Generate Synthetic Data95 96```python97from backend.src.data_generation import generate_sample_data98generate_sample_data()99```100 101### 4. Run the Streamlit UI102 103```bash104python -m streamlit run ui/streamlit_app.py105```106 107### 5. Run the API Server108 109```bash110uvicorn backend.src.api.app:app --reload111```112 113API documentation available at `http://localhost:8000/docs`.114 115## API Endpoints116 117| Method | Endpoint | Description |118|--------|----------|-------------|119| `POST` | `/api/v1/chat` | Unified orchestrator chat |120| `GET` | `/api/v1/portfolio/{user_id}` | Portfolio summary |121| `POST` | `/api/v1/portfolio/{user_id}/query` | Natural language portfolio query |122| `POST` | `/api/v1/profiling/{user_id}/start` | Start profiling session |123| `POST` | `/api/v1/profiling/{user_id}/respond` | Continue profiling conversation |124| `POST` | `/api/v1/recommendations/generate` | Generate recommendations |125| `GET` | `/health` | Health check |126 127## Project Structure128 129```130backend/131β”œβ”€β”€ src/132β”‚   β”œβ”€β”€ agents/              # Agent implementations133β”‚   β”‚   β”œβ”€β”€ asset_agent.py   # Portfolio query agent134β”‚   β”‚   └── orchestrator.py  # Multi-agent orchestrator135β”‚   β”œβ”€β”€ api/                 # FastAPI application136β”‚   β”‚   β”œβ”€β”€ app.py           # App factory137β”‚   β”‚   β”œβ”€β”€ dependencies.py  # Dependency injection138β”‚   β”‚   β”œβ”€β”€ schemas.py       # Request/response models139β”‚   β”‚   └── routes/          # API route handlers140β”‚   β”œβ”€β”€ asset_management/    # Module A: Portfolio data141β”‚   β”œβ”€β”€ common/              # Shared models, LLM client142β”‚   β”œβ”€β”€ multi_agent/         # LangGraph orchestrator143β”‚   β”‚   β”œβ”€β”€ state.py         # State definitions144β”‚   β”‚   β”œβ”€β”€ routing.py       # Intent classification145β”‚   β”‚   β”œβ”€β”€ nodes.py         # Graph node functions146β”‚   β”‚   └── graph.py         # Graph construction147β”‚   β”œβ”€β”€ profiling/           # Module B: Slot-filling agent148β”‚   β”œβ”€β”€ recommendation/      # Module C: RAG + recommendations149β”‚   └── mcp/                 # MCP servers for live data150ui/151β”œβ”€β”€ streamlit_app.py         # Main Streamlit application152tests/153β”œβ”€β”€ unit/                    # Unit tests154β”œβ”€β”€ integration/             # Integration tests155└── e2e/                     # End-to-end tests156```157 158## Running Tests159 160```bash161# All tests162pytest tests/ -v163 164# Specific test categories165pytest tests/unit/ -v166pytest tests/integration/ -v167pytest tests/e2e/ -v168```169 170## Tech Stack171 172- **Python 3.11+** β€” Core language173- **LangGraph** β€” Multi-agent orchestration and profiling workflows174- **FastAPI** β€” REST API layer175- **Streamlit** β€” Interactive UI176- **ChromaDB** β€” Vector store for RAG177- **Sentence Transformers** β€” Document embeddings178- **MCP (Model Context Protocol)** β€” Live market data integration179- **Pydantic v2** β€” Data validation180 181## Documentation182 183See [docs/00_INDEX.md](docs/00_INDEX.md) for the full documentation index.184