Skip to content

Commit

Permalink
Utter actions (#5297)
Browse files Browse the repository at this point in the history
removed utterance actions from examples and documentation
  • Loading branch information
MichaelMarien authored Feb 26, 2020
1 parent ebfcfc9 commit 2edc18a
Show file tree
Hide file tree
Showing 19 changed files with 62 additions and 129 deletions.
1 change: 1 addition & 0 deletions changelog/5174.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated the documentation to properly suggest not to explicitly add utterance actions to the domain.
5 changes: 0 additions & 5 deletions data/test_domains/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,3 @@ responses:
- text: goodbye :(
utter_default:
- text: default message

actions:
- utter_default
- utter_greet
- utter_goodbye
5 changes: 0 additions & 5 deletions data/test_domains/default_unfeaturized_entities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,3 @@ responses:
- goodbye :(
utter_default:
- default message

actions:
- utter_default
- utter_greet
- utter_goodbye
5 changes: 0 additions & 5 deletions data/test_domains/default_with_mapping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,3 @@ responses:
- text: goodbye :(
utter_default:
- text: default message

actions:
- utter_default
- utter_greet
- utter_goodbye
5 changes: 0 additions & 5 deletions data/test_domains/default_with_slots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,3 @@ responses:
- text: "bye bye 😢"
utter_default: # utterance sent by action_default_fallback
- text: "sorry, I didn't get that, can you rephrase it?"

actions:
- utter_default
- utter_greet
- utter_goodbye
4 changes: 0 additions & 4 deletions data/test_domains/duplicate_entities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,3 @@ responses:
utter_default:
- text: default message

actions:
- utter_default
- utter_greet
- utter_goodbye
5 changes: 0 additions & 5 deletions data/test_domains/duplicate_intents.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ responses:
utter_default:
- text: default message

actions:
- utter_default
- utter_greet
- utter_goodbye

session_config:
session_expiration_time: 60
carry_over_slots_to_new_session: true
5 changes: 0 additions & 5 deletions data/test_domains/duplicate_templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,3 @@ responses:
- text: default message
utter_greet:
- text: hey there!

actions:
- utter_default
- utter_greet
- utter_goodbye
8 changes: 2 additions & 6 deletions data/test_domains/form.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ responses:
- text: goodbye :(
utter_default:
- text: default message

actions:
- utter_default
- utter_greet
- utter_goodbye
- utter_ask_continue
utter_ask_continue:
- text: should I continue?

forms:
- some_form
5 changes: 0 additions & 5 deletions data/test_domains/missing_text_for_templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,3 @@ responses:
- goodbye :(
utter_default:
- default message

actions:
- utter_default
- utter_greet
- utter_goodbye
4 changes: 0 additions & 4 deletions data/test_multi_domain/data/GreetBot/domain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ intents:
- greet
- goodbye

actions:
- utter_greet
- utter_goodbye

responses:
utter_greet:
- text: "Hey! How are you?"
Expand Down
5 changes: 0 additions & 5 deletions data/test_multi_domain/data/MoodBot/domain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ intents:
- mood_great
- mood_unhappy

actions:
- utter_did_that_help
- utter_happy
- utter_cheer_up

responses:
utter_cheer_up:
- text: "Here is something to cheer you up:"
Expand Down
3 changes: 0 additions & 3 deletions data/test_multi_domain/domain.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
intents:
- goodbye

actions:
- utter_goodbye

responses:
utter_goodbye:
- text: "Bye"
9 changes: 1 addition & 8 deletions docs/_static/spec/rasa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ components:
type: array
items:
type: string
example: ['utter_greet', 'utter_goodbye', 'action_listen']
example: ['action_greet', 'action_goodbye', 'action_listen']

BotMessage:
type: object
Expand Down Expand Up @@ -1420,13 +1420,6 @@ components:
- mood_great
- mood_unhappy
actions:
- utter_greet
- utter_cheer_up
- utter_did_that_help
- utter_happy
- utter_goodbye
responses:
utter_greet:
- text: "Hey! How are you?"
Expand Down
24 changes: 3 additions & 21 deletions docs/user-guide/building-assistants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ We’ll also need to add the intents, actions and templates to our ``domain.yml`
- bye
- thank
actions:
- utter_greet
- utter_noworries
- utter_bye
templates:
utter_noworries:
- text: No worries!
Expand Down Expand Up @@ -279,9 +274,6 @@ to the list of actions. These actions always have to start with the ``respond_``
.. code-block:: yaml
actions:
- utter_greet
- utter_noworries
- utter_bye
- respond_faq
Next we’ll write a story so that Core knows which action to predict:
Expand Down Expand Up @@ -656,7 +648,8 @@ yet we don’t want the intent to affect the dialogue history. To do this, the r
must be an action that returns the ``UserUtteranceReverted()`` event to remove the
interaction from the dialogue history.

First, open the ``domain.yml`` and modify the greet intent and add ``action_greet`` as shown here:
First, open the ``domain.yml`` and modify the greet intent and add a new block ```actions``` in
the file, next, add the ``action_greet`` as shown here:

.. code-block:: yaml
Expand All @@ -668,11 +661,7 @@ First, open the ``domain.yml`` and modify the greet intent and add ``action_gree
- contact_sales
- inform
Actions:
- utter_greet
- utter_noworries
- utter_bye
- respond_faq
actions:
- action_greet
Remove any stories using the "greet" intent if you have them.
Expand Down Expand Up @@ -785,10 +774,6 @@ We’ll need to add the intent and utterances we just added to our domain:
- faq
- explain
actions:
- utter_explain_why_budget
- utter_explain_why_email
templates:
utter_explain_why_budget:
- text: We need to know your budget to recommend a subscription
Expand Down Expand Up @@ -896,9 +881,6 @@ And finally we’ll add a template to our domain file:

.. code-block:: yaml
actions:
- utter_out_of_scope
templates:
utter_out_of_scope:
- text: Sorry, I can’t handle that request.
Expand Down
8 changes: 0 additions & 8 deletions examples/moodbot/domain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ intents:
- mood_unhappy
- bot_challenge

actions:
- utter_greet
- utter_cheer_up
- utter_did_that_help
- utter_happy
- utter_goodbye
- utter_iamabot

responses:
utter_greet:
- text: "Hey! How are you?"
Expand Down
8 changes: 0 additions & 8 deletions rasa/cli/initial_project/domain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ intents:
- mood_unhappy
- bot_challenge

actions:
- utter_greet
- utter_cheer_up
- utter_did_that_help
- utter_happy
- utter_goodbye
- utter_iamabot

responses:
utter_greet:
- text: "Hey! How are you?"
Expand Down
79 changes: 55 additions & 24 deletions tests/core/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,7 @@ def test_custom_slot_type(tmpdir: Path):
responses:
utter_greet:
- text: hey there!
actions:
- utter_greet """,
- text: hey there! """,
domain_path,
)
Domain.load(domain_path)
Expand All @@ -220,21 +217,15 @@ def test_custom_slot_type(tmpdir: Path):
responses:
utter_greet:
- text: hey there!
actions:
- utter_greet""",
- text: hey there!""",
"""
slots:
custom:
type: blubblubblub
responses:
utter_greet:
- text: hey there!
actions:
- utter_greet""",
- text: hey there!""",
],
)
def test_domain_fails_on_unknown_custom_slot_type(tmpdir, domain_unkown_slot_type):
Expand All @@ -245,9 +236,7 @@ def test_domain_fails_on_unknown_custom_slot_type(tmpdir, domain_unkown_slot_typ


def test_domain_to_yaml():
test_yaml = """actions:
- utter_greet
config:
test_yaml = """config:
store_entities_as_slots: true
entities: []
forms: []
Expand Down Expand Up @@ -306,9 +295,7 @@ def test_domain_to_yaml_deprecated_templates():


def test_merge_yaml_domains():
test_yaml_1 = """actions:
- utter_greet
config:
test_yaml_1 = """config:
store_entities_as_slots: true
entities: []
intents: []
Expand All @@ -317,10 +304,7 @@ def test_merge_yaml_domains():
utter_greet:
- text: hey there!"""

test_yaml_2 = """actions:
- utter_greet
- utter_goodbye
config:
test_yaml_2 = """config:
store_entities_as_slots: false
session_config:
session_expiration_time: 20
Expand All @@ -333,6 +317,8 @@ def test_merge_yaml_domains():
cuisine:
type: text
responses:
utter_goodbye:
- text: bye!
utter_greet:
- text: hey you!"""

Expand All @@ -342,7 +328,10 @@ def test_merge_yaml_domains():
# single attribute should be taken from domain_1
assert domain.store_entities_as_slots
# conflicts should be taken from domain_1
assert domain.templates == {"utter_greet": [{"text": "hey there!"}]}
assert domain.templates == {
"utter_greet": [{"text": "hey there!"}],
"utter_goodbye": [{"text": "bye!"}],
}
# lists should be deduplicated and merged
assert domain.intents == ["greet"]
assert domain.entities == ["cuisine"]
Expand All @@ -355,7 +344,10 @@ def test_merge_yaml_domains():
# single attribute should be taken from domain_2
assert not domain.store_entities_as_slots
# conflicts should take value from domain_2
assert domain.templates == {"utter_greet": [{"text": "hey you!"}]}
assert domain.templates == {
"utter_greet": [{"text": "hey you!"}],
"utter_goodbye": [{"text": "bye!"}],
}
assert domain.session_config == SessionConfig(20, True)


Expand Down Expand Up @@ -771,3 +763,42 @@ def test_domain_as_dict_with_session_config():
)
def test_are_sessions_enabled(session_config: SessionConfig, enabled: bool):
assert session_config.are_sessions_enabled() == enabled


def test_domain_utterance_actions_deprecated_templates():
new_yaml = """actions:
- utter_greet
- utter_goodbye
config:
store_entities_as_slots: true
entities: []
forms: []
intents: []
templates:
utter_greet:
- text: hey there!
utter_goodbye:
- text: bye!
session_config:
carry_over_slots_to_new_session: true
session_expiration_time: 60
slots: {}"""

old_yaml = """config:
store_entities_as_slots: true
entities: []
forms: []
intents: []
responses:
utter_greet:
- text: hey there!
utter_goodbye:
- text: bye!
session_config:
carry_over_slots_to_new_session: true
session_expiration_time: 60
slots: {}"""

old_domain = Domain.from_yaml(old_yaml)
new_domain = Domain.from_yaml(new_yaml)
assert hash(old_domain) == hash(new_domain)
3 changes: 0 additions & 3 deletions tests/core/test_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,9 +806,6 @@ def create_policy(self, featurizer, priority):
@pytest.fixture(scope="class")
def default_domain(self):
content = """
actions:
- utter_hello
intents:
- greet
- bye
Expand Down

0 comments on commit 2edc18a

Please sign in to comment.