Skip to content

Commit

Permalink
Ignore REQUESTED_SLOT when switching to another form.
Browse files Browse the repository at this point in the history
Fix for issue #7710
  • Loading branch information
ArjaanBuijk committed Jan 21, 2021
1 parent 7de47da commit ef115ed
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions rasa/core/actions/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def extract_other_slots(
if they are set by corresponding entities from the user input
else return `None`.
"""
slot_to_fill = tracker.get_slot(REQUESTED_SLOT)
slot_to_fill = self.get_slot_to_fill(tracker)

entity_type_of_slot_to_fill = self._get_entity_type_of_slot_to_fill(
slot_to_fill, domain
Expand Down Expand Up @@ -317,13 +317,26 @@ def extract_other_slots(

return slot_values

def get_slot_to_fill(self, tracker: "DialogueStateTracker") -> Optional[str]:
"""Get the slot to be filled.
When switching to another form, the requested slot setting is still from the
previous form and must be ignored.
Returns:
The slot name or None
"""
return (
tracker.get_slot(REQUESTED_SLOT)
if tracker.active_loop_name == self.name()
else None
)

def extract_requested_slot(
self, tracker: "DialogueStateTracker", domain: Domain
) -> Dict[Text, Any]:
"""Extract the value of requested slot from a user input
else return `None`.
"""
slot_to_fill = tracker.get_slot(REQUESTED_SLOT)
"""Extract the value of requested slot from a user input else return `None`."""
slot_to_fill = self.get_slot_to_fill(tracker)
logger.debug(f"Trying to extract requested slot '{slot_to_fill}' ...")

# get mapping for requested slot
Expand Down Expand Up @@ -446,7 +459,7 @@ async def validate(
slot_values = self.extract_other_slots(tracker, domain)

# extract requested slot
slot_to_fill = tracker.get_slot(REQUESTED_SLOT)
slot_to_fill = self.get_slot_to_fill(tracker)
if slot_to_fill:
slot_values.update(self.extract_requested_slot(tracker, domain))

Expand Down

0 comments on commit ef115ed

Please sign in to comment.