Skip to content

Commit

Permalink
Merge pull request #7388 from RasaHQ/e2e-story-printing
Browse files Browse the repository at this point in the history
E2e story printing
  • Loading branch information
wochinge authored Dec 7, 2020
2 parents a1f0a39 + a1e2bee commit de9e17a
Show file tree
Hide file tree
Showing 26 changed files with 648 additions and 392 deletions.
9 changes: 5 additions & 4 deletions rasa/core/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,17 +304,18 @@ def __init__(self, event: UserUttered, eval_store: EvaluationStore) -> None:

def inline_comment(self) -> Text:
"""A comment attached to this event. Used during dumping."""
from rasa.shared.core.events import md_format_message
from rasa.shared.core.events import format_message

predicted_message = md_format_message(
predicted_message = format_message(
self.text, self.predicted_intent, self.predicted_entities
)
return f"predicted: {self.predicted_intent}: {predicted_message}"

def as_story_string(self, e2e: bool = True) -> Text:
from rasa.shared.core.events import md_format_message
"""Returns text representation of event."""
from rasa.shared.core.events import format_message

correct_message = md_format_message(
correct_message = format_message(
self.text, self.intent.get("name"), self.entities
)
return (
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/training/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def add_user_cell(data, cell):

for idx, event in enumerate(applied_events):
if isinstance(event, ActionExecuted):
bot_column.append(colored(event.action_name, "autocyan"))
bot_column.append(colored(str(event), "autocyan"))
if event.confidence is not None:
bot_column[-1] += colored(f" {event.confidence:03.2f}", "autowhite")

Expand Down
8 changes: 4 additions & 4 deletions rasa/core/training/story_conflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ def _find_conflicting_states(
state_action_mapping = defaultdict(list)
for element in _sliced_states_iterator(trackers, domain, max_history):
hashed_state = element.sliced_states_hash
if element.event.as_story_string() not in state_action_mapping[hashed_state]:
state_action_mapping[hashed_state] += [element.event.as_story_string()]
current_hash = hash(element.event)
if current_hash not in state_action_mapping[hashed_state]:
state_action_mapping[hashed_state] += [current_hash]

# Keep only conflicting `state_action_mapping`s
return {
Expand Down Expand Up @@ -238,8 +239,7 @@ def _build_conflicts_from_states(
conflicts[hashed_state] = StoryConflict(element.sliced_states)

conflicts[hashed_state].add_conflicting_action(
action=element.event.as_story_string(),
story_name=element.tracker.sender_id,
action=str(element.event), story_name=element.tracker.sender_id,
)

# Return list of conflicts that arise from unpredictable actions
Expand Down
1 change: 1 addition & 0 deletions rasa/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ def __init__(self, timestamp: float) -> None:
super(PublishingError, self).__init__()

def __str__(self) -> Text:
"""Returns string representation of exception."""
return str(self.timestamp)
Loading

0 comments on commit de9e17a

Please sign in to comment.