BotCycle offers personalized recommendations of bike availabilities and contextual information of a city through a natural interaction via a chatbot.
The module brain
receives and sends messages and is the main component of the bot
The module nlu
contains some experiments on Natural Language Understanding. For the moment it is standalone and not used by the brain
module.
This repository requires python 3
sudo apt install python3-pip python3-venv libgeos-dev
export LC_ALL=C # locale
sudo pip3 install virtualenv
- Clone/download this repository
- For each of the modules install the dependencies in a virtual environment:
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
To use the language models for NLU at runtime, it is required to train them.
The training is done on the preprocessed datasets wit_en
and wit_it
that can be found in the nlu/data
folder.
The training and saving can be done by running cd nlu && make build_models
, that will place in the brain/botcycle/nlu/joint/results/
folder the results that will be loaded later at runtime.
Launch the bot: python main.py
Alternatively, you can use docker-compose
The instruction refer to ubuntu distribution. You can adapt them easily to other linux distributions.
- Install
docker-compose
package:sudo apt install docker-compose
- Check the status of the docker-daemon:
systemctl status docker
- If the daemon is not running, start it:
systemctl start docker
. Consider using auto-start of the daemon at system boot (systemctl enable docker
/systemctl disable docker
) - Allow your user to run docker without sudo:
- Create the docker group if not exist:
sudo groupadd docker
- Add the desired user to the docker group:
sudo gpasswd -A $USER docker
- Either do a
newgrp docker
or log out/in to activate the changes to groups
When using the dockerized components, training the models can be a bit more complicated.
If you have the dependencies installed on your host (directly or indirectly via virtualenv
), you can follow the instructions relative to "without docker" choice, and thanks to volume mapping they will be available inside the containers.
Instead if you want to train the models from the containers the steps are the following:
- start one of the bot containers (
docker start CONTAINER_NAME
or usingdocker-compose start
) - enter interactively in it:
docker exec -it CONTAINER_NAME bash
- go to the makefile location:
cd /nlu
- run the correct make target:
make build_models
- exit from the container
- Make sure you are in top folder of this repository, where the
docker-compose.yml
file is located - Run
docker-compose up
to: - Build the images (if not yet available)
- Create the containers (if not created yet)
- Create the network (if not created yet)
- Start the containers
After the first run, you will be in interactive mode: the console output of the containers are routed to your console. To stop the containers type CTRL+C. For successive runs, you can simply use docker-compose start
that will start the containers and keep them in the background. You can stop then by running docker-compose stop
, or see the logs of a container with docker-compose logs CONTAINER_NAME
.
The brain module requires some environment variables, see the module README.md
.
You may need the mongo cli to explore the database: sudo apt install mongo-clients
The bot understands three intents:
- search a bike
- search an empty slot
- plan a trip
- set the user position (useful for other intents with missing entities)
The position can be sent as an attachment in any moment, also when the bot does not make request.