Skip to content

Commit

Permalink
Merge pull request #3719 from RasaHQ/fix-duplicate-interactive-learni…
Browse files Browse the repository at this point in the history
…ng-events

Fix duplicate interactive learning events
  • Loading branch information
wochinge committed Jun 11, 2019
2 parents 9de1118 + 181d770 commit daeb88d
Show file tree
Hide file tree
Showing 9 changed files with 203 additions and 178 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Added

Changed
-------
- update the tracker in interactive learning through reverting and appending events
instead of replacing the tracker
- ``POST /conversations/{conversation_id}/tracker/events`` supports a list of events

Removed
-------
Expand Down
10 changes: 7 additions & 3 deletions docs/_static/spec/rasa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ paths:
- JWT: []
tags:
- Tracker
summary: Append an event to a tracker
summary: Append events to a tracker
description: >-
Appends a new event to the tracker state of the conversation.
Appends one or multiple new events to the tracker state of the conversation.
Any existing events will be kept and the new events will be
appended, updating the existing state.
parameters:
Expand All @@ -152,7 +152,11 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Event'
oneOf:
- $ref: '#/components/schemas/Event'
- type: array
items:
$ref: '#/components/schemas/Event'
responses:
200:
$ref: '#/components/responses/200Tracker'
Expand Down
2 changes: 0 additions & 2 deletions rasa/cli/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def add_subparser(


def interactive(args: argparse.Namespace):
args.finetune = False # Don't support finetuning
args.fixed_model_name = None
args.store_uncompressed = False

Expand All @@ -58,7 +57,6 @@ def interactive(args: argparse.Namespace):


def interactive_core(args: argparse.Namespace):
args.finetune = False # Don't support finetuning
args.fixed_model_name = None
args.store_uncompressed = False

Expand Down
8 changes: 4 additions & 4 deletions rasa/core/trackers.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ def applied_events(self) -> List[Event]:
"""Returns all actions that should be applied - w/o reverted events."""

def undo_till_previous(event_type, done_events):
"""Removes events from `done_events` until `event_type` is
found."""
"""Removes events from `done_events` until the first
occurrence `event_type` is found which is also removed."""
# list gets modified - hence we need to copy events!
for e in reversed(done_events[:]):
del done_events[-1]
Expand All @@ -349,8 +349,8 @@ def undo_till_previous(event_type, done_events):
elif isinstance(event, UserUtteranceReverted):
# Seeing a user uttered event automatically implies there was
# a listen event right before it, so we'll first rewind the
# user utterance, then get the action right before it (the
# listen action).
# user utterance, then get the action right before it (also removes
# the `action_listen` action right before it).
undo_till_previous(UserUttered, applied_events)
undo_till_previous(ActionExecuted, applied_events)
else:
Expand Down
4 changes: 0 additions & 4 deletions rasa/core/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,8 @@ async def do_compare_training(cmdline_args, stories, additional_arguments):
def do_interactive_learning(cmdline_args, stories, additional_arguments=None):
from rasa.core.training import interactive

if cmdline_args.core and cmdline_args.finetune:
raise ValueError("--core can only be used without --finetune flag.")

interactive.run_interactive_learning(
stories,
finetune=cmdline_args.finetune,
skip_visualization=cmdline_args.skip_visualization,
server_args=cmdline_args.__dict__,
additional_arguments=additional_arguments,
Expand Down
Loading

0 comments on commit daeb88d

Please sign in to comment.