Custom Rephraser Prompt Template in Kubernetes Deployment
Rasa Pro CALM allows you to use a custom prompt for the Contextual Response Rephraser to improve the conversational experience for your users, such as maintaining a consistent personality for your assistant.
This guide will explain how to configure a Rasa CALM bot to use a custom prompt template for the Contextual Response Rephraser in a Kubernetes environment.
We will use a ConfigMap to store the custom prompt template and a volume mount to make it accessible to the Rasa pod.
This approach has two benefits:
- It allows Rasa to dynamically use the custom prompt without embedding it in the container image.
- Simplifies updates to the prompt template as you only need to update the ConfigMap and restart the pod to apply any changes.
Prerequisites
- Kubernetes cluster with
kubectl
configured. - Rasa deployment running in your Kubernetes cluster. This guide is specific to Rasa deployed using the Rasa Pro helm charts.
- A custom rephraser prompt file in Jinja2 format.
Steps to Use a Custom Rephraser Prompt Template
Step 1: Create a ConfigMap
Store your custom rephraser prompt in a ConfigMap to make it accessible to the Rasa pod.
- Save your prompt in a
.jinja2
file, e.g.,custom-rephraser-template.jinja2
. - Run:Replace:kubectl -n <namespace> create configmap custom-prompts --from-file=rephraser-template=<path-to-rephraser-prompt-jinja-file>
<namespace>
with your Rasa namespace.<path-to-rephraser-prompt-jinja-file>
with the file path.
Step 2: Update Values File
Why Add a Volume and Mount?
A volume attaches external resources (e.g., ConfigMaps) to the pod, while a volume mount makes those resources accessible inside the container. In this case, we are adding a volume and volume mount to attach the ConfigMap containing the custom rephraser prompt to the Rasa pod. For more detail, see the Kubernetes documentation.
values.yaml
Modify Using the Rasa Pro helm charts, add the following under the rasa
section:
Step 3: Deploy Changes
Redeploy your Rasa assistant to apply the configuration:
Run:
helm upgrade --install <release-name> <chart-name> -f values.yamlReplace:
<release-name>
with your Rasa Helm release name.<chart-name>
with the name of your Helm chart.
Verify the configuration with:
kubectl -n <namespace> describe pod <rasa-pod-name>
Step 4: Verify the Custom Prompt
Test your Rasa assistant to ensure the custom prompt is being used. You should see the the rephraser prompt in the debug logs.
You can update the prompt by editing the .jinja2
file, recreating the ConfigMap, and redeploying using helm upgrade
.