Skip to content

Instantly share code, notes, and snippets.

@maxbrenner-ai
Last active November 23, 2018 19:46
Show Gist options
  • Save maxbrenner-ai/5a2ce5d509c801a0d2e10a1303e06795 to your computer and use it in GitHub Desktop.
Save maxbrenner-ai/5a2ce5d509c801a0d2e10a1303e06795 to your computer and use it in GitHub Desktop.
rule-based policy
def _rule_action(self):
# self.rule_current_slot_index points to current slot
# rule_requests defined in dialogue_config.py
if self.rule_current_slot_index < len(rule_requests):
slot = rule_requests[self.rule_current_slot_index]
self.rule_current_slot_index += 1
rule_response = {'intent': 'request', 'inform_slots': {}, 'request_slots': {slot: 'UNK'}}
# self.rule_phase used to indicate if we are at second to last round or last round
elif self.rule_phase == 'not done':
rule_response = {'intent': 'match_found', 'inform_slots': {}, 'request_slots': {}}
self.rule_phase = 'done'
elif self.rule_phase == 'done':
rule_response = {'intent': 'done', 'inform_slots': {}, 'request_slots': {}}
else:
raise Exception('Should not have reached this clause')
# self._map_action_to_index(rule_response) takes an action and gets its index from all possible agent actions
index = self._map_action_to_index(rule_response)
return index, rule_response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment