--- title: AI Chatbot with Smart Routing emoji: 🤖 colorFrom: blue colorTo: purple sdk: docker pinned: false license: mit app_port: 7860 --- # 🤖 Financial AI Chatbot with Smart Routing & RAG **A demo GenAI app that demonstrates smart routing using LangChain** ## 🚀 Try It Live - **🎯 Live Demo**: [Financial AI Chatbot](https://huggingface.co/spaces/krinya/smart_routing_with_render_example) ← **Try it here!** - **💻 Frontend Code**: [`app.py`](https://huggingface.co/spaces/krinya/smart_routing_with_render_example/tree/main) - Gradio interface code - **🔗 Backend API**: [Deployed on Render](https://gen-ai-demo-rag-bot.onrender.com/docs) - **📖 Backend API Code**: [GitHub Repository](https://github.com/krinya/gen_ai_demo_rag_bot/tree/main) ## 🎯 What This Demonstrates This project shows **how to create a complete GenAI product**: ### 1. 🧠 Smart Routing with LangChain Intelligently routes financial questions about **5 major companies** (Apple, Google, Amazon, Tesla, Intel): - 🔍 **FAQ Route**: Quick facts (CEO names, founding dates) - 📚 **RAG Route**: Financial data from 2024 annual reports (revenue, profits) - 🧠 **LLM Route**: General explanations and financial concepts ### 2. 📊 RAG Implementation - **Vector Storage**: ChromaDB with processed financial documents (full annual reports) - **Retrieval System**: Semantic search for relevant information - **Smart Fallbacks**: Multiple sources with quality scoring ### 3. 🏗️ Production Architecture - **Backend**: Python FastAPI with LangChain, deployed on Render - **Frontend**: Gradio UI deployed on Hugging Face Spaces - **Separation**: Backend API + Frontend UI for scalability ## 🛠️ How This Shows GenAI Product Development **Complete workflow: Backend → Deploy → Frontend** 1. **Write Backend** (Python + LangChain) - FastAPI with smart routing logic - RAG pipeline with vector storage - Deploy on Render cloud platform 2. **Create Frontend** (Gradio + Hugging Face) - Interactive chat interface - Real-time routing insights - Deploy on Hugging Face Spaces 3. **Connect & Scale** - Backend API serves multiple frontends - Docker containerization - Production-ready architecture ## 🔧 Tech Stack - **AI**: OpenAI GPT-4o-mini + LangChain orchestration - **Backend**: Python FastAPI deployed on Render - **Frontend**: Gradio deployed on Hugging Face Spaces - **Storage**: ChromaDB vector database - **Data**: 2024 financial reports (Apple, Google, Amazon, Tesla, Intel) ## � Example Queries Try these in the live demo: - "Who is the CEO of Tesla?" → FAQ route - "What was Apple's revenue in 2024?" → RAG route - "How do you calculate P/E ratio?" → LLM route --- **🎯 Key Learning**: This demonstrates the complete GenAI development stack from data processing to production deployment!