Configuring the working environment

Video



Now that you are familiar with key building blocks of CALM, it's time to see how you can use Rasa Pro to start building your own custom conversational AI assistant. Rasa Pro extends Rasa Open Source and adds all of the capabilities of CALM, Rasa's conversational AI with language models. In this chapter, we're going to look at how you can configure your development environment and how you can get started with building your own custom conversational AI assistant. All of the instructions that we are going to cover in this chapter are also available in the Rasa Pro documentation.

Configuring Python environment

Configuring your development environment and installing Rasa Pro on your machine is a quick process that takes only a few steps. The first step is configuring your Python environment. At the time of making this video, Rasa supports a few specific Python versions: Python 3.8, 3.9, and 3.10. So, you need to make sure that you have at least one of these versions of Python installed on your machine. You can quickly check that by using the command:

python --version

In a situation where you don't have Python installed on your machine, or if you have a version that doesn't meet the provided requirements, you can update your Python installation using the instructions provided in Rasa's documentation. You will find the instructions for macOS, Ubuntu, and Windows.

Creating a virtual environment

It is highly recommended to use virtual environments to isolate your Python projects. This ensures that any dependencies you install will be project-specific and will not cause conflicts with other dependencies installed system-wide. The next step is to create a Python virtual environment and activate it. Before doing that, create a project directory for the assistant and refer to this directory as the project directory throughout this chapter.

mkdir rasa-calm-demo cd rasa-calm-demo

Now we can create the virtual environment for the project and activate it:

python --version source ./venv/bin/activate

Installing Rasa Plus

Under the hood, Rasa Pro contains a Python package called Rasa Plus, which you can install locally using either pip, the Python package manager, or poetry, a tool that makes it much easier to build, manage, and publish packages in a simple way. The instructions for both options are available in the documentation and include only some simple configurations. For example, if you decide to use pip, you will simply have to edit pip.conf and provide the following configurations:

[global]
extra-index-url = https://europe-west3-python.pkg.dev/rasa-releases/rasa-pro-python/simple/

You can find the instructions on how to find the pip.conf file on your machine by following the instructions in the Rasa's documentation.

Once you do the configuration, you can simply install Rasa Plus using the provided command:

pip install rasa-pro

It's very similar if you decide to use poetry. The first thing that you will have to do is to make sure that you have poetry installed on your machine, either poetry 1.4 or poetry 1.6, and provide the necessary configurations in the project.toml file:

[[tool.poetry.source]]
name = "rasa-pro"
url = "https://europe-west3-python.pkg.dev/rasa-releases/rasa-pro-python/simple"
priority = "supplemental"

You can create the project.toml file inside of the root of your working project and provide the configurations listed above. Once the configuration is finished, save the changes and install rasa-plus using the command:

poetry install

The process of installing the dependencies will take anything from a few seconds to a few minutes depending on your operating system.

Getting the Rasa Pro Developer Edition license

Rasa Pro will look for a license in the environmental variable called Rasa_Pro_License. Rasa Pro license is necessary to make sure that you are using the right Rasa Pro version for your project. Rasa Pro comes with a few different licenses, but if you are getting started with building with CALM, you can use the Rasa Pro Developer Edition license, which provides you a free license that enables you to use Rasa Pro completely for free and take advantage of all of the available features and build your application using CALM locally. To get the Rasa Pro Developer Edition license, head to the Rasa Pro license page. To request the license, you will simply have to provide your email address where your Developer Edition license for Rasa Pro will be provided. Once you hit submit, you will immediately receive your Rasa Pro Developer Edition license, which you will be able to use to start building with CALM. You can set your Rasa Pro license as an environmental variable temporarily in your terminal by using the command:

export RASA_PRO_LICENSE=<your-license-string>

It's highly recommended to set it persistently as well so that it is always available and you don't have to set it up every time you run Rasa Pro. To do that, you can follow up with a provided command:

echo "export RASA_PRO_LICENSE=<your-license-string>" >> ~/.bashrc

This will write your Rasa Pro license string in your bash profile and will make it available on your system for every time you're using Rasa Pro.

Creating an example project

The easiest way to get started with building your assistant is by running the command:

rasa init --template tutorial

This command will create the project directory for your CALM project and even provide a very simple example of an assistant built with CALM that you can either use as an example or even use this example project to start building your own custom assistant. This tutorial contains an assistant that is built for completing tasks like money transfer and others.

Getting an OpenAI API key

In order to follow this tutorial, you will have to set up your OpenAI API key. This will be necessary for your assistant to be able to interact with LLMs. To get the API key, you will have to navigate to the OpenAI page, login, and choose the API option on the OpenAI site. Here, you will see you have an option to see your API keys. Here you can hit create new secret key which will create your new API key. You can provide the name and get your secret key right away. The secret key will then have to be configured as an environmental variable as well by simply exporting this under OPENAI_API_KEY variable name:

export OPENAI_API_KEY=your-api-key

Interacting with the example assistant

Once you have the OpenAI API key set up, you can use the command rasa init and add the flag --template tutorial which will create an example project folder for you and let you code along with this tutorial. It is a fully functioning AI assistant that is capable of completing very simple tasks like transferring money and others. By following the prompt in the command line you will be able train the example assistant and interact with it. Most importantly, you will be able to see all of the files under the hood used to create this assistant.

You will see an example of flows, an example of domain, even the implementation of some custom actions. We will cover these files and configurations in more detail a little bit later in the series.


2016-2024 © Rasa.