Spaces:
Sleeping
Sleeping
| title: GenAI Loan Advisor | |
| emoji: π¦ | |
| colorFrom: blue | |
| colorTo: green | |
| sdk: docker | |
| app_port: 7860 | |
| pinned: false | |
| # π¦ GenAI Loan Advisor | |
| A robust Multi-Agent System built with **CrewAI** and **Mistral** that automates the bank loan underwriting process. This system executes a strict sequential pipeline to retrieve customer data, consult internal policy documents (RAG), and determine risk levels with zero human intervention. | |
| ## ποΈ Architecture: The "Plan & Execute" Model | |
| To prevent "infinite thinking loops" common in pure hierarchical systems, this project splits the workflow into two distinct phases: | |
| USER QUERY: "Can Andy get a loan?" | |
| β | |
| βΌ | |
| βββββββββββββββββββββββββββββββββββββββββ | |
| β PHASE 1: THE BRAIN (Strategy) β | |
| β Agent: Senior Context Analyst β | |
| β "I see a loan request. I will β | |
| β activate the Application Pipeline." β | |
| βββββββββββββββββ¬ββββββββββββββββββββββββ | |
| β Pass JSON Plan | |
| βΌ | |
| βββββββββββββββββββββββββββββββββββββββββ | |
| β PHASE 2: THE MUSCLE (Execution) β | |
| β (Strict Sequential Assembly Line) β | |
| β β | |
| β 1. DATA AGENT βββΆ Fetches PII & Scoreβ | |
| β (Output: Score 780, Good Status) β | |
| β β | |
| β 2. RAG AGENT βββΆ Checks Policy β | |
| β (Output: "750+ is Low Risk") β | |
| β β | |
| β 3. JUDGE AGENT βββΆ Makes Decision β | |
| β (Output: "Approved @ 3.175%") β | |
| β β | |
| β 4. RESOLUTION AGENT βββΆ Final Report β | |
| βββββββββββββββββββββββββββββββββββββββββ | |
| Key Features | |
| Smart Orchestration: The "Strategy Agent" acts as a Manager effectively by deciding the intent before the crew starts, eliminating the risk of the AI getting confused during execution. | |
| Whole-Sheet RAG: Implements a specialized 1500-character chunking strategy to preserve entire "Risk Matrix" tables from PDF policies, preventing the AI from seeing fragmented data. | |
| Hallucination Guardrails: The Data Agent is strictly bound to real customer lookups, preventing the invention of fake customers (like "John Doe"). | |
| Professional Reporting: The Resolution Agent ensures the final output is a clean, client-facing communication. | |
| Project Structure | |
| Quick Start | |
| 1. Environment Setup | |
| Create a .env file in the root: | |
| MISTRAL_API_KEY=your_api_key_here | |
| CODE=Access_code | |
| 3. Ingest Policy Documents | |
| Crucial Step: Run this once to build the Vector Database. | |
| python rag/ingest_policies.py | |
| 4. Installation | |
| pip install -r requirements.txt | |
| python app.py | |
| Sample Interaction | |
| User: "Can Andy get a loan?" | |
| System Logs: | |
| Context Analyst: Intent detected: Loan Application. Data Agent: Successfully retrieved Customer ID 9982 (Andy). Score: 780. RAG Agent: Found rule: "Credit Score 750-850 = Low Risk". Underwriter: Mapping "Low Risk" to Interest Rate Table -> 3.175%. | |
| Final Output: | |
| "We are pleased to inform you that Andy's loan application has been APPROVED. Based on a credit score of 780, he qualifies for our Low Risk tier with an interest rate of 3.175%." |