--- title: Smart Customer Support Agent emoji: ๐Ÿ’ฌ colorFrom: yellow colorTo: purple sdk: gradio sdk_version: 5.33.0 app_file: app.py pinned: false license: mit short_description: Agentic retrieval & smart routing for customer support tags: - agent-demo-track - llamaindex - llamacloud - rag - agentic-retrieval - smart-routing - customer-service - chatbot - claude - anthropic - cohere-embed --- # ๐Ÿ’ฌ Smart Customer Support Triage Agent An intelligent customer support system powered by LlamaIndex, Anthropic Claude and Gradio, featuring agentic routing and smart document retrieval across multiple knowledge bases. > [!IMPORTANT] > This project earned [Agent Track Honorable Mention](https://www.gradio.app/hackathon-winners) in โ€œGradio Agents & MCP Hackathon 2025โ€. Thank you so much! ๐Ÿฅน๐Ÿ™โค๏ธ ## ๐Ÿ”ฎ Live Demo Try the chatbot: **[https://huggingface.co/spaces/karenwky/cs-agent](https://huggingface.co/spaces/karenwky/cs-agent)** _\* Llama-3.1-405B-Instruct supported by Nebius AI Studio is used as the LLM in live demo._ ## ๐Ÿ“น Preview ## ๐Ÿš€ Technologies Used - **LLM**: Anthropic Claude Sonnet 4.0 for natural language understanding and generation - **RAG Framework**: LlamaIndex for agent framework and intelligent query routing - **Cloud Platform**: LlamaCloud for document parsing & indexng, managed vector database - **UI Framework**: Gradio for interactive web interface - **Observability**: LlamaTrace (Arize Phoenix) for LLM tracing and monitoring - **Language**: Python 3.12 - **Document Types**: PDF, PPTX, CSV support - **Coding Assistance**: Gemini 2.5 Flash - **Synthetic Data**: Grok Chat, Slidesgo for sample knowledge base generation ## ๐Ÿ“ Project Structure ``` cs-agent/ โ”œโ”€โ”€ app.py # Main application logic โ”œโ”€โ”€ requirements.txt # Python dependencies โ”œโ”€โ”€ logo.png # Chatbot avatar image โ””โ”€โ”€ data/ # Sample knowledge base โ”œโ”€โ”€ ProductManuals/ # Product documentation โ”œโ”€โ”€ FAQGeneralInfo/ # FAQ and general information โ”œโ”€โ”€ BillingPolicy/ # Billing and payment policies โ””โ”€โ”€ CompanyIntroductionSlides/ # Company overview ``` ## ๐Ÿ”„ Architecture & Workflow Architecture & Workflow Diagram ## โœจ Key Features ### ๐ŸŽฏ **Agentic Routing** - Intelligent query classification and routing to appropriate knowledge bases - Composite retrieval with automatic reranking - Context-aware document selection based on query intent ### ๐Ÿง  **Metadata Awareness** - Extracts and utilizes document metadata (e.g., author, creation date, modification date) - File-specific information retrieval from document properties - Enhanced context understanding through metadata integration ### ๐Ÿ”„ **Automatic Version Control** - Tracks document versions automatically (e.g., `late_payment_policy_v2.pdf`) - Maintains historical document access - Version-aware responses for policy and procedure queries ### ๐Ÿ’พ **Memory Management** - Persistent chat memory with token limit - Context preservation across conversation turns - Condensed question generation for better retrieval ### ๐Ÿ“Š **Observability** - Real-time LLM tracing with Arize Phoenix - Retrieval performance monitoring - Source attribution and scoring visibility ## ๐Ÿš€ Quick Start ### Prerequisites - Python 3.8+ - LlamaCloud API key - Anthropic API key - (Optional) Arize Phoenix API key ### Installation 1. **Clone the repository** ```bash git clone https://github.com/karenwky/cs-agent cd cs-agent ``` 2. **Install dependencies** ```bash pip install -r requirements.txt ``` 3. **Set environment variables** ```bash export ANTHROPIC_API_KEY="your-anthropic-api-key" export LLAMA_CLOUD_API_KEY="your-llamacloud-api-key" # Optional: For Phoenix tracing export PHOENIX_PROJECT_NAME="your-phoenix-project" export PHOENIX_API_KEY="your-phoenix-api-key" ``` 4. **Set up LlamaCloud indices** - Create a project named `CustomerSupportProject` in LlamaCloud - Upload documents to create these indices: - `ProductManuals` - `FAQGeneralInfo` - `BillingPolicy` - `CompanyIntroductionSlides` 5. **Launch the application** ```bash python app.py ``` ## ๐Ÿ—ฃ๏ธ Sample Questions ### ๐Ÿ“š **Product Manual Queries** - "Help! No response from the app, I can't do anything. What should I do?" - "What are the procedures to set up task automation?" - "How can your software help team collaboration?" - "Who is the author of the product manual and when is the last modified date?" ### โ“ **General FAQ & Company Info** - "Who are the founders of this company? What are their backgrounds?" - "Is your company environmentally friendly?" - "What kind of technical detail can I expect for sustainability questions?" ### ๐Ÿ’ฐ **Billing & Policy Questions** - "I got a $200 invoice outstanding for 45 days. How much is the late charge?" - "What is your latest late payment policy?" - "If I enable auto-pay but my payment method expires, will I get notified?" - "Does the 14-day refund policy refer to calendar days or business days?" ### ๐Ÿ”ง **Complex Multi-Domain Queries** - "If I sign up for annual 'Pro' subscription with 10% discount but cancel after 20 days, what exact refund amount considering the 14-day policy?" - "For multi-user discounts, if I add a 5th user mid-cycle, when does the 10% discount apply and how is prorating calculated?" ## ๐Ÿ”ฎ Potential Enhancements ### ๐ŸŽฏ **Advanced AI Capabilities** - **Multi-modal Support**: Add image and video processing for visual troubleshooting guides - **Voice Integration**: Implement speech-to-text and text-to-speech for accessibility - **Sentiment Analysis**: Detect customer frustration levels and escalate appropriately - **Predictive Analytics**: Anticipate customer needs based on interaction patterns ### ๐Ÿ”ง **Technical Improvements** - **Streaming Responses**: Implement real-time response streaming for better UX - **Caching Layer**: Add Redis/Memcached for frequently accessed information - **API Gateway**: Create RESTful APIs for integration with existing support systems - **Containerization**: Docker support for easy deployment and scaling ### ๐Ÿ“Š **Analytics & Monitoring** - **Custom Dashboards**: Build comprehensive analytics for support metrics - **A/B Testing**: Framework for testing different response strategies - **Performance Metrics**: Track response accuracy, user satisfaction, and resolution rates - **Automated Quality Assurance**: Implement response quality scoring and feedback loops ### ๐Ÿ” **Security & Compliance** - **Authentication System**: User management and role-based access control - **Data Encryption**: End-to-end encryption for sensitive customer data - **Audit Logging**: Comprehensive logging for compliance and security monitoring - **GDPR Compliance**: Data privacy controls and user data management ### ๐ŸŒ **Integration & Scalability** - **CRM Integration**: Connect with Salesforce, HubSpot, or other CRM systems - **Ticketing System**: Integration with Zendesk, Jira Service Management - **Multi-language Support**: Internationalization for global customer base - **Load Balancing**: Horizontal scaling for high-traffic scenarios ### ๐Ÿค– **Advanced Agent Capabilities** - **Tool Integration**: Connect with external APIs and services - **Workflow Automation**: Automated ticket creation and routing - **Escalation Logic**: Smart human handoff based on complexity scoring - **Learning System**: Continuous improvement from customer interactions ## ๐Ÿ™ Acknowledgments - [RAG is dead, long live agentic retrieval โ€” LlamaIndex](https://www.llamaindex.ai/blog/rag-is-dead-long-live-agentic-retrieval) - [LlamaCloudIndex + LlamaCloudRetriever - LlamaIndex](https://docs.llamaindex.ai/en/stable/module_guides/indexing/llama_cloud_index/) - [Condense plus context - LlamaIndex](https://docs.llamaindex.ai/en/stable/api_reference/chat_engines/condense_plus_context/) - [LlamaIndex | Phoenix](https://arize.com/docs/phoenix/tracing/integrations-tracing/llamaindex#setup) ## ๐Ÿ“ License This project is licensed under the MIT License.