0

I need help to write a code for custom actions for groups in Rasa?

Example of statement: What analysis do I use if independent variables are numerical and categorical but dependent variables are numerical

my nlu: What analysis do I use if [indep]{“entity”:‘depOrIndep_var’, “group”:“firstgroup_var”} variables are [num]{“entity”: “numOrCat_var1”, “group”: “firstgroup_var”} and [cat]{“entity”: “numOrCat_var2”, “group”: “firstgroup_var”} but [dependent]{“entity”: “depOrIndep_var”, “group”: “secondgroup_var”} variables are [numerical]{“entity”: “numOrCat_var3”, “group”: “secondgroup_var”}

the answer: "use X"

I am using Rasa3.1. Below are further details. How do I provide different answers depending on the variables provided (based on the groups)? Below is my attempt, but I think I am not doing it right. Advices would be much appreciated!

entities:

  • depOrIndep_var: groups:
    • firstgroup_var
    • secondgroup_var
  • numOrCat_var: groups:
    • firstgroup_var
    • secondgroup_var
  • factor_var: groups:
    • firstgroup_var
    • secondgroup_var slots: firstgroup_var: type: text mappings:
    • type: from_entity entity: depOrIndep_var group: firstgroup_var secondgroup_var: type: text mappings:
    • type: from_entity entity: depOrIndep_var group: secondgroup_var depOrIndep: type: text mappings:
    • type: from_entity entity: depOrIndep_var conditions:
      • active_loop: info_test_form numOrCat1: type: text mappings:
    • type: from_entity entity: numOrCat_var1 conditions:
      • active_loop: info_test_form numOrCat2: type: text mappings:
    • type: from_entity entity: numOrCat_var2 conditions:
      • active_loop: info_test_form numOrCat3: type: text mappings:
    • type: from_entity entity: numOrCat_var3 conditions:
      • active_loop: info_test_form forms: info_test_form: required_slots:
    • numOrCat1
    • numOrCat2
    • numOrCat3
    • depOrIndep
    • firstgroup_var
    • secondgroup_var
    • secondgroup_var
  • numOrCat_var: groups:
    • firstgroup_var
    • secondgroup_var

action.py:

class ActionInfoTestForm(Action):

def name(self) -> Text:
    return "action_info_test_form"

def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
    
    grouping = tracker.get_slot('firstgroup_var')
    depOrIndep = tracker.get_slot('depOrIndep')
    numOrCat1 = tracker.get_slot('numOrCat1')
    numOrCat2 = tracker.get_slot('numOrCat2')
    catvar = tracker.get_slot('cat_var')
   
    if grouping == 'firstgroup_var' and depOrIndep == 'independent' and numOrCat1 == 'numerical' and numOrCat2 == 'categorical':
        dispatcher.utter_message(template= 'utter_twodepcat')
karan
  • 85
  • 6

0 Answers0