Skip to content

Commit

Permalink
refactored and added tests to policy
Browse files Browse the repository at this point in the history
  • Loading branch information
tmbo committed Oct 27, 2023
1 parent f71a675 commit ca26d16
Show file tree
Hide file tree
Showing 13 changed files with 1,212 additions and 988 deletions.
610 changes: 11 additions & 599 deletions rasa/core/policies/flow_policy.py

Large diffs are not rendered by default.

Empty file.
31 changes: 31 additions & 0 deletions rasa/core/policies/flows/flow_exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from rasa.dialogue_understanding.stack.dialogue_stack import DialogueStack
from rasa.shared.exceptions import RasaException


class FlowException(RasaException):
"""Exception that is raised when there is a problem with a flow."""

pass


class FlowCircuitBreakerTrippedException(FlowException):
"""Exception that is raised when the flow circuit breaker tripped.
The circuit breaker gets tripped when a flow seems to be stuck in
executing steps and does not make any progress."""

def __init__(
self, dialogue_stack: DialogueStack, number_of_steps_taken: int
) -> None:
"""Creates a `FlowCircuitBreakerTrippedException`.
Args:
dialogue_stack: The dialogue stack.
number_of_steps_taken: The number of steps that were taken.
"""
super().__init__(
f"Flow circuit breaker tripped after {number_of_steps_taken} steps. "
"There appears to be an infinite loop in the flows."
)
self.dialogue_stack = dialogue_stack
self.number_of_steps_taken = number_of_steps_taken
Loading

0 comments on commit ca26d16

Please sign in to comment.