Skip to content

Instantly share code, notes, and snippets.

@BrunoCodeman
Last active November 22, 2018 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrunoCodeman/e2a310903da0bdbd21c6754df355d420 to your computer and use it in GitHub Desktop.
Save BrunoCodeman/e2a310903da0bdbd21c6754df355d420 to your computer and use it in GitHub Desktop.
Create RASA project with python
# create python venv
echo "creating virtualenv for $1 ";
mkdir -p ~/.venvs;
python3.6 -m venv ~/.venvs/$1;
source ~/.venvs/$1/bin/activate ;
echo "Done!!!";
#installing dependencies
echo "Installing dependencies for $1 ";
~/.venvs/$1/bin/pip install pip --upgrade rasa_core rasa_core_sdk numpy==1.14.5 spacy==2.0.12 rasa_nlu[spacy];
#creating project folder
echo "creating project folder for $1 ";
mkdir $1 && cd $1;
echo "Done!!!";
#creating project files
echo "Adding files for $1 ";
~/.venvs/$1/bin/pip freeze >> requirements.txt;
echo "## saudacao
* saudacao
- utter_saudacao
- utter_perguntar_nome
* informar_nome{\"nome\" : \"Bruno\"}
- slot{\"nome\": \"Bruno\"}
- utter_elogiar_nome
## saudacao2
* saudacao
- utter_saudacao
- utter_perguntar_nome
* informar_nome{\"nome\" : \"Evelyn\"}
- slot{\"nome\": \"Evelyn\"}
- utter_elogiar_nome
## saudacao3
* saudacao
- utter_saudacao
- utter_perguntar_nome
* informar_nome{\"nome\" : \"Paulo\"}
- slot{\"nome\": \"Paulo\"}
- utter_elogiar_nome
## saudacao4
* saudacao
- utter_saudacao
- utter_perguntar_nome
* informar_nome{\"nome\" : \"Roseli\"}
- slot{\"nome\": \"Roseli\"}
- utter_elogiar_nome
## despedida
* despedida
- utter_despedida
" >> stories.md;
echo "## intent:saudacao
- Oi
- Olá
- Bom dia
- Boa tarde
- Boa noite
## intent:despedida
- Tchau
- Adeus
- Até logo
- Flw
##intent: informar_nome
- [Paulo](nome)
- [Bruno](nome)
- [Evelyn](nome)
- [Roseli](nome)
- Meu nome é [Paulo](nome)
- Me chamo [Bruno](nome)
- Meu nome é [Evelyn](nome)
- Me chamo [Roseli](nome)
" >> nlu.md;
echo "
language: pt
pipeline: tensorflow_embedding" >> nlu_config.yml;
echo 'intents:
- saudacao
- despedida
- informar_nome
actions:
- utter_saudacao
- utter_despedida
- utter_perguntar_nome
- utter_elogiar_nome
slots:
nome:
type: text
templates:
utter_saudacao:
- text: "Olá! Como vai?"
utter_despedida:
- text: "Até logo!"
utter_perguntar_nome:
- text: "Como tu te chamas?"
utter_elogiar_nome:
- text: "{nome}? Que nome bonito!"' >> domain.yml;
echo "Done!!!";
read -n 1 -p "Treinar modelo? (s/n): " userinput
if [ "$userinput" = "s" ]; then
echo " Treinando modelo... ";
~/.venvs/$1/bin/python -m rasa_core.train -d domain.yml -s stories.md -o models/dialogue &&
~/.venvs/$1/bin/python -m rasa_nlu.train -c nlu_config.yml --data nlu.md -o models --fixed_model_name nlu --project current --verbose
fi
read -n 1 -p " Testar modelo? (s/n): " testinput
if [ "$testinput" = "s" ]; then
echo " Iniciando conversa... ";
~/.venvs/$1/bin/python -m rasa_core.run -d models/dialogue -u models/current/nlu
fi
read -n 1 -p " Executar API? (s/n): " runapi_input
if [ "$runapi_input" = "s" ]; then
echo " Iniciando API... ";
~/.venvs/$1/bin/python -m rasa_core_sdk.endpoint --actions actions
fi
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment