示例#1
0
def test_dialogue_from_parameters(domain: Domain):
    filename = "data/test_dialogues/default.json"
    tracker = tracker_from_dialogue_file(filename, domain)
    serialised_dialogue = InMemoryTrackerStore.serialise_tracker(tracker)
    deserialised_dialogue = Dialogue.from_parameters(
        json.loads(serialised_dialogue))
    assert tracker.as_dialogue().as_dict() == deserialised_dialogue.as_dict()
示例#2
0
def test_dialogue_from_parameters():
    domain = Domain.load(DEFAULT_DOMAIN_PATH_WITH_SLOTS_AND_NO_ACTIONS)
    filename = "data/test_dialogues/default.json"
    tracker = tracker_from_dialogue_file(filename, domain)
    serialised_dialogue = InMemoryTrackerStore.serialise_tracker(tracker)
    deserialised_dialogue = Dialogue.from_parameters(json.loads(serialised_dialogue))
    assert tracker.as_dialogue().as_dict() == deserialised_dialogue.as_dict()
示例#3
0
    def deserialise_tracker(
        self, sender_id: Text,
        serialised_tracker: Union[Text,
                                  bytes]) -> Optional[DialogueStateTracker]:
        """Deserializes the tracker and returns it."""

        tracker = self.init_tracker(sender_id)

        try:
            dialogue = Dialogue.from_parameters(json.loads(serialised_tracker))
        except UnicodeDecodeError:
            dialogue = self._deserialize_dialogue_from_pickle(
                sender_id, serialised_tracker)

        tracker.recreate_from_dialogue(dialogue)

        return tracker
示例#4
0
    def deserialise_tracker(
        self, sender_id: Text, serialised_tracker: Union[Text, bytes]
    ) -> Optional[DialogueStateTracker]:
        """Deserializes the tracker and returns it."""
        tracker = self.init_tracker(sender_id)

        try:
            dialogue = Dialogue.from_parameters(json.loads(serialised_tracker))
        except UnicodeDecodeError as e:
            raise TrackerDeserialisationException(
                "Tracker cannot be deserialised. "
                "Trackers must be serialised as json. "
                "Support for deserialising pickled trackers has been removed."
            ) from e

        tracker.recreate_from_dialogue(dialogue)

        return tracker
示例#5
0
def test_dialogue_from_parameters(domain: Domain):
    tracker = tracker_from_dialogue(TEST_DEFAULT_DIALOGUE, domain)
    serialised_dialogue = InMemoryTrackerStore.serialise_tracker(tracker)
    deserialised_dialogue = Dialogue.from_parameters(
        json.loads(serialised_dialogue))
    assert tracker.as_dialogue().as_dict() == deserialised_dialogue.as_dict()