This project implements a multi-client chatbot system with a Python server powered by Hugging Face Transformers and a Python client for user interaction. The server handles multiple concurrent clients using multi-threading, and the client provides a command-line interface with mood-based interactions.
- Client-server architecture over TCP
- AI chatbot powered by Hugging Face
DialoGPT-medium - Multi-threaded server for concurrent client support
- Commands:
/help,/exit,/clear,/sysinfo - Mood options:
default,sarcastic,enthusiastic,serious - Monorepo structure
server/:src/: Server source codetests/: Server unit testsrequirements.txt: Server dependencies
client_python/:src/: Client source codetests/: Client unit testsrequirements.txt: Client dependencies
shared_docs/: Architecture and protocol documentationscripts/: Utility scripts for running components
- Python 3.8+
- Git
- (Optional) Conda (if using Conda for environment management)
-
Clone the Repository:
git clone https://github.com/moaz-loaie/chatbot.git cd chatbot -
Server Setup:
-
Unix-like systems:
cd server python -m venv venv_server source venv_server/bin/activate pip install -r requirements.txt cd ..
-
Windows:
cd server python -m venv venv_server venv_server\Scripts\activate pip install -r requirements.txt cd ..
-
-
Client Setup:
-
Unix-like systems:
cd client_python python -m venv venv_client source venv_client/bin/activate pip install -r requirements.txt cd ..
-
Windows:
cd client_python python -m venv venv_client venv_client\Scripts\activate pip install -r requirements.txt cd ..
-
If you prefer to use Conda for managing environments, follow these steps:
conda env create -p server_env -f environment.yml
conda activate server_envconda env create -p client_env -f environment.yml
conda activate client_envNote: Ensure you have Conda installed. If not, refer to the Conda installation guide.
-
Start the Server:
-
Unix-like systems:
cd server source venv_server/bin/activate python src/main_server.py
-
Windows:
cd server venv_server\Scripts\activate python src/main_server.py
-
-
Start the Client:
-
In a new terminal:
-
Unix-like systems:
cd client_python source venv_client/bin/activate python src/main_client.py
-
Windows:
cd client_python venv_client\Scripts\activate python src/main_client.py
-
-
-
Start the Server:
-
Activate the server environment:
conda activate server_env
-
Run the server:
python server/src/main_server.py
-
-
Start the Client:
-
In a new terminal, activate the client environment:
conda activate client_env
-
Run the client:
python client_python/src/main_client.py
-
Alternatively, you can use the provided scripts for convenience:
-
Unix-like systems:
- Start the server:
./scripts/run_server.sh - Start the client:
./scripts/run_python_client.sh
- Start the server:
-
Windows:
- Start the server:
scripts\run_server.bat - Start the client:
scripts\run_python_client.bat
- Start the server:
Note: Ensure you run the server before starting any clients.
- Type messages or commands (e.g.,
/help). - Select a mood when prompted.
The project includes unit tests for both the server and client components. These tests use Python's built-in unittest module, so no additional libraries are required beyond the standard Python installation.
-
Navigate to the
server/directory. -
Activate the server environment:
- Virtual environment:
source venv_server/bin/activate(Unix) orvenv_server\Scripts\activate(Windows) - Conda:
conda activate server_env
- Virtual environment:
-
Run the tests:
python -m unittest discover tests
-
Navigate to the
client_python/directory. -
Activate the client environment:
- Virtual environment:
source venv_client/bin/activate(Unix) orvenv_client\Scripts\activate(Windows) - Conda:
conda activate client_env
- Virtual environment:
-
Run the tests:
python -m unittest discover tests
- Logs are saved in
logs/directories withinserver/andclient_python/. - Ensure the server is running before starting clients.
- The AI model is loaded once at server startup for efficiency, as implemented in
ai_model_interface.py.