def _predict_next_with_tracker( self, tracker: DialogueStateTracker) -> PolicyPrediction: """Collect predictions from ensemble and return action and predictions.""" followup_action = tracker.followup_action if followup_action: tracker.clear_followup_action() if followup_action in self.domain.action_names_or_texts: prediction = PolicyPrediction.for_action_name( self.domain, followup_action, FOLLOWUP_ACTION) return prediction logger.error( f"Trying to run unknown follow-up action '{followup_action}'. " "Instead of running that, Rasa Open Source will ignore the action " "and predict the next action.") target = self.model_metadata.core_target if not target: raise ValueError( "Cannot predict next action if there is no core target.") results = self.graph_runner.run( inputs={PLACEHOLDER_TRACKER: tracker}, targets=[target], ) policy_prediction = results[target] return policy_prediction
def _get_next_action_probabilities( self, tracker: DialogueStateTracker) -> PolicyPrediction: """Collect predictions from ensemble and return action and predictions.""" followup_action = tracker.followup_action if followup_action: tracker.clear_followup_action() if followup_action in self.domain.action_names: return PolicyPrediction.for_action_name( self.domain, followup_action, FOLLOWUP_ACTION) logger.error( f"Trying to run unknown follow-up action '{followup_action}'. " "Instead of running that, Rasa Open Source will ignore the action " "and predict the next action.") prediction = self.policy_ensemble.probabilities_using_best_policy( tracker, self.domain, self.interpreter) if isinstance(prediction, PolicyPrediction): return prediction rasa.shared.utils.io.raise_deprecation_warning( f"Returning a tuple of probabilities and policy name for " f"`{PolicyEnsemble.probabilities_using_best_policy.__name__}` is " f"deprecated and will be removed in Rasa Open Source 3.0.0. Please return " f"a `{PolicyPrediction.__name__}` object instead.") probabilities, policy_name = prediction return PolicyPrediction(probabilities, policy_name)
def _get_next_action_probabilities( self, tracker: DialogueStateTracker) -> PolicyPrediction: """Collect predictions from ensemble and return action and predictions.""" followup_action = tracker.followup_action if followup_action: tracker.clear_followup_action() if followup_action in self.domain.action_names_or_texts: return PolicyPrediction.for_action_name( self.domain, followup_action, FOLLOWUP_ACTION) logger.error( f"Trying to run unknown follow-up action '{followup_action}'. " "Instead of running that, Rasa Open Source will ignore the action " "and predict the next action.") return self.policy_ensemble.probabilities_using_best_policy( tracker, self.domain, self.interpreter)
def _get_next_action_probabilities( self, tracker: DialogueStateTracker ) -> Tuple[List[float], Optional[Text]]: """Collect predictions from ensemble and return action and predictions.""" followup_action = tracker.followup_action if followup_action: tracker.clear_followup_action() result = self._prob_array_for_action(followup_action) if result: return result else: logger.error( f"Trying to run unknown follow-up action '{followup_action}'!" "Instead of running that, we will ignore the action " "and predict the next action.") return self.policy_ensemble.probabilities_using_best_policy( tracker, self.domain, self.interpreter)