Giter VIP home page Giter VIP logo

financial-demo's Introduction

Notes on Rasa 3.x/ 2.x / 1.x

  1. The main branch of this repo is compatible with Rasa Open Source version 3.x
  2. The bot for Rasa 1.x can be found in the rasa-1 branch.

Financial Services Example Bot

This is an example chatbot demonstrating how to build AI assistants for financial services and banking. This starter pack can be used as a base for your own development or as a reference guide for implementing common banking-industry features with Rasa. It includes pre-built intents, actions, and stories for handling conversation flows like checking spending history and transferring money to another account.

Table of Contents

Install dependencies

Run:

pip install -r requirements.txt

To install development dependencies:

pip install -r requirements-dev.txt
pre-commit install
python -m spacy download en_core_web_md en
python -m spacy link en_core_web_md en

With pre-commit installed, the black and doctoc hooks will run on every git commit. If any changes are made by the hooks, you will need to re-add changed files and re-commit your changes.

Run the bot

Use rasa train to train a model.

Then, to run, first set up your action server in one terminal window, listening on port 5056:

rasa run actions --port 5056

Note that port 5056 is used for the action server, to avoid a conflict when you also run the helpdesk bot as described below in the handoff section.

In another window, run the duckling server (for entity extraction):

docker run -p 8000:8000 rasa/duckling

Then to talk to the bot, run:

rasa shell --debug

Note that --debug mode will produce a lot of output meant to help you understand how the bot is working under the hood. To simply talk to the bot, you can remove this flag.

You can also try out your bot locally using Rasa X by running

rasa x

Refer to our guided workflow in the Wiki page for how to get started with Rasa X in local mode.

Overview of the files

data/nlu/nlu.yml - contains NLU training data

data/nlu/rules.yml - contains rules training data

data/stories/stories*.yml - contains stories training data

actions.py - contains custom action/api code

domain.yml - the domain file, including bot response templates

config.yml - training configurations for the NLU pipeline and policy ensemble

tests/ - end-to-end tests

Things you can ask the bot

The bot currently has five skills. You can ask it to:

  1. Transfer money to another person
  2. Check your earning or spending history (with a specific vendor or overall)
  3. Answer a question about transfer charges
  4. Pay a credit card bill
  5. Tell you your account balance

It also has a limited ability to switch skills mid-transaction and then return to the transaction at hand.

For the purposes of illustration, the bot recognises the following fictional credit card accounts:

  • emblem
  • justice bank
  • credit all
  • iron bank

It recognises the following payment amounts (besides actual currency amounts):

  • minimum balance
  • current balance

It recognises the following vendors (for spending history):

  • Starbucks
  • Amazon
  • Target

You can change any of these by modifying actions.py and the corresponding NLU data.

If configured, the bot can also hand off to another bot in response to the user asking for handoff. More details on handoff below.

Handoff

This bot includes a simple skill for handing off the conversation to another bot or a human. This demo relies on this fork of chatroom to work, however you could implement similar behaviour in another channel and then use that instead. See the chatroom README for more details on channel-side configuration.

Using the default set up, the handoff skill enables this kind of conversation with two bots:

Try it out

The simplest way to use the handoff feature is to do the following:

  1. Clone chatroom and Helpdesk-Assistant alongside this repo
  2. In the chatroom repo, install the dependencies:
yarn install
  1. In the chatroom repo, build and serve chatroom:
yarn build
yarn serve
  1. In the Helpdesk-Assistant repo, install the dependencies and train a model (see the Helpdesk-Assistant README)
  2. In the Helpdesk-Assistant repo, run the rasa server and action server at the default ports (shown here for clarity) In one terminal window:
    rasa run --enable-api --cors "*" --port 5005 --debug
    In another terminal window:
    rasa run actions --port 5055 --debug
  3. In the Financial-Demo repo (i.e. this repo), run the rasa server and action server at the non-default ports shown below In one terminal window:
    rasa run --enable-api --cors "*" --port 5006 --debug
    In another terminal window:
    rasa run actions --port 5056 --debug
  4. Open chatroom_handoff.html in a browser to see handoff in action

How it works

Using chatroom, the general approach is as follows:

  1. User asks original bot for a handoff.
  2. The original bot handles the request and eventually sends a message with the following custom json payload:
        {
            "handoff_host": "<url of handoff host endpoint>",
            "title": "<title for bot/channel handed off to>"
            }
    
    This message is not displayed in the Chatroom window.
  3. Chatroom switches the host to the specified handoff_host
  4. The original bot no longer receives any messages.
  5. The handoff host receives the message /handoff{"from_host":"<original bot url">}
  6. The handoff host should be configured to respond to this message with something like, "Hi, I'm , how can I help you??"
  7. The handoff host can send a message in the same format as specified above to hand back to the original bot. In this case the same pattern repeats, but with the roles reversed. It could also hand off to yet another bot/human.

Bot-side configuration

The "try it out" section doesn't require any further configuration; this section is for those who want to change or further understand the set up.

For this demo, the user can ask for a human, but they'll be offered a bot (or bots) instead, so that the conversation looks like this:

For handoff to work, you need at least one "handoff_host". You can specify any number of handoff hosts in the file actions/handoff_config.yml.

handoff_hosts:
    helpdesk_assistant:
      title: "Helpdesk Assistant"
      url: "http://localhost:5005"
    ## you can add more handoff hosts to this list e.g.
    # moodbot:
    #   title: "MoodBot"
    #   url: "http://localhost:5007"

Handoff hosts can be other locally running rasa bots, or anything that serves responses in the format that chatroom accepts. If a handoff host is not a rasa bot, you will of course want to update the response text to tell the user who/what they are being handed off to.

The Helpdesk-Assistant bot has been set up to handle handoff in exactly the same way as Helpdesk-Assistant, so the simplest way to see handoff in action is to clone Financial-Demo alongside this repo.

If you list other locally running bots as handoff hosts, make sure the ports on which the various rasa servers & action servers are running do not conflict with each other.

Testing the bot

You can test the bot on the test conversations by:

  • start duckling
  • running rasa test.

This will run end-to-end testing on the conversations in tests/test_stories.yml.

All tests must pass.

Rasa X Deployment

To deploy financial-demo, it is highly recommended to make use of the one line deploy script for Rasa X.

As part of the deployment, you'll need to set up git integration to pull in your data and configurations, and build or pull an action server image.

Action Server Image

You will need to have docker installed in order to build the action server image. If you haven't made any changes to the action code, you can also use the public image on Dockerhub instead of building it yourself.

To build & tag the image, run:

export ACTION_SERVER_DOCKERPATH=<dockerID>/<name-of-image>:<tag-of-image>
make docker-build

Run the action server container:

make docker-run

Perform a smoke test on the health endpoint:

make docker-test

Once you have confirmed that the container is working, push the container image to a registry:

# login to a container registry with your credentials
docker login  

# check the registry logged into
docker system info | grep Registry

# push the action server image
make docker-push

CI/CD

Summary

As explained in the Setting up CI/CD section of the Rasa documentation, Continous Integration (CI) is the practice of merging in code changes frequently and automatically testing changes as they are committed. Continuous Deployment (CD) means automatically deploying integrated changes to a staging or production environment. Together, they allow you to make more frequent improvements to your assistant and efficiently test and deploy those changes.

A CI/CD pipeline is used to test, build and deploy the financial-demo bot to AWS EKS.

The pipeline uses GitHub Actions, defined in .github/workflows/cicd.yml. It includes these jobs:

params

  • Defines parameters for use by downstream jobs

params_summary

  • Prints the value of the parameters.

action_server

  • Builds & Tests the docker image of the action server with tag: <branch-name>
  • Uploads the docker image to the AWS ECR repository: financial-demo

rasa_model

  • Trains & Tests the rasa model with name: `models/.tar.gz
  • Uploads the trained model to the AWS S3 bucket: rasa-financial-demo

aws_eks_create_test_cluster

  • If not existing yet, creates an AWS EKS cluster with name: financial-demo-<branch-name>

deploy_to_test_cluster

  • Installs/Updates Rasa Enterprise, with the docker image created by the action_server job.
  • Deploys the rasa model, trained by the rasa_model job.
  • Performs smoke tests to ensure basic operations are all OK.

deploy_to_prod_cluster

  • Runs when pushing to the main branch, and all previous steps are successful.
  • Installs/Updates Rasa Enterprise, with the docker image created by the action_server job.
  • Deploys the rasa model, trained by the rasa_model job.
  • Performs smoke tests to ensure basic operations are all OK.

GitHub Secrets

Secrets can be added to your GitHub repository by going to Settings > Secrets and selecting New repository secret.

When entering values, be sure to omit quotes.

AWS IAM User API Keys:

To configure the aws cli in Github Actions, create IAM User API Keys as described below, and add them as GitHub secrets to the repository:

  • AWS_ACCESS_KEY_ID = Access key ID
  • AWS_SECRET_ACCESS_KEY = Secret access key

Rasa Enterprise License:

To define a pull secret in Github Actions for the private GCR repo, you'll need to retrieve the private values from your Rasa Enterprise license file (docs) and add them as GitHub secrets to the repository:

  • GCR_AUTH_JSON_PRIVATE_KEY_ID = private_key_id
  • GCR_AUTH_JSON_PRIVATE_KEY = private_key
  • GCR_AUTH_JSON_CLIENT_EMAIL = client_email
  • GCR_AUTH_JSON_CLIENT_ID = client_id

An alternative approach to GCR repo authentication would be with the gcloud credential helper.

Helm chart Credentials

To use safe_credentials in Github Actions through values.yml (docs), add following GitHub Secrets to the repo, replacing each <safe credential> with a different alphanumeric string and choosing a <username> for the initial user.

(Please use safe credentials to avoid data breaches)

  • GLOBAL_POSTGRESQL_POSTGRESQLPASSWORD = <safe credential>
  • GLOBAL_REDIS_PASSWORD = <safe credential>
  • RABBITMQ_RABBITMQ_PASSWORD = <safe credential>
  • RASAX_INITIALUSER_USERNAME = <username>
  • RASAX_INITIALUSER_PASSWORD = <safe credential>
  • RASAX_JWTSECRET = <safe credential>
  • RASAX_PASSWORDSALT = <safe credential>
  • GLOBAL_POSTGRESQL_POSTGRESQLPASSWORD = <safe credential>
  • GLOBAL_POSTGRESQL_POSTGRESQLPASSWORD = <safe credential>

AWS Preparation

The CI/CD pipeline of financial-demo uses AWS for all the storage & compute resources.

After cloning or forking the financial-demo GitHub repository you must set up the following items before the pipeline can run.

IAM User API Keys

The CI/CD pipeline uses the aws cli.

The aws cli needs a set of IAM User API keys for authentication & authorization:

In your AWS Console, go to the IAM dashboard to create a new set of API keys:

  • Click on Users

  • Click on Add user

    • User name = findemo (The actual name is not important, we will never use this name directly)

      Choose "programmatic access." This allows you to use the aws cli to interact with AWS.

    • Click on Next: Permissions

      • Click on Attach existing policies directly

        For IAM access, you can choose “AdministratorAccess”, or limit access to only what is needed by the CD pipeline.

    • Click on Next: Tags

    • Click on Next: Review

    • Click on Create user

    • Store in a safe location: Access key ID & Secret access key

SSH Key Pair

To SSH into the EC2 worker nodes of the EKS cluster, you'll need an SSH Key Pair

  • In your AWS Console, go to EC2 > Key Pairs, and create a Key Pair with the name findemo, and download the file findemo.pem which contains the private SSH key. Note that the name findemo is important, since it is used by the CI/CD pipeline when the cluster is created.

Local AWS CLI

Before the CI/CD pipeline can run, you will use the AWS CLI locally to create some resources and need to install & configure the CLI locally.

Install AWS CLI v2

See the installation instructions.

Configure your AWS CLI

# AWS CLI version 2.1.26 or later
aws --version

# Configure AWS CLI
aws configure
AWS Access Key ID [None]: -----          # See above: IAM User API Keys
AWS Secret Access Key [None]: -------    # See above: IAM User API Keys
Default region name [None]: us-west-2    # The CI/CD pipeline uses us-west-2 
Default output format [None]: 

# Check your configuration
aws configure list [--profile profile-name]

# verify it works
aws s3 ls

ECR repository & S3 bucket

The CI pipeline creates two artifacts:

  • An action server docker image, which is pushed to an AWS ECR repository.
  • A trained rasa model, which is copied to an AWS S3 bucket

Run these commands to create the storage for these artifacts. These commands run the AWS CLI and create an ECR repository and an S3 bucket:

# create ECR repository with name `financial-demo`
make aws-ecr-create-repository

# create S3 bucket with name `rasa-financial-demo`
make aws-s3-create-bucket

EKS production cluster

If the production cluster is already set up, you can skip this section.

This section describes the initial deployment of the financial-demo bot on an EKS production cluster.

This initial deployment is done manually. After that, the deployment is maintained & upgraded automatically by the CI/CD pipeline.

Preparation

Before you can create or interact with an EKS cluster, you must install eksctl, kubectl, helm, jp, and define some environment variables.

Install eksctl

See the installation instructions

If you use Ubuntu, you can issue the command:

make install-eksctl

Install kubectl

See the installation instructions

If you use Ubuntu, you can issue the command:

make install-kubectl

Install helm

See the installation instructions

If you use Ubuntu, you can issue the command:

make install-helm

Install jp

See the installation instructions

If you use Ubuntu, you can issue the command:

make install-jp

Set environment variables

There are many ways to set the required environment variables in your local environment.

One way is to create a file ./secret/envs_export, with this content:

# source this file to set the environment variables the same as the GitHub secrets.
export GCR_AUTH_JSON_PRIVATE_KEY_ID=...
export GCR_AUTH_JSON_PRIVATE_KEY='-----BEGIN PRIVATE KEY-...-END PRIVATE KEY-----\n'
export GCR_AUTH_JSON_CLIENT_EMAIL='...'
export GCR_AUTH_JSON_CLIENT_ID=...
export GLOBAL_POSTGRESQL_POSTGRESQLPASSWORD=...
export GLOBAL_REDIS_PASSWORD=...
export RABBITMQ_RABBITMQ_PASSWORD=...
export RASAX_DEBUG_MODE=false
export RASAX_INITIALUSER_USERNAME=admin
export RASAX_INITIALUSER_PASSWORD=...
export RASAX_JWTSECRET=...
export RASAX_PASSWORDSALT=...
export RASAX_TOKEN=...
export RASA_TOKEN=...

Then, create the environment variables with the command:

source ./secret/envs_export

Create the EKS cluster

Create the EKS production cluster, with name financial-demo-production:

make aws-eks-cluster-create AWS_EKS_CLUSTER_NAME=financial-demo-production

Some other useful 'Makefile functions' to interact with an EKS cluster:

make aws-eks-cluster-list-all

# in commands below, default name of cluster = financial-demo-<current branch name>
#
make aws-eks-cluster-describe AWS_EKS_CLUSTER_NAME=<name of cluster>
make aws-eks-cluster-describe-stacks AWS_EKS_CLUSTER_NAME=<name of cluster>
make aws-eks-cluster-delete AWS_EKS_CLUSTER_NAME=<name of cluster>

Configure kubeconfig

Add the EKS cluster information to ~/.kube/config, and set the current-context to that cluster:

make aws-eks-cluster-update-kubeconfig AWS_EKS_CLUSTER_NAME=financial-demo-production

# make sure kubectl is now looking at the correct EKS cluster
make kubectl-config-current-context

Install/Upgrade Rasa Enterprise

Versions

Select compatible versions

Get compatible versions for rasa-x, rasa and rasa-sdk from compatibility matrix

For the rasa-x-helm chart, the latest version should work. When installing a very old version, you might need to use an older helm chart version, selected with:

#.............NAME   URL
helm repo add rasa-x https://rasahq.github.io/rasa-x-helm
helm repo update

# .................NAME  /CHARTNAME
$ helm search repo rasa-x/rasa-x --versions
NAME         	CHART VERSION	APP VERSION	DESCRIPTION                                 
rasa-x/rasa-x	2.0.0        	0.41.1     	Rasa X Helm chart for Kubernetes / Openshift
rasa-x/rasa-x	1.16.0       	0.40.1     	Rasa X Helm chart for Kubernetes / Openshift
..
rasa-x/rasa-x	1.7.0        	0.33.0     	Rasa X Helm chart for Kubernetes / Openshift
rasa-x/rasa-x	1.6.13       	0.30.1     	Rasa X Helm chart for Kubernetes / Openshift
# NOTE: APP VERSION = Rasa X version

rasa & rasa-sdk

# file: requirements.txt
rasa[spacy]==2.5.2
rasa-sdk==2.5.0

# file: Dockerfile
FROM rasa/rasa-sdk:2.5.0

rasa-x & rasa-x-helm

# file: Makefile

RASAX_TAG := 0.39.3
RASAX_HELM_CHART_VERSION := 2.0.0

Build & push action server docker image

Build, run, test & push the action docker server image, with name:

  • <ECR URI>/financial-demo:<current branch name>
# check out the `main` branch.
# -> the branch name is used as the image tag
git checkout main

# build the image
make docker-build

# test it
make docker-run
make docker-test
make docker-stop

# Login & push the docker image to the AWS ECR repository
make aws-ecr-docker-login
make docker-push

Install/Upgrade Rasa Enterprise

Install/Upgrade Rasa Enterprise, using the action server docker image that was uploaded to the ECR repository:

# make sure kubectl is looking at the correct EKS cluster
make aws-eks-cluster-update-kubeconfig AWS_EKS_CLUSTER_NAME=financial-demo-production
# check it
make kubectl-config-current-context  AWS_EKS_CLUSTER_NAME=financial-demo-production

# check out the `main` branch.
# -> The action server docker image with tag = current branch name will be installed
git checkout main

# if you want to re-install rasa enterprise completely from scratch:
make rasa-enterprise-uninstall
make rasa-enterprise-delete-pvc-all
make aws-eks-namespace-delete

# create namespace `my-namespace`
make aws-eks-namespace-create

# create/refresh gcr-pull-secret, for Rasa Enterprise image
make pull-secret-gcr-create

# create/refresh ecr-pull-secret, for action server image
make pull-secret-ecr-create

# Install/Upgrade Rasa Enterprise with the action server
make rasa-enterprise-install

# Check Rasa Enterprise Health
make rasa-enterprise-check-health

# To troubleshoot, highly recommended to use OCTANT, see Appendix C

Train, test & upload model to S3

# check out the `main` branch.
git checkout main

# Train the model: `models/<current branch>.tar.gz`
make rasa-train

# In another window, start duckling server
docker run -p 8000:8000 rasa/duckling

# Run the end-to-end tests
make rasa-test

# Upload `models/<current branch>.tar.gz` to S3
# Note: This does not mean the model is deployed to Rasa Enterprise,
#       which is done in the next step.
make aws-s3-upload-rasa-model

Deploy, Tag & Smoketest the trained model

# Configure ~/.kube/config and set current_context
make aws-eks-cluster-update-kubeconfig  AWS_EKS_CLUSTER_NAME=financial-demo-production

# Deploy rasa model
make aws-s3-download-rasa-model
make rasa-enterprise-model-delete
make rasa-enterprise-model-upload
make rasa-enterprise-model-tag

# Wait about 1 minute, so rasa-production can download, upack & load the model

# Smoketest
make rasa-enterprise-smoketest

DNS

Optionally, if you want to access Rasa Enterprise at your own (sub)-domain name, define a DNS record of type CNAME with your domain service provider:

  • name of sub-domain: aws-financial-demo

    ==> This example name will resolve to aws-financial-demo.my-domain.com

  • Type: CNAME

  • Content: --------.us-west-2.elb.amazonaws.com

    ==> This is the hostname of the External Application Load Balancer that AWS EKS created during the deployment. You can get this hostname with the command:

    make rasa-enterprise-get-loadbalancer-hostname
  • TTL (Time to Live): 1 Hour

  • Priority:

It might take some time for things to propagate, but you can verify it with commands like nslookup & dig:

########################################################################
# use `nslookup -type`
nslookup -type=CNAME aws-financial-demo.my-domain.com
aws-financial-demo.my-domain.com canonical name = ---.us-west-2.elb.amazonaws.com.

########################################################################
# use `dig`
dig CNAME aws-financial-demo.my-domain.com
...
;; ANSWER SECTION:
aws-financial-demo.my-domain.com. ---- IN CNAME ---.us-west-2.elb.amazonaws.com.

Once propagated, you can access Rasa Enterprise at http://aws-financial-demo.my-domain.com

Trouble Shooting

If something goes wrong with the CI/CD pipeline, you should:

The following steps will most likely reveal what is going wrong:

  • Before you can use the Makefile commands locally, follow the Preparation steps:

    • Install eksctl, kubectl, helm, jp
    • Set the environment variables
  • Then, configure kubectl, so you are looking at the correct EKS cluster.

    • To troubleshoot the EKS test cluster for your current branch

      make aws-eks-cluster-update-kubeconfig
    • To Troubleshoot the EKS production cluster

      make aws-eks-cluster-update-kubeconfig AWS_EKS_CLUSTER_NAME=financial-demo-production
  • Make sure you are now looking at the correct cluster by checking the current context:

    make kubectl-config-current-context
  • Then, issue these commands to check things out.

    • Trouble shoot the EKS cluster

      # Check the available commands for the `aws-eks` cluster:
      $ make aws-eks # Do NOT press `Enter`, but press the `Tab` key twice
      aws-eks-cluster-create                    aws-eks-cluster-info
      aws-eks-cluster-delete                    aws-eks-cluster-list-all
      aws-eks-cluster-describe                  aws-eks-cluster-status
      aws-eks-cluster-describe-stacks           aws-eks-cluster-update-kubeconfig
      aws-eks-cluster-exists                    aws-eks-namespace-create
      aws-eks-cluster-get-certificateAuthority  aws-eks-namespace-delete
      aws-eks-cluster-get-endpoint
      
      # Trouble shoot the cluster
      make aws-eks-cluster-exists
      make aws-eks-cluster-status
      make aws-eks-cluster-info
    • Trouble shoot the S3 storage of the trained model

      # Check the available commands for the `aws-s3` bucket:
      make aws-s3 # Do NOT press `Enter`, but press the `Tab` key twice
      aws-s3-create-bucket        aws-s3-list-rasa-models
      aws-s3-delete-bucket        aws-s3-rasa-model-exists
      aws-s3-download-rasa-model  aws-s3-upload-rasa-model
      
      # Trouble shoot the S3 storage of the trained model
      make aws-s3-list-rasa-models
      make aws-s3-rasa-model-exists
    • Trouble shoot the ECR storage of the action server image

      # Check the available commands for the `aws-ecr` repository:
      make aws-ecr # Do NOT press `Enter`, but press the `Tab` key twice
      aws-ecr-create-repository        aws-ecr-get-repositoryUri
      aws-ecr-docker-login             aws-ecr-image-exists
      aws-ecr-get-authorization-token  aws-ecr-list-images
      
      # First, login to the ECR (This expires after a while, so redo it)
      make aws-ecr-docker-login
      
      # Then, Troubleshoot the ECR storage of the action server image
      make aws-ecr-list-images
      make aws-ecr-image-exists
    • Trouble shoot the Rasa Enterprise deployment

      # Check the available commands for the `rasa-enterprise` deployment:
      $ make rasa-e # Do NOT press `Enter`, but press the `Tab` key twice
      rasa-enterprise-check-health               rasa-enterprise-get-secrets-rabbit
      rasa-enterprise-get-access-token           rasa-enterprise-get-secrets-redis
      rasa-enterprise-get-base-url               rasa-enterprise-install
      rasa-enterprise-get-chat-token             rasa-enterprise-model-delete
      rasa-enterprise-get-loadbalancer-hostname  rasa-enterprise-model-tag
      rasa-enterprise-get-login                  rasa-enterprise-model-upload
      rasa-enterprise-get-pods                   rasa-enterprise-smoketest
      rasa-enterprise-get-secrets-postgresql     rasa-enterprise-uninstall
      
      # Trouble shoot the rasa enterprise deployment
      make rasa-enterprise-get-pods
      make rasa-enterprise-check-health
      make rasa-enterprise-smoketest

Cleanup of AWS resources

The CI/CD pipeline creates unique artifacts and infrastructure for each branch. This is all cleaned up once a branch is deleted, by a special workflow .github/workflows/cleanup.yml.

You can also do a manual cleanup, either from the AWS CLI, or from the AWS Console.

From the command line:

  • AWS ECR:

    # list the action server images in the ECR
    make aws-ecr-list-images
    
    # delete the action server image of current branch
    make aws-ecr-delete-image
    
    # delete an action server image created by another branch
    make aws-ecr-delete-image GIT_BRANCH_NAME=my_other_branch
  • AWS S3:

    # list the rasa models in the S3 bucket
    make aws-s3-list-rasa-models
    
    # delete the rasa model of current branch
    make aws-s3-delete-rasa-model
    
    # delete a rasa model created by another branch
    make aws-s3-delete-rasa-model GIT_BRANCH_NAME=my_other_branch
  • AWS EKS:

    # list the EKS clusters
    make aws-eks-cluster-list-all
    
    # to delete ALL the test clusters
    make aws-eks-cluster-delete-all-test-clusters
    
    # delete the test cluster of the current branch
    make aws-eks-cluster-delete
    
    # delete a test cluster created by another branch
    make aws-eks-cluster-delete GIT_BRANCH_NAME=my_other_branch

From the AWS console:

  • AWS ECR:

    In the AWS Console, go to the ECR repository financial-demo, and delete the action server images.

  • AWS S3:

    In the AWS Console, go to the S3 bucket rasa-financial-demo , and delete the rasa models.

  • AWS EKS:

    In the AWS Console, go to CloudFormation, and delete all the stacks in reverse order as created by the eksctl command.

    When a stack fails to delete due to dependencies, you have two options:

    • Option 1: Manually delete the resources that the stack is not able to delete. (RECOMMENDED)

      You can do this by drilling down into the CloudFormation stack delete events messages and deleting items bottom-up the dependency tree.

      One example of a bottom-up delete sequence is when deletion of the VPC fails:

      • EC2 > Load Balancers: first, delete the ELB load balancer of the cluster. Look at the Tags to see what cluster a loadbalancer belongs to.
      • VPC > Virtual Private Cloud: Subnets: then, delete the two subnets of the cluster. Look at the Name to see what cluster a subnet belongs to.
        • This will also delete the EC2 > Network interfaces, named eni-xxxx
        • You cannot delete Subnets until the ELB load balancers are deleted
      • VPC > Virtual Private Cloud: Your VPCs: finally, delete the VPC of the cluster. Look at the Name to see what cluster a VPC belongs to.
        • This will also delete all associated:
          • security groups (sg-xxx)
          • internet gateways (igw-xxx)
          • subnets (subnet-xxx)

      After cleaning up, try again to delete the AWS CloudFormation stack.

      If it still does not delete, iterate the manual cleanups until it does.

      Again, this can be a painful process, but once the CloudFormation stacks delete properly, you are guaranteed that you have cleaned up all the EKS related resources created by the CI/CD pipeline.

    • Option 2: Select to retain the resources that have dependency errors. (NOT RECOMMENDED)

      The stack delete operation will simply skip deleting them. This is NOT recommended, because you will clutter up your AWS account with many unused resources.

Appendix A: The AWS EKS cluster

We use eksctl to create the clusters. It creates many AWS resources with CloudFormation templates.

Some of these AWS resources are:

  • A VPC with
    • Public & private subnets
    • Internet & NAT Gateways
    • Route Tables
  • An IAM EKS service role
  • An EKS Cluster Control Plane
  • An EKS Managed nodegroup of EC2 instances

The cluster context is also added to the ~/.kube/config file.

The VPC created looks something like this:

The EKS Control Plane interacts with the the EKS Data Plane (the nodes), like this:

img

Appendix B: OCTANT

Octant is a useful open sourced tool for visualizing workloads inside the cluster and troubleshooting issues when they arise.

Install Octant

Installation instructions

Install on Ubuntu

cd ~
mkdir octant
cd octant
wget https://github.com/vmware-tanzu/octant/releases/download/v0.20.0/octant_0.20.0_Linux-64bit.deb
sudo dpkg -i octant_0.20.0_Linux-64bit.deb

Run Octant

# #################################################### #
# Configure kubectl to look at the correct EKS cluster #
# #################################################### #

# -> for a feature branch test cluster
git checkout my-feature-branch

# -> for the production cluster
git branch production # create temporary, local `production` branch
git checkout production

# Configure kubeconfig for the correct EKS cluster
make aws-eks-cluster-update-kubeconfig

# make sure kubectl is now looking at the correct EKS cluster
make kubectl-config-current-context

# #################################################### #
# Run Octant on default port 7777 and open the browser #
# #################################################### #
OCTANT_LISTENER_ADDR=0.0.0.0:7777 octant &

# Within octant, select the namespace `my-namespace`

Appendix D: AWS EKS references

There are two commands to create AWS EKS clusters; eksctl & aws eks.

  • The eksctl cli is the most complete, and it is what we ended up using.

  • The aws eks cli does not support to launch worker nodes to the cluster control plane. This has to be done manually from the AWS Console, which makes it unsuited for a CI/CD pipeline where everything needs to be done via scripting (=> infrastructure as code).

The following references are useful for learning about AWS EKS, and it is highly recommended to manually build test-clusters with both the eksctl & aws eks commands to help demystify the AWS resources that are being generated:

financial-demo's People

Contributors

akelad avatar amn41 avatar arjaanbuijk avatar b-quachtran avatar erohmensing avatar henry-hz avatar indam23 avatar kedz avatar koaning avatar rgstephens avatar tttthomasssss avatar yuriowindiatmoko2401 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

financial-demo's Issues

CI/CD - Run the pipeline when push to main

Because it was the first merge to main, the trigger to run it and deploy it to the production cluster is not yet set correctly. It is still set to be triggered by a push to the infrastructure-as-code branch.

This needs to be changed, and then tested, to make sure the pipeline is deploying it correctly top the production cluster.

ImportError: cannot import name 'json' from 'engineio'

I got the below error.


Traceback (most recent call last):
  File "/Users/cpasumarthi/codeBase/chatbot/venv/bin/rasa", line 6, in <module>
    from rasa.__main__ import main
  File "/Users/cpasumarthi/codeBase/chatbot/venv/lib/python3.7/site-packages/rasa/__init__.py", line 9, in <module>
    from rasa.train import train
  File "/Users/cpasumarthi/codeBase/chatbot/venv/lib/python3.7/site-packages/rasa/train.py", line 39, in <module>
    from rasa.core.agent import Agent
  File "/Users/cpasumarthi/codeBase/chatbot/venv/lib/python3.7/site-packages/rasa/core/agent.py", line 15, in <module>
    from rasa.core.channels.channel import OutputChannel, UserMessage
  File "/Users/cpasumarthi/codeBase/chatbot/venv/lib/python3.7/site-packages/rasa/core/channels/__init__.py", line 12, in <module>
    from rasa.core.channels.socketio import SocketIOInput
  File "/Users/cpasumarthi/codeBase/chatbot/venv/lib/python3.7/site-packages/rasa/core/channels/socketio.py", line 10, in <module>
    from socketio import AsyncServer
  File "/Users/cpasumarthi/codeBase/chatbot/venv/lib/python3.7/site-packages/socketio/__init__.py", line 3, in <module>
    from .client import Client
  File "/Users/cpasumarthi/codeBase/chatbot/venv/lib/python3.7/site-packages/socketio/client.py", line 11, in <module>
    from . import packet
  File "/Users/cpasumarthi/codeBase/chatbot/venv/lib/python3.7/site-packages/socketio/packet.py", line 2, in <module>
    from engineio import json as _json
ImportError: cannot import name 'json' from 'engineio' 

This error is due to an incompatible version of python-engineio library as shown below. It worked fine after upgrading the version

ERROR: rasa 2.4.0 has requirement python-engineio<3.14,>=3.11, but you'll have python-engineio 4.2.0 which is incompatible.

Environment:

OS: Big Sur 11.4
Python: 3.7.7

Consider using the spaCy tokenizer

When looking at the config.yml I read:

  - name: "SpacyEntityExtractor"
    # Note: It is not possible to use the SpacyTokenizer + SpacyFeaturizer in 
    #       combination with the WhitespaceTokenizer, and as a result the
    #       PERSON extraction by Spacy is not very robust.
    #       Because of this, the nlu training data is annotated as well, and the
    #       DIETClassifier will also extract PERSON entities.

This reads as a fair warning, but it also begs the question: why aren't we using the spaCy tokenizer here? I'll gladly make a PR but I'm curious if there's something that I'm currently not considering.

domain error when training

Thanks for working on this rasa example!

I am having this error after 'rasa train'.

python 3.7.6
rasa 1.10.9

❯ rasa train
Traceback (most recent call last):
  File "/home/henry/.venv/bin/rasa", line 10, in <module>
    sys.exit(main())
  File "/home/henry/.venv/lib/python3.7/site-packages/rasa/__main__.py", line 92, in main
    cmdline_arguments.func(cmdline_arguments)
  File "/home/henry/.venv/lib/python3.7/site-packages/rasa/cli/train.py", line 76, in train
    additional_arguments=extract_additional_arguments(args),
  File "/home/henry/.venv/lib/python3.7/site-packages/rasa/train.py", line 50, in train
    additional_arguments=additional_arguments,
  File "uvloop/loop.pyx", line 1456, in uvloop.loop.Loop.run_until_complete
  File "/home/henry/.venv/lib/python3.7/site-packages/rasa/train.py", line 101, in train_async
    additional_arguments,
  File "/home/henry/.venv/lib/python3.7/site-packages/rasa/train.py", line 172, in _train_async_internal
    new_fingerprint = await model.model_fingerprint(file_importer)
  File "/home/henry/.venv/lib/python3.7/site-packages/rasa/model.py", line 290, in model_fingerprint
    domain_without_nlg = Domain.from_dict(domain_dict)
  File "/home/henry/.venv/lib/python3.7/site-packages/rasa/core/domain.py", line 162, in from_dict
    **additional_arguments,
  File "/home/henry/.venv/lib/python3.7/site-packages/rasa/core/domain.py", line 431, in __init__
    self._check_domain_sanity()
  File "/home/henry/.venv/lib/python3.7/site-packages/rasa/core/domain.py", line 1049, in _check_domain_sanity
    incorrect_mappings,
rasa.core.domain.InvalidDomain: Intent 'handoff' is set to trigger action 'utter_greet', which is not defined in the domain.

Create mock profiles to enhance skills

Create mock profiles with:

  • account details
  • balances
  • credit card accounts
  • spending by date & vendor
  • known recipients

This will allow more realistic skills that act on the mock data. It could be reset, and a new random profile assigned with each session start.

python 3.8 problem

In rasa installation docs it says rasa works with python 3.8, but unfortunately this demo throws the following error while installing pip dependencies

"ERROR: Could not find a version that satisfies the requirement rasa[spacy]==1.10.8"

PS: Works fine with python 3.7.

Failed to extract slot PERSON with action transfer_form

This error appears sometimes

Scenario :
I say
"Pay to Jane smith"

I say "Pay carol"

From what I see the behaviour of picking the PERSON entity looks random if it picks jane smith slot is set no issues .

When it not set it it throws the exception .

I wanted to why am I seeing this behaviour in same session and chat window

CI/CD - Document the required AWS permissions

Right now the instructions say to use Administrative access, but that is not practical for Enterprises.

We need to figure out the minimum required permissions and list them in the README.

InvalidModelError: spaCy model error

python -V
Python 3.7.10

pip3 install -r requirements-dev.txt
python -m spacy download en_core_web_md en

Requirement already satisfied: en in /home/joggerjoel/.pyenv/versions/3.7.10/lib
/python3.7/site-packages (0.0.1)
Requirement already satisfied: en_core_web_md==2.2.5 from https://github.com/exp
losion/spacy-models/releases/download/en_core_web_md-2.2.5/en_core_web_md-2.2.5.
tar.gz#egg=en_core_web_md==2.2.5 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/
python3.7/site-packages (2.2.5)
Requirement already satisfied: spacy>=2.2.2 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from en_core_web_md==2.2.5) (2.2.4)
Requirement already satisfied: setuptools in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from spacy>=2.2.2->en_core_web_md==2.2.5) (47.1.0)
Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from spacy>=2.2.2->en_core_web_md==2.2.5) (4.59.0)
Requirement already satisfied: requests<3.0.0,>=2.13.0 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from spacy>=2.2.2->en_core_web_md==2.2.5) (2.25.1)
Requirement already satisfied: plac<1.2.0,>=0.9.6 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from spacy>=2.2.2->en_core_web_md==2.2.5) (1.1.3)
Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from spacy>=2.2.2->en_core_web_md==2.2.5) (2.0.5)
Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from spacy>=2.2.2->en_core_web_md==2.2.5) (1.0.5)
Requirement already satisfied: srsly<1.1.0,>=1.0.2 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from spacy>=2.2.2->en_core_web_md==2.2.5) (1.0.5)
Requirement already satisfied: catalogue<1.1.0,>=0.0.7 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from spacy>=2.2.2->en_core_web_md==2.2.5) (1.0.0)
Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from spacy>=2.2.2->en_core_web_md==2.2.5) (3.0.5)
Requirement already satisfied: blis<0.5.0,>=0.4.0 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from spacy>=2.2.2->en_core_web_md==2.2.5) (0.4.1)
Requirement already satisfied: numpy>=1.15.0 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from spacy>=2.2.2->en_core_web_md==2.2.5) (1.18.5)
Requirement already satisfied: thinc==7.4.0 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from spacy>=2.2.2->en_core_web_md==2.2.5) (7.4.0)
Requirement already satisfied: wasabi<1.1.0,>=0.4.0 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from spacy>=2.2.2->en_core_web_md==2.2.5) (0.8.2)
Requirement already satisfied: certifi>=2017.4.17 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.2->en_core_web_md==2.2.5) (2020.12.5)
Requirement already satisfied: chardet<5,>=3.0.2 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.2->en_core_web_md==2.2.5) (3.0.4)
Requirement already satisfied: idna<3,>=2.5 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.2->en_core_web_md==2.2.5) (2.10)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.2->en_core_web_md==2.2.5) (1.26.4)
Requirement already satisfied: importlib-metadata>=0.20; python_version < "3.8" in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from catalogue<1.1.0,>=0.0.7->spacy>=2.2.2->en_core_web_md==2.2.5) (4.0.1)
Requirement already satisfied: zipp>=0.5 in /home/joggerjoel/.pyenv/versions/3.7.10/lib/python3.7/site-packages (from importlib-metadata>=0.20; python_version < "3.8"->catalogue<1.1.0,>=0.0.7->spacy>=2.2.2->en_core_web_md==2.2.5) (3.4.1)

✔ Download and installation successful

rasa train

2021-04-24 08:23:39 INFO     rasa.nlu.utils.spacy_utils  - Trying to load spacy model with name 'en_core_web_md'
InvalidModelError: Please confirm that en_core_web_md is an available spaCy model. You need to download one upfront. For example:
python -m spacy download en_core_web_md
More informaton can be found on https://rasa.com/docs/rasa/components#spacynlp

rasa action server listen port is 5055 by default

Rasa Version: Rasa 1.10.8
I followed by stepd in Readme. After I exec rasa run actions ,I see output in console ,which is
Action endpoint is up and running on http://localhost:5055
Then I specify action server port using 5056 ,by execingf rasa run actions -p 5056 ,so I am glad to see finanical-demo run successfully.
My suggestion is there can specify action server port in readme file ,thus this can be easy for newer running demo.

Allow floats for amount to pay

If you enter a decimal number for cc_payment_form amount it isn't handled.

  File "/Users/greg/Dev/rasa/financial-demo/actions.py", line 114, in validate_payment_amount
    if value and value.lower() in self.payment_amount_db():
AttributeError: 'float' object has no attribute 'lower'

RuntimeError: This event loop is already running

When I try and test the bot with rasa shell --debug I get a runtime error and it seems the process gets blocked as there is no response from the bot if I try and interact.

rasa shell --debug
2020-06-04 09:05:52 DEBUG    rasa.model  - Extracted model to 'C:\Users\USERNAME\AppData\Local\Temp\1\tmpjzm3he9j'.
2020-06-04 09:05:52 DEBUG    rasa.cli.utils  - Parameter 'endpoints' not set. Using default location 'endpoints.yml' instead.
2020-06-04 09:05:52 DEBUG    rasa.cli.utils  - Parameter 'credentials' not set. Using default location 'credentials.yml' instead.
2020-06-04 09:05:52 DEBUG    rasa.model  - Extracted model to 'C:\Users\USERNAME\AppData\Local\Temp\1\tmpklfl9j12'.
2020-06-04 09:05:55 INFO     root  - Connecting to channel 'cmdline' which was specified by the '--connector' argument. Any other channels will be ignored. To connect to all given channels, omit the '--connector' argument.
2020-06-04 09:05:55 DEBUG    sanic.root  - CORS: Configuring CORS with resources: {'/*': {'origins': [''], 'methods': 'DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT', 'allow_headers': ['.*'], 'expose_headers': None, 'supports_credentials': True, 'max_age': None, 'send_wildcard': False, 'automatic_options': True, 'vary_header': True, 'resources': {'/*': {'origins': ''}}, 'intercept_exceptions': True, 'always_send': True}}
2020-06-04 09:05:55 DEBUG    rasa.core.utils  - Available web server routes:
/webhooks/rest                                     GET                            custom_webhook_CmdlineInput.health
/webhooks/rest/webhook                             POST                           custom_webhook_CmdlineInput.receive
/                                                  GET                            hello
2020-06-04 09:05:55 INFO     root  - Starting Rasa server on http://localhost:5005
2020-06-04 09:05:55 DEBUG    rasa.core.utils  - Using the default number of Sanic workers (1).
2020-06-04 09:05:55 INFO     root  - Enabling coroutine debugging. Loop id 2401635131176.
2020-06-04 09:05:55 DEBUG    rasa.model  - Extracted model to 'C:\Users\USERNAME\AppData\Local\Temp\1\tmpa4tr7si9'.
c:\users\USERNAME\appdata\local\continuum\miniconda3\envs\findemo\lib\site-packages\thinc\neural\_custom_kernels.py:36: ResourceWarning: unclosed file <_io.TextIOWrapper name='c:\\users\\USERNAME\\appdata\\local\\continuum\\miniconda3\\envs\\findemo\\lib\\site-packages\\thinc\\neural\\_custom_kernels.cu' mode='r' encoding='utf8'>
  SRC = (PWD / "_custom_kernels.cu").open("r", encoding="utf8").read()
c:\users\USERNAME\appdata\local\continuum\miniconda3\envs\findemo\lib\site-packages\thinc\neural\_custom_kernels.py:39: ResourceWarning: unclosed file <_io.TextIOWrapper name='c:\\users\\USERNAME\\appdata\\local\\continuum\\miniconda3\\envs\\findemo\\lib\\site-packages\\thinc\\neural\\_murmur3.cu' mode='r' encoding='utf8'>
  MMH_SRC = (PWD / "_murmur3.cu").open("r", encoding="utf8").read()
2020-06-04 09:05:57 DEBUG    rasa.utils.tensorflow.models  - Loading the model ...
2020-06-04 09:05:58 DEBUG    rasa.utils.tensorflow.models  - Finished loading the model.
2020-06-04 09:05:58 DEBUG    rasa.utils.tensorflow.models  - Building tensorflow prediction graph...
2020-06-04 09:06:04 DEBUG    rasa.utils.tensorflow.models  - Finished building tensorflow prediction graph.
2020-06-04 09:06:24 INFO     rasa.nlu.components  - Added 'SpacyNLP' to component cache. Key 'SpacyNLP-en_core_web_md'.
2020-06-04 09:06:24 DEBUG    rasa.core.tracker_store  - Connected to InMemoryTrackerStore.
2020-06-04 09:06:24 DEBUG    rasa.core.lock_store  - Connected to lock store 'InMemoryLockStore'.
2020-06-04 09:06:24 DEBUG    rasa.model  - Extracted model to 'C:\Users\USERNAME\AppData\Local\Temp\1\tmprkmgvsrh'.
2020-06-04 09:06:24 DEBUG    pykwalify.compat  - Using yaml library: c:\users\USERNAME\appdata\local\continuum\miniconda3\envs\findemo\lib\site-packages\ruamel\yaml\__init__.py
2020-06-04 09:06:25 DEBUG    rasa.utils.tensorflow.models  - Loading the model ...
2020-06-04 09:06:25 DEBUG    rasa.utils.tensorflow.models  - Finished loading the model.
2020-06-04 09:06:25 DEBUG    rasa.utils.tensorflow.models  - Building tensorflow prediction graph...
2020-06-04 09:06:26 DEBUG    rasa.utils.tensorflow.models  - Finished building tensorflow prediction graph.
2020-06-04 09:06:26 DEBUG    rasa.core.nlg.generator  - Instantiated NLG to 'TemplatedNaturalLanguageGenerator'.
2020-06-04 09:06:26 INFO     root  - Rasa server is up and running.
Bot loaded. Type a message and press enter (use '/stop' to exit): 
2020-06-04 09:06:27 ERROR    asyncio  - Task exception was never retrieved
future: <Task finished coro=<configure_app.<locals>.run_cmdline_io() done, defined at c:\users\USERNAME\appdata\local\continuum\miniconda3\envs\findemo\lib\site-packages\rasa\core\run.py:128> exception=RuntimeError('This event loop is already running',)>
Traceback (most recent call last):
  File "c:\users\USERNAME\appdata\local\continuum\miniconda3\envs\findemo\lib\site-packages\rasa\core\run.py", line 134, in run_cmdline_io
    sender_id=conversation_id,
  File "c:\users\USERNAME\appdata\local\continuum\miniconda3\envs\findemo\lib\asyncio\coroutines.py", line 110, in __next__
    return self.gen.send(None)
  File "c:\users\USERNAME\appdata\local\continuum\miniconda3\envs\findemo\lib\site-packages\rasa\core\channels\console.py", line 142, in record_messages
    text = get_user_input(button_question)
  File "c:\users\USERNAME\appdata\local\continuum\miniconda3\envs\findemo\lib\site-packages\rasa\core\channels\console.py", line 78, in get_user_input
    style=Style([("qmark", "#b373d6"), ("", "#b373d6")]),
  File "c:\users\USERNAME\appdata\local\continuum\miniconda3\envs\findemo\lib\site-packages\questionary\question.py", line 45, in ask
    return self.unsafe_ask(patch_stdout)
  File "c:\users\USERNAME\appdata\local\continuum\miniconda3\envs\findemo\lib\site-packages\questionary\question.py", line 59, in unsafe_ask
    return self.application.run()
  File "c:\users\USERNAME\appdata\local\continuum\miniconda3\envs\findemo\lib\site-packages\prompt_toolkit\application\application.py", line 812, in run
    self.run_async(pre_run=pre_run, set_exception_handler=set_exception_handler)
  File "c:\users\USERNAME\appdata\local\continuum\miniconda3\envs\findemo\lib\asyncio\base_events.py", line 475, in run_until_complete
    self.run_forever()
  File "c:\users\USERNAME\appdata\local\continuum\miniconda3\envs\findemo\lib\asyncio\base_events.py", line 429, in run_forever
    raise RuntimeError('This event loop is already running')
RuntimeError: This event loop is already running

handoff is not working

I trained rasa in helpdesk-assistant and in financial demo and they working perfectly on chatroom_handoff.html but financial demo can't send me to helpdesk-assistant when i request handoff . just taking the handoff action request and keep chatting with financial demo

1
2

There's no errors on any ports i run
The ports of helpdesk_assistant:
helpdesk port 5005
helpdesk port 5055

The ports of financial demo:
financial demo
Uploading Inkedfinancial demo1_LI.jpg…

Thanks in advance

Remove slot mappings for credit_card and time

The slots credit_card and time are also entities with the same names.
This means that whenever NLU extracts these entities, the slots are automatically filled.

This means that defining these lines in slot_mappings are not needed:

  • "credit_card": self.from_entity(entity="credit_card")
  • "time": [self.from_entity(entity="time")]

not able to install requirements-dev.txt

im getting an error when i install requirements-dev.txt

ERROR: Command errored out with exit status 1: /Users/w/Documents/GitHub/financial-demo/venv/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/h5/jcvtwyn90zn9zftt0_3v_vrc0000gn/T/pip-install-zfm2bqqi/pytype_c303814f64fb49c6811b11ace471d273/setup.py'"'"'; file='"'"'/private/var/folders/h5/jcvtwyn90zn9zftt0_3v_vrc0000gn/T/pip-install-zfm2bqqi/pytype_c303814f64fb49c6811b11ace471d273/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/h5/jcvtwyn90zn9zftt0_3v_vrc0000gn/T/pip-record-e7zz4vuc/install-record.txt --single-version-externally-managed --compile --install-headers /Users/w/Documents/GitHub/financial-demo/venv/include/site/python3.7/pytype Check the logs for full command output.

CI/CD - always build the docker image & rely on docker build in logic

The CI/CD pipeline checks if it needs to build the action server docker image or not.
It does this by checking if any of the changed files of the most recent commits require a re-build.

This is not good for two reasons:

  1. It is not fail safe, because it could be that there are no model changes in the current commit, but there were in the previous commit, and if the build during the previous commit failed, the docker image that is stored on ECR is old.
  2. We're duplicating logic, because docker build & docker push already include all the required logic to build or push changes.

It is proposed that we simply always build & push the action server image, and rely on smarts available in the docker cli to build & push anything that needs to be updated.

Please improve readme instructions

  • Are the commands shown in the readme executed in the virtual environment?

  • Docker does not exist in the virtual environment after following the installation instructions on rasa.com. There is a command in the readme that uses Docker. Should we install Docker in the virtual environment?

  • After installing Docker and running rasa/duckling, it says to do "rasa shell --debug" but where? Do it in a third window? If I do that it just says "the path 'models' does not exist". I already ran "rasa train".

Payees from set list aren't always picked up

Some of the names from the set list of valid payees aren't always picked up by spacy. It would be better if the valid names are ones that are always recognized, even when given as single words.

It would help if they were full names (e.g. John Hopkins), since spacy recognizes these more easily.

Custom action issue

To get the list of vendors i defined the new action vendor in action.py. But on putting the query after retraining the model its showing no registered actions for action_vendor.

  • Error
`ERROR    rasa.core.processor  - Encountered an exception while running action 'action_vendor'.Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.
Traceback (most recent call last):
  File "/home/kush/.local/lib/python3.8/site-packages/rasa/core/actions/action.py", line 670, in run
    response = await self.action_endpoint.request(
  File "/home/kush/.local/lib/python3.8/site-packages/rasa/utils/endpoints.py", line 154, in request
    raise ClientResponseError(
rasa.utils.endpoints.ClientResponseError: 404, Not Found, body='b'{"error":"No registered action found for name \'action_vendor\'.","action_name":"action_vendor"}''
  • defined action
class ActionVendor(Action):

    def name(self):
        return "action_vendor"

    def run(self, dispatcher, tracker, domain):
        vendors = tracker.get_slot("vendor_list")
        formatted_vendors = "\n" + "\n".join(
            [f"- {vendor}" for vendor in vendors]
        ) 
        dispatcher.utter_message(
            template="utter_vendors",
            formatted_vendors=formatted_vendors,
        )
        return []

Rasa train issue

Hi. Did several times, with Python 3.8, 3.7, 3.7-dev, 3.6, 3.6-dev - to no avail.
Throws an error:
rasa train

Remove `UserUtteranceReverted` from all `ActionShowXX` custom actions

In rasa 2.3, the logic was introduced that rules that are not used in stories are not added to the tracker. As a result:

  • These rules do not impact predictions with stories
  • We can remove the UserUtteranceReverted from all ActionShowXX custom actions, because they were introduced for the same purpose.

time parsing for transaction search not working

Asking "How much did I spend at Starbucks in the last two months?" results in

app_1              | 2020-06-16 18:48:00 DEBUG    rasa_sdk.forms  - Submitting the form 'transact_search_form'
app_1              | Exception occurred while handling uri: 'http://app:5055/webhook'
app_1              | Traceback (most recent call last):
app_1              |   File "/opt/venv/lib/python3.7/site-packages/sanic/app.py", line 976, in handle_request
app_1              |     response = await response
app_1              |   File "/app/rasa_sdk/endpoint.py", line 102, in webhook
app_1              |     result = await executor.run(action_call)
app_1              |   File "/app/rasa_sdk/executor.py", line 387, in run
app_1              |     events = await action(dispatcher, tracker, domain)
app_1              |   File "/app/rasa_sdk/forms.py", line 606, in run
app_1              |     events.extend(self.submit(dispatcher, temp_tracker, domain))
app_1              |   File "/app/actions/actions.py", line 314, in submit
app_1              |     from_date = date.fromisoformat(time_range.split("T")[0])
app_1              | ValueError: Invalid isoformat string: 'last two months'

Take Any Vendors

How to configure this demo so that it can take "any" vendors instead of only three?

CI/CD - base decision to train or not on fingerprint logic of `rasa train` itself

The CI/CD pipeline checks if it needs to train the model or not.
It does this by checking if any of the changed files of the most recent commits require a re-training.

This is not good for two reasons:

  1. It is not fail safe, because it could be that there are no model changes in the current commit, but there were in the previous commit, and if training during the previous commit failed, the trained model that is stored on S3 is old.
  2. We're duplicating logic, because rasa already includes the logic to make that decision, using fingerprinting. The model.tar.gz of a trained model includes all the information that the rasa train command needs to decide to retrain or not.

It is proposed to try this approach:

  • When the CI/CD pipeline is at the point to train the model, it first downloads the current model from S3
  • It then issues the rasa train command, and relies on the build-in logic to train or not
  • It then uploads the model back to S3, but only if it has changed.

Generalizing on first name

I'm new to Rasa and using this demo to learn. When I run it, I can type in "pay Karen" or "pay Lisa" and it works fine but if I say "pay Percy" it says "Sorry, I didn't get that." Percy is in the list of known recipients.

Why doesn't it work with Percy?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.