From 1112edf67bd218d11d25021b5612b1fa89bae58a Mon Sep 17 00:00:00 2001 From: Anca Lita <27920906+ancalita@users.noreply.github.com> Date: Fri, 22 Sep 2023 15:35:14 +0100 Subject: [PATCH] update property name --- rasa/core/policies/flow_policy.py | 3 +-- rasa/shared/core/flows/flow.py | 27 ++++----------------------- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/rasa/core/policies/flow_policy.py b/rasa/core/policies/flow_policy.py index 924e9ec32984..2895458d30d1 100644 --- a/rasa/core/policies/flow_policy.py +++ b/rasa/core/policies/flow_policy.py @@ -52,7 +52,6 @@ GenerateResponseFlowStep, IfFlowLink, EntryPromptFlowStep, - CollectInformationScope, SlotRejection, StepThatCanStartAFlow, UserMessageStep, @@ -521,7 +520,7 @@ def _reset_scoped_slots( # reset all slots scoped to the flow if ( isinstance(step, CollectInformationFlowStep) - and step.scope == CollectInformationScope.FLOW + and step.reset_after_flow_ends ): slot = tracker.slots.get(step.collect_information, None) initial_value = slot.initial_value if slot else None diff --git a/rasa/shared/core/flows/flow.py b/rasa/shared/core/flows/flow.py index 63204c6f2eea..c61a81d47288 100644 --- a/rasa/shared/core/flows/flow.py +++ b/rasa/shared/core/flows/flow.py @@ -1,7 +1,6 @@ from __future__ import annotations from dataclasses import dataclass -from enum import Enum from typing import Any, Dict, List, Optional, Protocol, Set, Text, runtime_checkable import structlog @@ -963,24 +962,6 @@ def is_triggered(self, tracker: DialogueStateTracker) -> bool: return False -# enumeration of collect information scopes. scope can either be flow or global -class CollectInformationScope(str, Enum): - FLOW = "flow" - GLOBAL = "global" - - @staticmethod - def from_str(label: Optional[Text]) -> "CollectInformationScope": - """Converts a string to a CollectInformationScope.""" - if label is None: - return CollectInformationScope.FLOW - elif label.lower() == "flow": - return CollectInformationScope.FLOW - elif label.lower() == "global": - return CollectInformationScope.GLOBAL - else: - raise NotImplementedError - - @dataclass class SlotRejection: """A slot rejection.""" @@ -1029,8 +1010,8 @@ class CollectInformationFlowStep(FlowStep): """how the slot value is validated using predicate evaluation.""" ask_before_filling: bool = False """Whether to always ask the question even if the slot is already filled.""" - scope: CollectInformationScope = CollectInformationScope.FLOW - """how the question is scoped, determines when to reset its value.""" + reset_after_flow_ends: bool = True + """Determines whether to reset the slot value at the end of the flow.""" @classmethod def from_json(cls, flow_step_config: Dict[Text, Any]) -> CollectInformationFlowStep: @@ -1049,7 +1030,7 @@ def from_json(cls, flow_step_config: Dict[Text, Any]) -> CollectInformationFlowS "utter", f"utter_ask_{flow_step_config['collect_information']}" ), ask_before_filling=flow_step_config.get("ask_before_filling", False), - scope=CollectInformationScope.from_str(flow_step_config.get("scope")), + reset_after_flow_ends=flow_step_config.get("reset_after_flow_ends", True), rejections=[ SlotRejection.from_dict(rejection) for rejection in flow_step_config.get("rejections", []) @@ -1067,7 +1048,7 @@ def as_json(self) -> Dict[Text, Any]: dump["collect_information"] = self.collect_information dump["utter"] = self.utter dump["ask_before_filling"] = self.ask_before_filling - dump["scope"] = self.scope.value + dump["reset_after_flow_ends"] = self.reset_after_flow_ends dump["rejections"] = [rejection.as_dict() for rejection in self.rejections] return dump