Cool little bash script with options to train nlu, train core, or run bot in terminal


(Christopher Celotto) #1

Hi everyone - I wanted to make a little something to avoid going through terminal history / copying and pasting the commands to train nlu model, train core, and run the bot every time. I wrote a little bash script to make it more convenient! I figured I’d share it on here for anyone else who is looking for a little convenience boost.

This was much easier than trying to create a python file to do a similar thing. Feel free to adjust the actual training command parameters to your specific needs. I also added some color options for fun too. Enjoy!

#!/bin/bash

GREEN='\033[0;32m' #green color
BLUE='\033[0;34m' #blue color
CYAN='\033[0;36m' #cyan color
PURPLE='\033[0;35m' #purple color
NC='\033[0m' #no color
RED='\033[0;31m' # red color

echo -e "${BLUE}Hi there! What would you like to do? Please enter one of the following numbers.${NC}
	
	1.   train nlu
	2.   train core
	3.   run bot"

read input

if [[ $input == "1" || $input == "1" ]]; then
        python -m rasa_nlu.train -c config.yml --data data/nlu_data -o models --fixed_model_name nlu_model --project current --verbose
elif [[ $input == "2" || $input == "2" ]]; then
        python -m rasa_core.train -d domain.yml -s data/stories -o models/current/dialogue --epochs 300
elif [[ $input == "3" || $input == "3" ]]; then
        python -m rasa_core.run -d models/current/dialogue -u models/current/nlu_model
else
        echo -e "${RED}Error${NC}: invalid entry. Please run ./bot again and select 1, 2, or 3."
fi

Just navigate to your directory, type the command below, and thats it!

./bot


(Saqib Ahmed) #2

Suggestion:

It would be great to make it more generic by adding the options to take user input for the domain, story, and the NLU training files at least.

Ideally, this script should be able to take all the input parameters of the train/run scripts by prompting the user for input with having some sensible defaults if the user doesn’t give any input.


(Christopher Celotto) #3

That sounds like a cool idea. Do you have any suggestions on how to do that? Please feel free to edit the code and repost.