Example #1
0
    def update(self, event: Event, domain: Optional[Domain] = None) -> None:
        """Modify the state of the tracker according to an ``Event``."""
        if not isinstance(event, Event):  # pragma: no cover
            raise ValueError("event to log must be an instance of a subclass of Event.")

        if self.model_id and METADATA_MODEL_ID not in event.metadata:
            event.metadata = {**event.metadata, METADATA_MODEL_ID: self.model_id}

        self.events.append(event)
        event.apply_to(self)
Example #2
0
    def update(self, event: Event, domain: Optional[Domain] = None) -> None:
        """Modify the state of the tracker according to an ``Event``. """
        if not isinstance(event, Event):  # pragma: no cover
            raise ValueError("event to log must be an instance of a subclass of Event.")

        self.events.append(event)
        event.apply_to(self)

        if domain and isinstance(event, UserUttered):
            # store all entities as slots
            for e in domain.slots_for_entities(event.parse_data["entities"]):
                self.update(e)
Example #3
0
    def update(self, event: Event, domain: Optional[Domain] = None) -> None:
        """Modify the state of the tracker according to an ``Event``. """
        if not isinstance(event, Event):  # pragma: no cover
            raise ValueError("event to log must be an instance of a subclass of Event.")

        self.events.append(event)
        event.apply_to(self)

        if domain and isinstance(event, (UserUttered, EntitiesAdded)):
            if isinstance(event, UserUttered):
                # Rather get entities from `parse_data` as
                # `DefinePrevUserUtteredEntities` might have already affected the
                # `UserUttered.entities` attribute (this might e.g. happen when the
                # `InMemoryTrackerStore` is used).
                entities = event.parse_data[ENTITIES]
            else:
                entities = event.entities

            for e in domain.slots_for_entities(entities):
                self.update(e)