Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
Migrate to rasa v2.3.3
Browse files Browse the repository at this point in the history
Update packages, and requirements.txt.
Use rasa x instead of the demo web app, since the rasa-webchat widget is outdated (see botfront/rasa-webchat#344).
Update the screencast to demonstrate rasa x interactive mode.
  • Loading branch information
Tim-Abwao committed Feb 26, 2021
1 parent 7670d77 commit ee458be
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 213 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
venv
__pycache__
*.db
events.*
49 changes: 18 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,44 @@ A simple chatbot that's fun to talk to. Powered by [Rasa][1].
- Number and history facts courtesy of [Numbers API][2].
- Jokes courtesy of the [Official Jokes API][3].

## Prerequisites

- [Python][4], and some knowledge of *Rasa* (check out [Rasa Basics][5]).
- An internet connection to fetch content from the APIs.

## Getting started

- Download the files, and create a virtual environment:
1. Download the necessary files:

```bash
git clone https://github.com/Tim-Abwao/rasa-chatbot.git
cd rasa-chatbot
```

2. Create a virtual environment, and install the required packages:

```bash
python3 -m venv venv
source venv/bin/activate
pip install -U pip
pip install rasa Flask
pip3 install rasa-x --extra-index-url https://pypi.rasa.com/simple
```

- Train the chatbot, then run `run.sh` to launch it:
3. Start [Rasa X][4] using the `run.sh` script:

```bash
cd trivia-chatbot && rasa train
cd .. && bash run.sh
rasa x
```

The [Rasa Webchat][6] widget (by [Botfront][7]) provides a nice interface to the chatbot from websites. The `run.sh` script in the `rasa-chatbot` directory sets up a demo webpage using [flask][8], then starts the *Rasa action server* and the *Rasa* chatbot server.
The script:

![run script](screencasts/script-run.gif)
- Activates the Python virtual environment (default *venv*), if present.
- Trains a model for the chatbot, if one doesn't yet exist.
- Starts the *rasa action server*, and *rasa x server* - which additionally opens a browser tab to its user interface.
Once you see the line *"Rasa server is up and running"*, head on to <localhost:5000> in your favourite browser:
Please visit the [rasa x user guide][4] to learn more about its features.
![web widget](screencasts/web-chat.gif)

When you're done, just close the demo webpage browser tab, and use `Ctrl + C` to terminate the *Rasa* processes running in the terminal.
Next time you wish to start the chatbot, you'll just have to run the `run.sh` script.

```bash
bash run.sh
```
![rasa x ui](screen.gif)
## Deployment Options
Please see [Messaging & Voice Channels][9] for help on how to make the chatbot available on various platforms. Options include:
Please see [Messaging & Voice Channels][5] for help on how to make the chatbot available on various platforms. Options include:
- Your own website *(as in the Webchat demo above)*
- Your own website
- Facebook Messenger
- Slack
- Telegram
Expand All @@ -66,9 +57,5 @@ Please see [Messaging & Voice Channels][9] for help on how to make the chatbot a
[1]: https://rasa.com
[2]: http://numbersapi.com
[3]: https://official-joke-api.appspot.com/random_joke
[4]: https://www.python.org
[5]: https://rasa.com/docs/rasa/playground
[6]: https://github.com/botfront/rasa-webchat
[7]: https://botfront.io/
[8]: https://flask.palletsprojects.com/en/1.1.x/
[9]: https://rasa.com/docs/rasa/messaging-and-voice-channels/
[4]: https://rasa.com/docs/rasa-x/
[5]: https://rasa.com/docs/rasa/messaging-and-voice-channels/
12 changes: 0 additions & 12 deletions demo-web-app/app.py

This file was deleted.

27 changes: 0 additions & 27 deletions demo-web-app/templates/demo.html

This file was deleted.

140 changes: 72 additions & 68 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,139 +1,143 @@
absl-py==0.10.0
aio-pika==6.7.1
absl-py==0.11.0
aio-pika==6.8.0
aiofiles==0.6.0
aiohttp==3.6.3
aiohttp==3.7.4
aiormq==3.3.1
APScheduler==3.6.3
alembic==1.4.3
APScheduler==3.7.0
astunparse==1.6.3
async-generator==1.10
async-timeout==3.0.1
attrs==20.2.0
boto3==1.16.20
botocore==1.19.20
cachetools==4.1.1
certifi==2020.11.8
cffi==1.14.3
attrs==19.3.0
bidict==0.21.2
boto3==1.17.16
botocore==1.20.16
cachetools==4.2.1
certifi==2020.12.5
cffi==1.14.5
chardet==3.0.4
click==7.1.2
cloudpickle==1.4.1
cloudpickle==1.6.0
colorclass==2.2.0
coloredlogs==14.0
colorhash==1.0.2
cryptography==3.2.1
coloredlogs==14.3
colorhash==1.0.3
croniter==1.0.6
cryptography==3.4.6
cycler==0.10.0
decorator==4.4.2
dm-tree==0.1.5
dnspython==1.16.0
docopt==0.6.2
fbmessenger==6.0.0
Flask==1.1.2
future==0.18.2
gast==0.3.3
google-auth==1.23.0
gast==0.4.0
gitdb==4.0.5
GitPython==3.1.13
google-auth==1.27.0
google-auth-oauthlib==0.4.2
google-pasta==0.2.0
grpcio==1.33.2
grpcio==1.35.0
h11==0.9.0
h5py==2.10.0
httpcore==0.11.1
httplib2==0.18.1
httplib2==0.19.0
httptools==0.1.1
httpx==0.15.4
humanfriendly==8.2
humanfriendly==9.1
idna==2.10
importlib-metadata==2.0.0
itsdangerous==1.1.0
Jinja2==2.11.2
isodate==0.6.0
jmespath==0.10.0
joblib==0.15.1
jsonpickle==1.4.1
jsonpickle==1.5.2
jsonschema==3.2.0
kafka-python==2.0.2
kafka-python==1.4.7
Keras-Preprocessing==1.1.2
kiwisolver==1.3.1
Markdown==3.3.3
Mako==1.1.4
Markdown==3.3.4
MarkupSafe==1.1.1
matplotlib==3.3.3
matplotlib==3.3.4
mattermostwrapper==2.2
multidict==4.7.6
multidict==5.1.0
natsort==7.1.1
networkx==2.5
numpy==1.19.4
numpy==1.16.6
oauth2client==4.1.3
oauthlib==3.1.0
opt-einsum==3.3.0
packaging==20.4
packaging==20.9
pamqp==2.3.0
Pillow==8.0.1
pkg-resources==0.0.0
prompt-toolkit==2.0.10
protobuf==3.14.0
pika==1.2.0
Pillow==8.1.0
prompt-toolkit==3.0.16
protobuf==3.15.3
psycopg2-binary==2.8.6
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.20
pydot==1.4.1
PyJWT==1.7.1
pykwalify==1.7.0
pydot==1.4.2
PyJWT==2.0.0
pykwalify==1.8.0
pymongo==3.10.1
pyparsing==2.4.7
pyrsistent==0.17.3
pyTelegramBotAPI==3.7.6
python-crfsuite==0.9.7
python-dateutil==2.8.1
python-editor==1.0.4
python-engineio==3.13.2
python-socketio==4.6.0
python-telegram-bot==12.8
pytz==2020.4
PyYAML==5.3.1
python-socketio==5.0.4
pytz==2020.5
questionary==1.5.2
rasa==2.1.0
rasa-sdk==2.1.1
rasa==2.3.3
rasa-sdk==2.3.1
rasa-x==0.37.0
redis==3.5.3
regex==2020.9.27
requests==2.25.0
requests==2.25.1
requests-oauthlib==1.3.0
requests-toolbelt==0.9.1
rfc3986==1.4.0
rocketchat-API==1.9.1
rsa==4.6
rsa==4.7.2
ruamel.yaml==0.16.12
ruamel.yaml.clib==0.2.2
s3transfer==0.3.3
sanic==20.9.1
s3transfer==0.3.4
sanic==20.12.2
Sanic-Cors==0.10.0.post3
sanic-jwt==1.4.1
Sanic-Plugins-Framework==0.9.4.post1
scikit-learn==0.23.2
scipy==1.5.4
sentry-sdk==0.19.3
sanic-jwt==1.6.0
Sanic-Plugins-Framework==0.9.5
scikit-learn==0.24.1
scipy==1.6.1
sentry-sdk==0.19.5
six==1.15.0
sklearn-crfsuite==0.3.6
slackclient==2.9.3
smmap==3.0.5
sniffio==1.2.0
SQLAlchemy==1.3.20
tabulate==0.8.7
tensorboard==2.4.0
tensorboard-plugin-wit==1.7.0
tensorflow==2.3.1
tensorflow-addons==0.11.2
SQLAlchemy==1.3.23
tabulate==0.8.9
tensorboard==2.4.1
tensorboard-plugin-wit==1.8.0
tensorflow==2.3.2
tensorflow-addons==0.12.0
tensorflow-estimator==2.3.0
tensorflow-hub==0.9.0
tensorflow-hub==0.10.0
tensorflow-probability==0.11.1
tensorflow-text==2.3.0
termcolor==1.1.0
terminaltables==3.1.0
threadpoolctl==2.1.0
tornado==6.1
tqdm==4.50.2
twilio==6.45.4
typeguard==2.10.0
tqdm==4.56.2
twilio==6.50.1
typeguard==2.11.1
typing-extensions==3.7.4.3
tzlocal==2.1
ujson==3.2.0
urllib3==1.26.2
ujson==1.35
urllib3==1.26.3
uvloop==0.14.0
wcwidth==0.2.5
webexteamssdk==1.6
websockets==8.1
Werkzeug==1.0.1
wrapt==1.12.1
yarl==1.5.1
zipp==3.4.0
yarl==1.6.3
26 changes: 13 additions & 13 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/usr/bin/env bash

# activate Python virtual environment
source venv/bin/activate
# Activate the Python virtual environment
if [ -d venv ]
then
source venv/bin/activate
fi

# Flask web app
export FLASK_APP=demo-web-app/app
export FLASK_ENV=development
flask run &
flask_server_pid=$!

# Action server & Rasa server
cd trivia-chatbot
rasa run actions &
rasa run --cors "*"

# stop flask web app
kill $flask_server_pid;
# Train the chatbot if no model is present
if [ ! -d models ]
then rasa train
fi

# Start the action server & Rasa X
rasa run actions &
rasa x
Binary file added screen.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed screencasts/script-run.gif
Binary file not shown.
Binary file removed screencasts/web-chat.gif
Binary file not shown.
2 changes: 1 addition & 1 deletion trivia-chatbot/actions/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def run(self, dispatcher: CollectingDispatcher, tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
joke_content = requests.get(
'https://official-joke-api.appspot.com/random_joke'
).json()
).json()
joke = f"{joke_content['setup']}... {joke_content['punchline']}"
dispatcher.utter_message(joke)
return []
4 changes: 4 additions & 0 deletions trivia-chatbot/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ pipeline:
# max_ngram: 4
# - name: DIETClassifier
# epochs: 100
# constrain_similarities: true
# model_confidence: cosine
# - name: EntitySynonymMapper
# - name: ResponseSelector
# epochs: 100
# constrain_similarities: true
# model_confidence: cosine
# - name: FallbackClassifier
# threshold: 0.3
# ambiguity_threshold: 0.1
Expand Down
Loading

0 comments on commit ee458be

Please sign in to comment.