Hi Everyone, I’m facing issues in rasa training. NLU model training completed but the core part is shows some issues
error: InvalidRule: Contradicting rules or stories found �
- the prediction of the action ‘action_listen’ in story ‘Leave Application’ is contradicting with rule(s) ‘Activate form’ which predicted action ‘utter_leave’. Please update your stories and rules so that they don’t contradict each other. You can find more information about the usage of rules at Rules.
actions.py : from typing import Any, Text, Dict, List, Union
from rasa_sdk import Action, Tracker
from rasa_sdk.events import Restarted, SlotSet, EventType
from rasa_sdk.executor import CollectingDispatcher
class ValidateLeaveForm(Action):
def name(self) -> Text:
return "leave_form"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
required_slots = ["br_employee_id", "start_date", "end_date", "reason"]
for slot_name in required_slots:
if tracker.slots.get(slot_name) is None:
# The slot is not filled yet. Request the user to fill this slot next.
return [SlotSet("requested_slot", slot_name)]
# All slots are filled.
return [SlotSet("requested_slot", None)]
class ActionSubmit(Action):
def name(self) -> Text:
return "action_submit"
def run(
self,
dispatcher,
tracker: Tracker,
domain: "DomainDict",
) -> List[Dict[Text, Any]]:
dispatcher.utter_message(template="utter_details_thanks",
Emp_id = tracker.get_slot('br_employee_id'),
Start_date = tracker.get_slot('start_date'),
End_date = tracker.get_slot('end_date'),
Reason = tracker.get_slot('reason'))
class action_restart(Action):
def name(self):
return "action_restart"
def run(self, dispatcher, tracker, domain):
return [Restarted()]
rules: version: “2.0”
rules:
-
rule: Say goodbye anytime the user says goodbye
steps:
-
intent: goodbye
-
action: utter_goodbye
-
action: action_restart
-
-
rule: Activate form
steps:
-
intent: leave application
-
action: utter_leave
-
action: leave_form
-
active_loop: leave_form
-
-
rule: Submit form
condition:
Condition that form is active.
- active_loop: leave_form
steps:
Form is deactivated
-
action: leave_form
-
active_loop: null
-
slot_was_set:
- requested_slot: null
The actions we want to run when the form is submitted.
- action: action_submit
-
rule: Ask the user to rephrase whenever they send a message with low NLU confidence
steps:
-
intent: out_of_scope
-
action: utter_out_of_scope
-