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.
- 🔍 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
- Python 3.12+
- PyTorch
- FastAPI
- MongoDB
- Uvicorn (for dev server)
- scikit-learn (metrics)
- matplotlib (for training metrics)
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
git clone https://github.com/Lprabodha/auto-sales-chatbot
cd auto_sales_bot
git clone https://github.com/Lprabodha/auto-sales-chatbot-widgetpython -m venv .venv
source .venv/bin/activatepip install -r requirements.txtEnsure MongoDB is running locally at mongodb://localhost:27017. Use Docker or install MongoDB natively.
🚗 Sample vehicle listings JSON: data/sample_vehicles.json
mongoimport --uri "mongodb://localhost:27017" \
--db auto_sales_bot \
--collection vehicles \
--file data/sample_vehicles.json \
--jsonArray
MONGO_URI=mongodb://localhost:27017
DB_NAME=auto_sales_bot
MODEL_PATH=models/model.pth
SECRET_KEY=your-secret-key
python train.pyuvicorn api:app --reloadRequest:
{ "query": "Show me Toyota Vitz under 5 million" }Response:
{
"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
}
]
}Request:
{
"query": "Any Toyota cars under 4 million?",
"response": "Here are some Toyota available:",
"predicted_intent": "ask_price_range",
"prob": 0.91,
"thumbs_up": false
}Forces model retraining based on feedback data (after admin update).
Use a cron job or scheduler to run the retrain script:
0 0 * * * cd /path/to/project && .venv/bin/python retrain_daily.pyThis will:
- Update
intents.jsonfrom admin-approved feedback - Retrain the model if required
- Save the updated model
Feel free to open issues or PRs for new features, model improvements, or bug fixes.
- Dewmina Udayashan
- Lahiru Prabodha
Happy coding! 😊
MIT License. See LICENSE file for details.