Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form switching #7771

Merged
merged 29 commits into from
Feb 8, 2021
Merged

Form switching #7771

merged 29 commits into from
Feb 8, 2021

Conversation

ArjaanBuijk
Copy link
Contributor

@ArjaanBuijk ArjaanBuijk commented Jan 21, 2021

Proposed changes:
Fixes for two issues when switching forms:

Status (please check what you already did):

  • added some tests for the functionality
  • updated the documentation
  • updated the changelog (please check changelog for instructions)
  • reformat files using black (please check Readme for instructions)

Fix for issue #7751 to avoid that a form will re-ask for the slot prior to switching to another form.
Copy link
Contributor

@wochinge wochinge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core re-asks for slot upon form interruption

In my opinion this can't happen due to

if await self.is_done(output_channel, nlg, tracker, domain, events_so_far):
, no?

Base automatically changed from master to main January 22, 2021 11:15
forms is first called for the original form. 
- The slot validation is called on the sentence that will trigger the form switching, but the original form is still active. The slot validation will fail and will also return ActionExecutionRejected event
- Need to avoid raising the ActionExecutionRejected event too soon, because other slots might be set by the custom action. Reverted that change with a comment to clarify.
- Need to avoid asking for the requested slot by checking if ActionExecutionRejected event was returned. The form is not yet done, so the is_done() method is still False.
@ArjaanBuijk
Copy link
Contributor Author

@wochinge ,

Core re-asks for slot upon form interruption

In my opinion this can't happen due to

if await self.is_done(output_channel, nlg, tracker, domain, events_so_far):

, no?

It actually does happen, because the loop is first done with the original form still active.

  • The sentence that will trigger the next form is first validated for the requested slot of the orginal form
  • The validation will fail, but the form is not done, and it will ask for the next slot if we don't prevent this

I restored the logic to avoid raising the ActionExecutionRejected to quickly, so other slots set by the custom validation action will be set, but add an if statement that avoids the form asking for the next slot if ActionExecutionRejected was returned.

@ArjaanBuijk ArjaanBuijk requested a review from wochinge January 22, 2021 21:42
Copy link
Contributor

@wochinge wochinge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rasa/core/actions/forms.py Outdated Show resolved Hide resolved
rasa/core/actions/forms.py Outdated Show resolved Hide resolved
rasa/core/actions/forms.py Outdated Show resolved Hide resolved
rasa/core/actions/forms.py Outdated Show resolved Hide resolved
rasa/core/actions/forms.py Outdated Show resolved Hide resolved
rasa/core/actions/forms.py Show resolved Hide resolved
rasa/core/actions/forms.py Outdated Show resolved Hide resolved
ArjaanBuijk and others added 5 commits January 26, 2021 14:01
Co-authored-by: Tobias Wochinger <[email protected]>
Co-authored-by: Tobias Wochinger <[email protected]>
Co-authored-by: Tobias Wochinger <[email protected]>
Co-authored-by: Tobias Wochinger <[email protected]>
@wochinge
Copy link
Contributor

Just re-request review once you you're done 🙌🏻

@ArjaanBuijk ArjaanBuijk requested review from wochinge and removed request for Ghostvv and desmarchris January 27, 2021 17:16
changelog/7751.bugfix.md Show resolved Hide resolved
rasa/core/actions/forms.py Outdated Show resolved Hide resolved
rasa/core/actions/forms.py Outdated Show resolved Hide resolved
rasa/core/actions/forms.py Outdated Show resolved Hide resolved
rasa/core/actions/forms.py Outdated Show resolved Hide resolved
tests/core/actions/test_forms.py Outdated Show resolved Hide resolved
tests/core/actions/test_forms.py Outdated Show resolved Hide resolved
tests/core/actions/test_forms.py Outdated Show resolved Hide resolved
tests/core/actions/test_forms.py Outdated Show resolved Hide resolved
tests/core/actions/test_forms.py Outdated Show resolved Hide resolved
ArjaanBuijk and others added 2 commits February 2, 2021 11:15
Co-authored-by: Tobias Wochinger <[email protected]>
Co-authored-by: Tobias Wochinger <[email protected]>
@ArjaanBuijk ArjaanBuijk requested a review from wochinge February 2, 2021 21:20
tests/core/actions/test_forms.py Outdated Show resolved Hide resolved
tests/core/actions/test_forms.py Outdated Show resolved Hide resolved
tests/core/actions/test_forms.py Outdated Show resolved Hide resolved
tests/core/actions/test_forms.py Outdated Show resolved Hide resolved
tests/core/actions/test_forms.py Outdated Show resolved Hide resolved
@TyDunn TyDunn added this to the 2.3 Rasa Open Source milestone Feb 5, 2021
- simpler call to PolicyPrediction, using all defaults
- Build up an `events_expected` list as we go, and assert it against the tracker
- Include the `BotUttered()` event in the `events_expected` list that is asserted.
@ArjaanBuijk
Copy link
Contributor Author

@wochinge ,
I like the way the test for form switching is looking after implementing your suggestions. Let me know what you think.

@ArjaanBuijk ArjaanBuijk requested a review from wochinge February 5, 2021 16:36
Copy link
Contributor

@wochinge wochinge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 🚀 Nice work! Do you want to target 2.2.x so you can release a micro with the fix? Alternatively we're also releasing a minor on Thursday.

@ArjaanBuijk
Copy link
Contributor Author

Looks good Nice work! Do you want to target 2.2.x so you can release a micro with the fix? Alternatively we're also releasing a minor on Thursday.

@wochinge ,
I prefer to release in the minor on Thursday.

Copy link
Contributor

@wochinge wochinge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@ArjaanBuijk ArjaanBuijk merged commit 5195217 into main Feb 8, 2021
@ArjaanBuijk ArjaanBuijk deleted the form-switching branch February 8, 2021 16:49
@wochinge
Copy link
Contributor

wochinge commented Feb 8, 2021

Nice work @ArjaanBuijk ! 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants