async def retrieve(self, sender_id: Text) -> Optional[DialogueStateTracker]: """Retrieve dialogues for a sender_id in reverse-chronological order. Based on the session_date sort key. """ dialogues = self.db.query( KeyConditionExpression=Key("sender_id").eq(sender_id), Limit=1, ScanIndexForward=False, )["Items"] if not dialogues: return None events = dialogues[0].get("events", []) # `float`s are stored as `Decimal` objects - we need to convert them back events_with_floats = core_utils.replace_decimals_with_floats(events) if self.domain is None: slots = [] else: slots = self.domain.slots return DialogueStateTracker.from_dict(sender_id, events_with_floats, slots)
def test_replace_decimals_with_floats(_input: Any, expected: Any): assert utils.replace_decimals_with_floats(_input) == expected