A chatbot for TrentU students that will assist in choosing courses
This is a full-stack web application with a Django backend and a React frontend. The backend provides a RESTful API using Django REST Framework, and the frontend is built with React and communicates with the backend via API calls.
root/
├── backend/ # Django project
| ├── conversations/
| | └── ...
| ├── recommendation/
| | └── ...
| ├── users/
| | └── ...
│ ├── courserec/
│ | └── ...
| ├── manage.py
| └── .env
├── data/
| └── ...
├── docker/
| └── docker-compose.yml
├── frontend/ # React app (Create React App)
| ├── courserec
| │ ├── package.json
| | ├── public/
| │ └── src/
| │ └── ...
├── fine-tuning
| ├── fine-tuning-gpt04mini.py
| ├── testing-fine-tuned-model.py
├── pre-processing
| ├── chattypeconversion.py
| ├── question.py
| ├── train_val_spilt.py
| └──validate.py
├── README.md
├── requirements.txt
└── .gitignore
- Python 3.8+
- Node.js 14+
- npm or yarn
- pip
- docker
Create a .env file in the backend directory as show in the Project Structure. Inside the .env file store your OPENAI API key as such
OPENAI_API_KEY = ....
- This chatbot works using a fine-tuned LLM model. To fine tune your LLM model, use the
train.jsonlandval.jsonlfiles in thedatadirectory. - To fine-tune your model, please refer to the OPENAI API docs
- Replace the name of your fine-tuned model with
ft:gpt-4o-mini-2024-07-18:hamza::AwwppreQin thebackend/recommend/usemodel.pyfile
- Create a virtual environment and activate it:
python -m venv env
source env/bin/activate # On Windows: env\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Navigate to the docker directory:
cd docker- Start the container
docker-compose -f docker-compose.yml up- Navigate to the backend directory:
cd backend- Apply migrations and run the server:
python manage.py migrate
python manage.py runserverThe backend server will run at: http://127.0.0.1:8000/
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Start the development server:
npm run devThe frontend will run at: http://localhost:5173/
Ensure that API calls from React are directed to the correct backend URL. You can use environment variables (.env) or proxy settings in package.json:
"proxy": "http://127.0.0.1:8000"- Collect static files:
python manage.py collectstatic- Build React app:
npm run build - Copy the contents of
frontend/build/into Django's static directory or configure Django to serve it.
python manage.py testnpm test # or yarn testThis project is licensed under the MIT License
Pull requests are welcome! For major changes, please open an issue first to discuss what you’d like to change.