https://github.com/lprabodha/auto-sales-chatbot
AutoBot β Intelligent Chatbot for Auto Sales
https://github.com/lprabodha/auto-sales-chatbot
chatbot conversational-ai fastapi mongodb nlp pytorch vehicle-search
Last synced: 2 months ago
JSON representation
AutoBot β Intelligent Chatbot for Auto Sales
- Host: GitHub
- URL: https://github.com/lprabodha/auto-sales-chatbot
- Owner: Lprabodha
- Created: 2025-03-24T17:15:02.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-25T13:50:09.000Z (about 1 year ago)
- Last Synced: 2025-06-27T19:41:17.629Z (12 months ago)
- Topics: chatbot, conversational-ai, fastapi, mongodb, nlp, pytorch, vehicle-search
- Language: Python
- Homepage: https://auto-sales-chatbot.vercel.app/
- Size: 15.4 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π AutoBot β Intelligent Chatbot for Auto Sales







AutoBot is an AI-powered chatbot built using **PyTorch**, **FastAPI**, and **MongoDB** that helps users search and filter vehicles intelligently. It can handle queries related to brands, models, fuel types, price ranges, and more, and supports feedback collection for continuous improvement via scheduled model retraining.
---
## π Features
- π **Natural Language Understanding** for vehicle queries (e.g., *βShow me Toyota Vitz under 5 millionβ*)
- π **Price, model, brand, and type filters** with fuzzy matching
- π¬ **Interactive Chat Mode** or REST API
- π§ **ML Model Training** with intent classification using PyTorch
- β»οΈ **Daily Retraining from Feedback** (admin-reviewed)
- π **Feedback Logging** with thumbs up/down reactions
- π **MongoDB Integration** for vehicle data and feedback history
---
## π§° Tech Stack
- **Python 3.12+**
- **PyTorch**
- **FastAPI**
- **MongoDB**
- **Uvicorn** (for dev server)
- **scikit-learn** (metrics)
- **matplotlib** (for training metrics)
---
## π Folder Structure
```
auto_sales_bot/
β
βββ data/
β βββ intents.json # Training intents
βββ models/
β βββ model.pth # Saved PyTorch model
βββ utils/
β βββ preprocessing.py # Preprocessing utils
βββ api.py # FastAPI endpoint
βββ chatbot.py # Chat logic & ML inference
βββ train.py # Training script
βββ retrain_daily.py # Scheduled retraining
βββ mongo_service.py # MongoDB interface
βββ requirements.txt # Dependencies
```
---
## βοΈ Setup Instructions
### 1. Clone the repository
```bash
git clone https://github.com/Lprabodha/auto-sales-chatbot
cd auto_sales_bot
git clone https://github.com/Lprabodha/auto-sales-chatbot-widget
```
### 2. Create & activate a virtual environment
```bash
python -m venv .venv
source .venv/bin/activate
```
### 3. Install dependencies
```bash
pip install -r requirements.txt
```
### 4. Start MongoDB
Ensure MongoDB is running locally at `mongodb://localhost:27017`. Use Docker or install MongoDB natively.
#### Sample Data & Retraining
π Sample vehicle listings JSON: data/sample_vehicles.json
#### Import Sample Data to MongoDB
```
mongoimport --uri "mongodb://localhost:27017" \
--db auto_sales_bot \
--collection vehicles \
--file data/sample_vehicles.json \
--jsonArray
```
### 5. Configure your .env file
```
MONGO_URI=mongodb://localhost:27017
DB_NAME=auto_sales_bot
MODEL_PATH=models/model.pth
SECRET_KEY=your-secret-key
```
### 6. Train the model (initial run)
```bash
python train.py
```
### 7. Start the API
```bash
uvicorn api:app --reload
```
---
## π¬ API Endpoints
### `POST /chat`
**Request:**
```json
{ "query": "Show me Toyota Vitz under 5 million" }
```
**Response:**
```json
{
"response": "Here are some Toyota Vitz available:",
"prob": 0.97,
"intent": "ask_brand_model",
"suggestions": [
{
"id": 1,
"model_name": "Vitz 2019",
"vehicle_name": "Toyota Vitz",
"year": 2019,
"price": 9500000,
"mileage": 60000
}
]
}
```
### `POST /feedback`
**Request:**
```json
{
"query": "Any Toyota cars under 4 million?",
"response": "Here are some Toyota available:",
"predicted_intent": "ask_price_range",
"prob": 0.91,
"thumbs_up": false
}
```
### `POST /retrain-now`
Forces model retraining based on feedback data (after admin update).
---
## β° Automating Daily Retraining
Use a cron job or scheduler to run the retrain script:
```bash
0 0 * * * cd /path/to/project && .venv/bin/python retrain_daily.py
```
This will:
- Update `intents.json` from admin-approved feedback
- Retrain the model if required
- Save the updated model
---
## β¨ Contributions
Feel free to open issues or PRs for new features, model improvements, or bug fixes.
---
## π¨βπ» Authors
- Dewmina Udayashan
- Lahiru Prabodha
---
Happy coding! π
---
## π License
MIT License. See `LICENSE` file for details.