This project is a Python-based chatbot that uses various dependencies, including some that may require Rust for building. This README provides step-by-step instructions on how to set up the project, build the Docker image, and run the application.
- Prerequisites
- Project Structure
- Docker Setup
- Handling Rust Dependency
- Running the Application
- Troubleshooting
- License
Before you begin, ensure you have the following installed on your local machine:
The project structure should look something like this:
├── Dockerfile
├── requirements.txt
├── chatbot_training.py
├── chat.py
└── README.md
The Dockerfile is used to create a Docker image for the chatbot application. It installs all necessary dependencies, including Rust and Cargo, which are required for some Python packages.
# Use an official Python runtime as a base image
FROM python:3.10-slim
# Install Rust and Cargo
RUN apt-get update && apt-get install -y curl \
&& curl https://sh.rustup.rs -sSf | sh -s -- -y \
&& source $HOME/.cargo/env
# Set the working directory in the container
WORKDIR /app
# Copy the requirements file into the container
COPY requirements.txt .
# Install any needed packages specified in requirements.txt
RUN pip install -r requirements.txt
# Copy the rest of the application code into the container
COPY . .
# Expose the application port
EXPOSE 8000
# Define the command to run your application
CMD ["python", "chatbot_training.py"]
To build the Docker image, navigate to the project directory in your terminal and run the following command:
docker build -t chatbot:latest .
After building the image, you can run the Docker container using:
docker run -p 8000:8000 chatbot:latest
This command will start the application and map port 8000 from the container to port 8000 on your host machine.
Some Python packages in this project require Rust and Cargo to compile. The Dockerfile includes steps to install Rust and Cargo to handle these dependencies. If you encounter errors related to Rust during the build process, ensure that Rust is properly installed and available in the PATH.
The application can be run in two separate terminals:
-
Terminal 1: Run the chatbot training script.
python chatbot_training.py
This script preprocesses the data, trains the model, and saves the necessary objects.
-
Terminal 2: Run the chat interface.
python chat.py
This script starts the chat interface where you can interact with the trained chatbot.
If you encounter issues related to Rust or Cargo not being installed:
- Ensure that Rust is installed on your system or in your Docker environment.
- Rebuild the Docker image after making sure Rust is available.
If you experience dependency version conflicts, consider updating your requirements.txt
to compatible versions or consult the documentation for the specific package.
If you see notices about an outdated version of pip
, you can update it by adding this line to your Dockerfile before the pip install
command:
RUN python -m pip install --upgrade pip