I am really struggling with developing custom actions in droplet (digital ocean).
Through the lesson (Rasa Tutorials - Install Rasa X with Docker Compose on Digital Ocean - YouTube), managed to finish setting up rasa x and Github connection. However, couldn’t find a way to enable my “simple custom actions” as shown below (it is all saved in etc/rasa/actions with empty init.py):
from typing import Any, Text, Dict, List
import pandas as pd
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
class ActionRephraseResponse(Action):
def name(self) -> Text:
return "action_pandas"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
df = pd.DataFrame({"A": ["this dataframe is working", "dataframe is working", 7], "B": [2, 5, 8], "C": [3, 6, 9]})
dispatcher.utter_message(text=df["A"].tolist()[0])
return []
Seems it’s an issue with adding dependencies to rasa, but I’ve installed pandas for sure by
sudo apt-get install python3-pandas
and made “docker-compose.override.yml” with the content:
version: '3.4'
services:
app:
image: 'rasa/rasa-sdk:latest'
volumes:
- './actions:/app/actions'
expose:
- '5055'
depends_on:
- rasa-production
and ran “sudo docker-compose down” and “sudo docker-compose up -d”. As a result, my model can understand when to “action_pandas” without saying “this dataframe is working”.
To fix this, I’ve found some answers talking about using Dockerfile like:
touch Dockerfile
nano Dockerfile
FROM rasa/rasa-sdk:2.8.2
# Switch to root user
USER root
#RUN apt-get update && apt-get install -y git
# Do other stuff, e.g.: add python dependencies, etc.
RUN pip3 install --no-cache-dir numpy
RUN pip3 install --no-cache-dir pandas
# Switch back to a non-root user
USER 1001
and I ran
docker build .
However, it’s not working despite showing:
Installing collected packages: six, pytz, python-dateutil, pandas
Successfully installed pandas-1.3.3 python-dateutil-2.8.2 pytz-2021.3 six-1.16.0
Removing intermediate container 3b3c9b58f2b2
---> 3460c743a5b9
Step 6/6 : USER 1001
---> Running in 1c1f30c821e0
Removing intermediate container 1c1f30c821e0
---> c427dd668ea7
Successfully built c427dd668ea7
I have no idea how to work with the docker things in droplet… Could you please help me with this?
Any help would be greatly appreciated.