From c0870ae531d457aec646f573d745f2744d56705f Mon Sep 17 00:00:00 2001 From: Tom Bocklisch Date: Mon, 18 Sep 2023 06:29:58 +0200 Subject: [PATCH] remoed obsolete type coercion during condition checking of pypred --- rasa/core/policies/flow_policy.py | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/rasa/core/policies/flow_policy.py b/rasa/core/policies/flow_policy.py index 00d70f0f2a7b..635c969ec9bc 100644 --- a/rasa/core/policies/flow_policy.py +++ b/rasa/core/policies/flow_policy.py @@ -294,30 +294,11 @@ def is_condition_satisfied( ) -> bool: """Evaluate a predicate condition.""" - def get_value( - initial_value: Union[Text, None] - ) -> Union[Text, float, bool, None]: - if initial_value is None or isinstance(initial_value, (bool, float)): - return initial_value - - # if this isn't a bool or float, it's something else - # the below is a best effort to convert it to something we can - # use for the predicate evaluation - initial_value = str(initial_value) # make sure it's a string - - if initial_value.lower() in ["true", "false"]: - return initial_value.lower() == "true" - - if initial_value.isnumeric(): - return float(initial_value) - - return initial_value - # attach context to the predicate evaluation to allow coditions using it context = {"context": DialogueStack.from_tracker(tracker).current_context()} document: Dict[str, Any] = context.copy() for slot in self.domain.slots: - document[slot.name] = get_value(tracker.get_slot(slot.name)) + document[slot.name] = tracker.get_slot(slot.name) p = Predicate(self.render_template_variables(predicate, context)) try: return p.evaluate(document)