Skip to content

Install from source code

Ali Razmdideh edited this page Aug 8, 2021 · 15 revisions

Install from source code

Clone Rasa branch

git clone https://github.com/arezae/chatbot --branch rasa --single-branch --depth 1

Directory tree

To run the Rasa chatbot, we need to run actions-server and chatbot-server separately. So we've separated actions, datasets, and the chatbot from each other.

Action-Server will contain actions and datasets, and Rasa-Server will contain the chatbot model and its autocorrect component.

production/
├── action-server
│   ├── actions
│   └── docker
├── mysql-server
└── rasa-server
    ├── autocorrect
    │   └── data
    ├── docker
    └── rasa
        ├── data
        └── tests

In the rest of the document, we will install requirements and then run chatbot and action servers.

Install requirements

Create python environment

pip install --user --upgrade pip
pip install --user virtualenv
python -m venv rasa_env

Activate your python environment

source virtualenv/bin/activate

Install rasa chatbot requirements

pip install --no-cache-dir -r production/rasa-server/requirements.txt

Install rasa chatbot server and actions server requirements

pip install --no-cache-dir -r production/rasa-server/requirements.txt -r production/action-server/requirements.txt

Download Spacy weights

python -m spacy download en_core_web_md

Download the autocorrect module dictionaries. This dictionary consists of English and medical words.

cd production/rasa-server
python -c "import autocorrect; autocorrect.Speller('en_med')"

Train rasa model ⌛

cd production/rasa-server/rasa
rasa train

You can also download model weights from Dropbox.

Run rasa server

We are almost done. Now we can run the rasa and actions server.

  • Run the Rasa server. If you would like to run the Rasa server with tokens to authenticate requests, You can add --auth-token YOUR_TOKEN at the end of the following command
cd production/rasa-server/rasa
mkdir logs
rasa run --log-file logs/rasa-server.log --enable-api

Run the MySQL server

 mysql -uroot -p"$MYSQL_ROOT_PASSWORD" datasets < mysql-server/datasets.sql

Run the action server

  • Create logs directory
cd production/action-server/actions
mkdir logs
  • Create .env file into action-server directory, to read database information:
$ cat action-server/.env
MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD
SQL_USER=root
HOST=db
MYSQL_DATABASE=datasets
DRUG_TABLE=drugs
LAB_TABLE=labs
  • Run action server
rasa run --log-file logs/action-server.log actions --actions actions

Enjoy chatting with MedBot 🤗

curl --location --request POST 'http://localhost:5005/webhooks/rest/webhook' \
--header 'Content-Type: application/json' \
--data-raw '{
    "message" : "Can you give me dosage information of Abilify?",
    "sender" : "default"
}'

More examples of sending a request to the chatbot

Clone this wiki locally