Skip to content

Commit

Permalink
updated to latest dm2
Browse files Browse the repository at this point in the history
  • Loading branch information
tmbo committed Sep 21, 2023
1 parent fba9a4a commit c4c3c4a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions rasa/core/policies/flow_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,12 @@ def consider_flow_switch(self, tracker: DialogueStateTracker) -> ActionPredictio
else:
structlogger.debug("flow.nostartable")
return ActionPrediction(None, 0.0)

def should_abstain(self, tracker: DialogueStateTracker) -> bool:
"""
Don't make predictions if this is a dummy flow.
"""
if current_flow := self.dialogue_stack.top_flow(self.all_flows):
return current_flow.id.startswith("dummy")

def should_abstain(self) -> bool:
"""Don't make predictions if this is a dummy flow."""
active_frame = self.dialogue_stack.top()
if isinstance(active_frame, BaseFlowStackFrame):
return active_frame.flow(self.all_flows).id.startswith("dummy")
return False

def advance_flows(self, tracker: DialogueStateTracker) -> ActionPrediction:
Expand All @@ -428,8 +427,7 @@ def advance_flows(self, tracker: DialogueStateTracker) -> ActionPrediction:
Returns:
The predicted action and the events to run.
"""
abstain = self.should_abstain(tracker)
if abstain:
if self.should_abstain():
return ActionPrediction(None, 0.0)

prediction = self.consider_flow_switch(tracker)
Expand Down

0 comments on commit c4c3c4a

Please sign in to comment.