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

tracker.form_slots_to_validate returns no slots on activation #269

Closed
NetBKarine opened this issue Sep 15, 2020 · 3 comments · Fixed by #276
Closed

tracker.form_slots_to_validate returns no slots on activation #269

NetBKarine opened this issue Sep 15, 2020 · 3 comments · Fixed by #276
Labels
area:rasa-sdk 🧑‍💻 Everything that touches our python Rasa SDK type:bug 🐛 Something isn't working

Comments

@NetBKarine
Copy link

Rasa version: 2.0.0a4

Rasa SDK version: 2.0.0a4

Python version: 3.7.8

Operating system (windows, osx, ...): Ubuntu 18.04

Issue:
tracker.form_slots_to_validate() ignores slots to validate when called on form activation. I didn't try it with pre-filled slots, but the problem will probably be the same as with a slot filled with a from_trigger_intent mapping (I think it's the check to see if there's an active loop that causes this). Here's a simple example to test it:

Command or request that led to error:

rasa shell --debug
Your input ->  /test_form
Asking other slot
Your input ->  /affirm
Form completed. Value is value_to_correct

Content of configuration file (config.yml) (if relevant):

...
policies:
  - name: RulePolicy

Content of domain file (domain.yml) (if relevant):

intents:
  - affirm
  - test_form

actions:
  - validate_test_trigger_intent_form

forms:
  - test_trigger_intent_form:
      filled_with_trigger_intent:
        - type: from_trigger_intent
          intent: test_form
          value: value_to_correct
      other_slot: # Just to verify if value is validated later
        - type: from_intent
          intent: affirm
          value: True

slots:
  filled_with_trigger_intent:
    type: unfeaturized

  other_slot:
    type: unfeaturized

templates:
  utter_ask_other_slot:
    - text: Asking other slot

  utter_form_completed:
    - text: Form completed. Value is {filled_with_trigger_intent}

Content of rules file (rules.yml) (if relevant):

...
rules:
  - rule: test trigger intent validation
    steps:
      - intent: test_form
      - action: test_trigger_intent_form
      - active_loop: test_trigger_intent_form
      - active_loop: null
      - action: utter_form_completed

Contents of actions.py (if relevant):

class ValidateTestTriggerIntentForm(Action):
    def name(self) -> Text:
        return "validate_test_trigger_intent_form"

    def run(
        self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
    ) -> List[EventType]:
        extracted_slots: Dict[Text, Any] = tracker.form_slots_to_validate()

        logger.info(f"Validating extracted slots: {extracted_slots}")
        logger.info(tracker.events)

        validation_events: List[EventType] = []

        for slot_name, slot_value in extracted_slots.items():
            if slot_name == "filled_with_trigger_intent" and slot_value == "value_to_correct":
                validation_events.append(SlotSet("filled_with_trigger_intent", "corrected_value"))

        return validation_events

Logs show that the correct events are there and core calls the validation action with the slot:

Action server logs for first interaction:

...
action-server_1  | 2020-09-15 18:16:03 INFO     covidflow.actions.test_trigger_intent_form  - [info     ] Validating extracted slots: {} 
action-server_1  | 2020-09-15 18:16:03 INFO     covidflow.actions.test_trigger_intent_form  - [info     ] [{'event': 'action', 'timestamp': 1600193759.547206, 'name': 'action_listen', 'policy': None, 'confidence': 1.0}, {'event': 'user', 'timestamp': 1600193763.3620577, 'text': '/test_form', 'parse_data': {'intent': {'name': 'test_form', 'confidence': 1.0}, 'entities': [], 'text': '/test_form', 'message_id': 'b3562360e39546a685aea2ff0afa0b29', 'metadata': {}, 'intent_ranking': [{'name': 'test_form', 'confidence': 1.0}]}, 'input_channel': 'cmdline', 'message_id': 'b3562360e39546a685aea2ff0afa0b29', 'metadata': {}}, {'event': 'action', 'timestamp': 1600193763.3705964, 'name': 'test_trigger_intent_form', 'policy': None, 'confidence': None}, {'event': 'slot', 'timestamp': 1600193763.370542, 'name': 'filled_with_trigger_intent', 'value': 'value_to_correct'}] 
...

Core logs for first interaction:

...
2020-09-15 18:42:58 DEBUG    rasa.core.actions.forms  - Activated the form 'test_trigger_intent_form'.
2020-09-15 18:42:58 DEBUG    rasa.core.actions.forms  - No pre-filled required slots to validate.
2020-09-15 18:42:58 DEBUG    rasa.core.actions.forms  - Validating user input 'UserUttered(text: /test_form, intent: {'name': 'test_form', 'confidence': 1.0}, entities: [])'.
2020-09-15 18:42:58 DEBUG    rasa.core.actions.forms  - Extracted 'value_to_correct' for extra slot 'filled_with_trigger_intent'.
2020-09-15 18:42:58 DEBUG    rasa.core.actions.forms  - Validating extracted slots: {'filled_with_trigger_intent': 'value_to_correct'}
2020-09-15 18:42:58 DEBUG    rasa.core.actions.action  - Calling action endpoint to run action 'validate_test_trigger_intent_form'.
...
@NetBKarine NetBKarine added area:rasa-sdk 🧑‍💻 Everything that touches our python Rasa SDK type:bug 🐛 Something isn't working labels Sep 15, 2020
@sara-tagger
Copy link

Thanks for the issue, @degiz will get back to you about it soon!

You may find help in the docs and the forum, too 🤗

@petasis
Copy link

petasis commented Oct 4, 2020

I am also facing the same issue. How to fix it?

@akelad
Copy link
Contributor

akelad commented Oct 5, 2020

Hey @NetBKarine, this should be fixed by PR #276. Thanks for bringing that up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:rasa-sdk 🧑‍💻 Everything that touches our python Rasa SDK type:bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants