{"id":29353760,"url":"https://github.com/rahulsamant37/customer_support_chatbot","last_synced_at":"2026-04-29T23:03:55.775Z","repository":{"id":302882819,"uuid":"1013719193","full_name":"rahulsamant37/Customer_Support_Chatbot","owner":"rahulsamant37","description":"An intelligent e-commerce customer support chatbot built with LangChain, FastAPI, and Google's Gemini AI. This chatbot provides product recommendations and handles customer queries by leveraging a vector database powered by AstraDB and product review data from Flipkart.","archived":false,"fork":false,"pushed_at":"2025-07-04T14:29:36.000Z","size":169,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-04T16:02:36.631Z","etag":null,"topics":["aiops","astradb","aws-ecr","docker","fastapi","gemini-api","github-actions","rag-chatbot","unit-testing","vector-database"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rahulsamant37.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-04T10:58:03.000Z","updated_at":"2025-07-04T14:33:26.000Z","dependencies_parsed_at":"2025-07-04T16:05:20.994Z","dependency_job_id":"c96852ca-c163-48d9-a86d-daa17407ad95","html_url":"https://github.com/rahulsamant37/Customer_Support_Chatbot","commit_stats":null,"previous_names":["rahulsamant37/customer_support_chatbot"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rahulsamant37/Customer_Support_Chatbot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulsamant37%2FCustomer_Support_Chatbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulsamant37%2FCustomer_Support_Chatbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulsamant37%2FCustomer_Support_Chatbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulsamant37%2FCustomer_Support_Chatbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rahulsamant37","download_url":"https://codeload.github.com/rahulsamant37/Customer_Support_Chatbot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulsamant37%2FCustomer_Support_Chatbot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264379216,"owners_count":23598824,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aiops","astradb","aws-ecr","docker","fastapi","gemini-api","github-actions","rag-chatbot","unit-testing","vector-database"],"created_at":"2025-07-09T02:09:12.520Z","updated_at":"2026-04-29T23:03:55.701Z","avatar_url":"https://github.com/rahulsamant37.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Customer Support Chatbot\n\nAn intelligent e-commerce customer support chatbot built with LangChain, FastAPI, and Google's Gemini AI. This chatbot provides product recommendations and handles customer queries by leveraging a vector database powered by AstraDB and product review data from Flipkart.\n\n## 🚀 Features\n\n- **AI-Powered Conversations**: Uses Google's Gemini 2.0 Flash model for natural language understanding\n- **Vector Search**: Intelligent product retrieval using AstraDB vector store\n- **Real-time Chat Interface**: Modern web-based chat UI\n- **Product Recommendations**: Context-aware product suggestions based on customer reviews\n- **RESTful API**: FastAPI backend with CORS support\n- **Scalable Architecture**: Modular design with separate components for ingestion, retrieval, and inference\n- **Docker Support**: Containerized deployment ready\n\n## 🏗️ Architecture\n\n```\nCustomer_Support_Chatbot/\n├── main.py                     # FastAPI application entry point\n├── data/                       # Product data storage\n│   └── flipkart_product_review.csv\n├── data_ingestion/             # Data processing and vector store ingestion\n│   ├── __init__.py\n│   └── ingestion_pipeline.py\n├── retriever/                  # Vector search and document retrieval\n│   ├── __init__.py\n│   └── retrieval.py\n├── prompt_library/             # AI prompt templates\n│   ├── __init__.py\n│   └── prompt.py\n├── utils/                      # Utility modules\n│   ├── __init__.py\n│   ├── config_loader.py\n│   └── model_loader.py\n├── frontend/                   # Web chat interface\n│   ├── index.html\n│   └── README.md\n├── config/                     # Configuration files\n│   └── config.yaml\n├── notebook/                   # Jupyter notebook for experimentation\n│   └── custmor_support.ipynb\n└── setup_database.py          # Database initialization script\n```\n\n## 🛠️ Tech Stack\n\n- **Backend**: FastAPI, Python 3.12+\n- **AI/ML**: LangChain, Google Gemini AI, Google Text Embeddings\n- **Database**: AstraDB (Vector Database)\n- **Frontend**: HTML, CSS, JavaScript\n- **Deployment**: Docker, Uvicorn\n- **Data Processing**: Pandas\n\n## 📋 Prerequisites\n\nBefore running the application, ensure you have:\n\n1. **Python 3.12+** installed\n2. **AstraDB account** with vector search enabled\n3. **Google AI Studio API key**\n4. **Required environment variables** (see setup section)\n\n## ⚙️ Setup and Installation\n\n### 1. Clone the Repository\n\n```bash\ngit clone \u003crepository-url\u003e\ncd Customer_Support_Chatbot\n```\n\n### 2. Install Dependencies\n\nUsing pip:\n```bash\npip install -r requirements.txt\n```\n\nUsing uv (recommended):\n```bash\nuv install\n```\n\n### 3. Environment Configuration\n\nCreate a `.env` file in the root directory with the following variables:\n\n```env\n# Google AI API\nGOOGLE_API_KEY=your_google_api_key_here\n\n# AstraDB Configuration\nASTRA_DB_API_ENDPOINT=your_astra_db_endpoint\nASTRA_DB_APPLICATION_TOKEN=your_astra_db_token\nASTRA_DB_KEYSPACE=your_keyspace_name\n```\n\n### 4. Configuration\n\nUpdate `config/config.yaml` if needed:\n\n```yaml\nastra_db:\n  collection_name: \"ecommercedata\"\n\nembedding_model:\n  provider: \"google\"\n  model_name: \"models/text-embedding-004\"\n\nretriever:\n  top_k: 10\n\nllm:\n  provider: \"google\"\n  model_name: \"gemini-2.0-flash\"\n```\n\n### 5. Database Setup\n\nInitialize the vector database with product data:\n\n```bash\npython setup_database.py\n```\n\nThis script will:\n- Validate your environment variables\n- Load product data from `data/flipkart_product_review.csv`\n- Create embeddings and populate the AstraDB vector store\n\n### 6. Run the Application\n\nStart the FastAPI server:\n\n```bash\nuvicorn main:app --host 0.0.0.0 --port 8000 --reload\n```\n\nThe application will be available at:\n- **API**: http://localhost:8000\n- **Chat Interface**: http://localhost:8000/chat\n- **API Documentation**: http://localhost:8000/docs\n\n## 🐳 Docker Deployment\n\n### Build and Run with Docker\n\n```bash\n# Build the Docker image\ndocker build -t customer-support-chatbot .\n\n# Run the container\ndocker run -p 8000:8000 --env-file .env customer-support-chatbot\n```\n\n## 📚 API Endpoints\n\n### GET `/`\nHealth check endpoint\n```json\n{\n  \"message\": \"Welcome to the Product Information Bot API. Use the /get endpoint to chat with the bot.\"\n}\n```\n\n### POST `/get`\nChat with the bot\n```bash\ncurl -X POST \"http://localhost:8000/get\" \\\n     -H \"Content-Type: application/x-www-form-urlencoded\" \\\n     -d \"msg=Tell me about bluetooth headphones\"\n```\n\nResponse:\n```json\n{\n  \"response\": \"Based on the product reviews, I can recommend the BoAt Rockerz 235v2...\"\n}\n```\n\n### GET `/chat`\nAccess the web chat interface\n\n## 🎯 Usage Examples\n\n### Query Product Information\n```\nUser: \"What are the best bluetooth headphones under 2000?\"\nBot: \"Based on customer reviews, I recommend the BoAt Rockerz 235v2...\"\n```\n\n### Ask About Product Features\n```\nUser: \"Tell me about the battery life of BoAt headphones\"\nBot: \"According to customer reviews, the BoAt Rockerz 235v2 offers...\"\n```\n\n## 🔧 Component Details\n\n### Data Ingestion Pipeline\n- **File**: `data_ingestion/ingestion_pipeline.py`\n- **Purpose**: Processes CSV data and creates vector embeddings\n- **Features**: Automatic data transformation and AstraDB integration\n\n### Retrieval System\n- **File**: `retriever/retrieval.py`\n- **Purpose**: Handles vector similarity search\n- **Features**: Configurable top-k results, efficient document retrieval\n\n### Model Loader\n- **File**: `utils/model_loader.py`\n- **Purpose**: Manages AI model initialization\n- **Features**: Google Gemini integration, embedding model loading\n\n### Prompt Templates\n- **File**: `prompt_library/prompt.py`\n- **Purpose**: Contains optimized prompts for the AI model\n- **Features**: Context-aware response generation\n\n## 🧪 Development\n\n### Run Tests\nThe project includes a comprehensive test suite with 68 tests covering all major components:\n\n```bash\n# Run all tests\npython -m pytest tests/\n\n# Run tests with coverage report\npython -m pytest tests/ --cov=. --cov-report=term-missing\n\n# Run specific test categories\npython -m pytest tests/ -m unit          # Unit tests only\npython -m pytest tests/ -m integration   # Integration tests only\npython -m pytest tests/ -m api          # API tests only\n\n# Run tests in verbose mode\npython -m pytest tests/ -v\n\n# Run tests and stop on first failure\npython -m pytest tests/ -x\n```\n\n**Test Coverage:**\n- **88% overall code coverage**\n- **Unit Tests:** Model loading, configuration, prompt templates\n- **Integration Tests:** Data ingestion, retrieval workflows, API endpoints\n- **API Tests:** FastAPI endpoints, CORS, static file serving\n- **Error Handling:** Environment validation, file handling, network errors\n\n### Development Mode\n```bash\nuvicorn main:app --reload --host 0.0.0.0 --port 8000\n```\n\n### Jupyter Notebook\nExplore the project interactively:\n```bash\njupyter notebook notebook/custmor_support.ipynb\n```\n\n## 🐛 Troubleshooting\n\n### Common Issues\n\n1. **\"No product information available\" Error**\n   - Run `python setup_database.py` to populate the database\n   - Verify your AstraDB credentials in the `.env` file\n\n2. **API Key Errors**\n   - Ensure your Google API key is valid and has the necessary permissions\n   - Check that all environment variables are properly set\n\n3. **Connection Timeouts**\n   - Verify your AstraDB endpoint and token\n   - Check your internet connection\n\n### Debug Mode\nEnable detailed logging by setting:\n```bash\nexport PYTHONPATH=\"${PYTHONPATH}:$(pwd)\"\npython main.py\n```\n\n## 📈 Performance Optimization\n\n- **Vector Search**: Optimized for sub-second response times\n- **Caching**: Environment variables and model loading optimization\n- **Async Operations**: FastAPI async support for concurrent requests\n- **Memory Management**: Efficient document processing\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## 🔗 Related Resources\n\n- [LangChain Documentation](https://python.langchain.com/)\n- [AstraDB Vector Search](https://docs.datastax.com/en/astra-serverless/docs/vector-search/overview.html)\n- [Google AI Studio](https://makersuite.google.com/)\n- [FastAPI Documentation](https://fastapi.tiangolo.com/)\n\n## 📞 Support\n\nFor support and questions:\n- Open an issue on GitHub\n- Check the troubleshooting section\n- Review the API documentation at `/docs`\n\n---\n\n**Built with ❤️ using LangChain and Google AI**","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahulsamant37%2Fcustomer_support_chatbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frahulsamant37%2Fcustomer_support_chatbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahulsamant37%2Fcustomer_support_chatbot/lists"}