notice

This is documentation for Rasa Documentation v2.x, which is no longer actively maintained.
For up-to-date documentation, see the latest version (3.x).

Version: 2.x

rasa.shared.core.training_data.structures

EventTypeError Objects

class EventTypeError(RasaCoreException, ValueError)

Represents an error caused by a Rasa Core event not being of the expected type.

Checkpoint Objects

class Checkpoint()

Represents places where trackers split.

This currently happens if

  • users place manual checkpoints in their stories
  • have or statements for intents in their stories.

__init__

| __init__(name: Text, conditions: Optional[Dict[Text, Any]] = None) -> None

Creates Checkpoint.

Arguments:

  • name - Name of the checkpoint.
  • conditions - Slot conditions for this checkpoint.

filter_trackers

| filter_trackers(trackers: List[DialogueStateTracker]) -> List[DialogueStateTracker]

Filters out all trackers that do not satisfy the conditions.

StoryStep Objects

class StoryStep()

A StoryStep is a section of a story block between two checkpoints.

NOTE: Checkpoints are not only limited to those manually written in the story file, but are also implicitly created at points where multiple intents are separated in one line by chaining them with "OR"s.

is_action_unlikely_intent

| @staticmethod
| is_action_unlikely_intent(event: Event) -> bool

Checks if the executed action is a action_unlikely_intent.

is_action_session_start

| @staticmethod
| is_action_session_start(event: Event) -> bool

Checks if the executed action is a action_session_start.

explicit_events

| explicit_events(domain: Domain, should_append_final_listen: bool = True) -> List[Union[Event, List[Event]]]

Returns events contained in the story step including implicit events.

Not all events are always listed in the story dsl. This includes listen actions as well as implicitly set slots. This functions makes these events explicit and returns them with the rest of the steps events.

RuleStep Objects

class RuleStep(StoryStep)

A Special type of StoryStep representing a Rule.

get_rules_condition

| get_rules_condition() -> List[Event]

Returns a list of events forming a condition of the Rule.

get_rules_events

| get_rules_events() -> List[Event]

Returns a list of events forming the Rule, that are not conditions.

add_event_as_condition

| add_event_as_condition(event: Event) -> None

Adds event to the Rule as part of its condition.

Arguments:

  • event - The event to be added.

Story Objects

class Story()

from_events

| @staticmethod
| from_events(events: List[Event], story_name: Optional[Text] = None) -> "Story"

Create a story from a list of events.

StoryGraph Objects

class StoryGraph()

Graph of the story-steps pooled from all stories in the training data.

__hash__

| __hash__() -> int

Return hash for the story step.

Returns:

Hash of the story step.

fingerprint

| fingerprint() -> Text

Returns a unique hash for the stories which is stable across python runs.

Returns:

fingerprint of the stories

ordered_steps

| ordered_steps() -> List[StoryStep]

Returns the story steps ordered by topological order of the DAG.

cyclic_edges

| cyclic_edges() -> List[Tuple[Optional[StoryStep], Optional[StoryStep]]]

Returns the story steps ordered by topological order of the DAG.

overlapping_checkpoint_names

| @staticmethod
| overlapping_checkpoint_names(cps: List[Checkpoint], other_cps: List[Checkpoint]) -> Set[Text]

Find overlapping checkpoints names

with_cycles_removed

| with_cycles_removed() -> "StoryGraph"

Create a graph with the cyclic edges removed from this graph.

get

| get(step_id: Text) -> Optional[StoryStep]

Looks a story step up by its id.

as_story_string

| as_story_string() -> Text

Convert the graph into the story file format.

order_steps

| @staticmethod
| order_steps(story_steps: List[StoryStep]) -> Tuple[deque, List[Tuple[Text, Text]]]

Topological sort of the steps returning the ids of the steps.

topological_sort

| @staticmethod
| topological_sort(graph: Dict[Text, Set[Text]]) -> Tuple[deque, List[Tuple[Text, Text]]]

Creates a top sort of a directed graph. This is an unstable sorting!

The function returns the sorted nodes as well as the edges that need to be removed from the graph to make it acyclic (and hence, sortable).

The graph should be represented as a dictionary, e.g.:

>>> example_graph = { ... "a": set("b", "c", "d"), ... "b": set(), ... "c": set("d"), ... "d": set(), ... "e": set("f"), ... "f": set()} >>> StoryGraph.topological_sort(example_graph) (deque([u'e', u'f', u'a', u'c', u'd', u'b']), [])

is_empty

| is_empty() -> bool

Checks if StoryGraph is empty.

generate_id

generate_id(prefix: Text = "", max_chars: Optional[int] = None) -> Text

Generate a random UUID.

Arguments:

  • prefix - String to prefix the ID with.
  • max_chars - Maximum number of characters.

Returns:

Generated random UUID.