An AI chatbot for the Ontario Centre of Forensic Sciences (CFS), developed using Rasa and OpenAI. Answers forensics investigators' questions by performing semantic search across a large library of CFS technical documents to find the most relevant search results.
- Linux OS
- Ubuntu 18.04 / 20.04
- Debian 9 / 10
- Red Hat 7 / 8
- CentOS 7 / 8
Python 3.8
pip 21.1.3
docker
docker-compose
python3 -m venv ~/rasa-cfs-env
cd ~/rasa-cfs-env
source ./bin/activate
git clone https://github.com/aoruize/rasa-cfs.git
cd rasa-cfs
pip install -r requirements.txt
Ensure you have access to the OpenAI Beta API. Login to OpenAI and copy your API key from https://beta.openai.com/docs/developer-quickstart/your-api-keys.
To temporarily add the environment variable, run the following command in the terminal, using your own API key:
export OPENAI_API_KEY='sk-...'
To add the environment variable to the operating system permanently, add it to your shell configuration files. Add the above command to the end of the following files:
~/.bashrc
~/.profile
cd ~/rasa-cfs-env/rasa-cfs
rasa run actions
-
Download
curl -sSL -o install.sh https://storage.googleapis.com/rasa-x-releases/0.41.1/install.sh
-
Install all files into default folder,
/etc/rasa
:sudo bash ./install.sh
-
Start up Rasa X and wait until all containers are running (Using
-d
will run Rasa X in the background):cd /etc/rasa sudo docker-compose up -d
-
Access and set admin password:
cd /etc/rasa sudo python3 rasa_x_commands.py create --update admin me <PASSWORD>
Navigate to the hostname or IP where your server is reachable and log in using your newly created password.
Learn more: https://rasa.com/docs/rasa-x/installation-and-setup/install/docker-compose
- This repository is set up with a GitHub Actions workflow, so that whenever a change is pushed to the
actions
directory, a new Docker image for the Custom Action Server will be built and pushed to a container registry.
To specify which container registry and image name, open .github/workflows/action_server.yml
and change docker_image_name:
to your desired Docker registry and image name.
Also, follow the instructions in Building an Action Server Image to specify your docker_registry_login:
and docker_registry_password:
.
-
Add OpenAI API key environment variable to .env file:
cd /etc/rasa vim .env
Add your API key to the bottom of the file:
OPENAI_API_KEY=sk-...
-
Replace the default
app
image with the image of your custom action server:To avoid your changes in the docker-compose file being overwritten when you update versions, you should not apply your changes to
docker-compose.yml
. Instead, create a new file calleddocker-compose.override.yml
inside your/etc/rasa
directory and apply your changes there. Docker will automatically take that file into account and override any attributes indocker-compose.yml
with changes from the override file.The contents of
docker-compose.override.yml
should look like this:version: '3.4' services: app: restart: always image: <image:tag> expose: - "5055" environment: OPENAI_API_KEY: "${OPENAI_API_KEY}"
-
If your Docker containers are already running, take them down and then start Rasa X again:
cd /etc/rasa sudo docker-compose down sudo docker-compose up -d
Learn more: https://rasa.com/docs/rasa-x/installation-and-setup/customize#connecting-a-custom-action-server
Rasa Open Source: https://rasa.com/docs/rasa/
Rasa X: https://rasa.com/docs/rasa-x/
Rasa Action Server: https://rasa.com/docs/action-server
Implement in-house semantic search instead of using OpenAI by following this guide: