Skip to content

Commit

Permalink
ATO-218 Tackle review findings
Browse files Browse the repository at this point in the history
  • Loading branch information
losterloh committed Jul 14, 2022
1 parent d2948f0 commit eb6805d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
7 changes: 3 additions & 4 deletions changelog/11333.bugfix.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
`SlotSet` events will be emitted even if slot value remains unchanged.
`SlotSet` events will be emitted when the value set by the current user turn is the same as the existing value.

Previously, `ActionExtractSlots` would not emit any `SlotSet` events if the value remains
unchanged. However, this breaks the augmented memoization policy cause it will lose these
slot values when truncating the tracker.
Previously, `ActionExtractSlots` would not emit any `SlotSet` events if the new value was the same as the existing
one. This caused the augmented memoization policy to lose these slot values when truncating the tracker.
22 changes: 13 additions & 9 deletions tests/core/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2667,24 +2667,28 @@ async def test_action_extract_slots_non_required_form_slot_with_from_entity_mapp


async def test_action_extract_slots_returns_slot_set_even_if_slot_value_is_unchanged():
entity_name = "entity"
value = "value"
intent_name = "intent_with_entity"

event_with_slot_entity = UserUttered(
text="I am a text",
intent={"name": "intent_with_entity"},
entities=[{"entity": "entity", "value": "value"}],
intent={"name": intent_name},
entities=[{"entity": entity_name, "value": value}],
)

domain = textwrap.dedent(
"""
f"""
intents:
- intent_with_entity
- {intent_name}
entities:
- entity
- {entity_name}
slots:
entity:
type: text
mappings:
- type: from_entity
entity: entity
entity: {entity_name}
"""
)

Expand All @@ -2697,7 +2701,7 @@ async def test_action_extract_slots_returns_slot_set_even_if_slot_value_is_uncha
],
)

tracker._set_slot("entity", "value")
tracker._set_slot(entity_name, value)

action = ActionExtractSlots(None)

Expand All @@ -2710,5 +2714,5 @@ async def test_action_extract_slots_returns_slot_set_even_if_slot_value_is_uncha

assert len(events) == 1
assert type(events[0]) == SlotSet
assert events[0].key == "entity"
assert events[0].value == "value"
assert events[0].key == entity_name
assert events[0].value == value

0 comments on commit eb6805d

Please sign in to comment.