Я работал с расой, и есть вещи из formAction
, которые я до сих пор не очень хорошо понимаю, мой вопрос сегодня - почему? Мой formAction
активирован, но он не хранит никаких slotvalue
, если я его неправильно использую?
Вот мой код:
class HotelForm(FormAction):
def name(self):
# type: () -> Text
return "formaejemplo"
@staticmethod
def required_slots(tracker):
return ["tipo_habitacion"]
def slot_mappings(self):
return {'tipo_habitacion':[self.from_entity(entity='tipo_habitacion',intent=['gethabitacion','peticion_habitacion'])]}
@staticmethod
def habitaciones_db():
return ["individual","doble","suite","suite doble"]
def submit(self, dispatcher, tracker, domain):
dispatcher.utter_template('utter_listo', tracker)
return []
def validate(self,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any]) -> List[Dict]:
slot_values = self.extract_other_slots(dispatcher, tracker, domain)
print('slot values:',slot_values)
slot_to_fill = tracker.get_slot(REQUESTED_SLOT)
if slot_to_fill:
print('slot values:',slot_values)
slot_values.update(self.extract_requested_slot(dispatcher,tracker, domain))
if not slot_values:
try:
return super().validate(dispatcher, tracker, domain)
except ActionExecutionRejection as e:
# could not extract entity
dispatcher.utter_message(
"Sorry, I could not parse the value correctly. \n"
"Please double check your entry otherwise I will ask you this forever"
)
return []
for slot, value in slot_values.items():
print('Slot: ',slot)
print('valor: ',values)
if slot == 'tipo_habitacion':
if value.lower() not in self.habitaciones_db():
dispatcher.utter_template('utter_wrong_tipo_habitacion', tracker)
# validation failed, set slot to None
slot_values[slot] = None
# validation succeed, set the slots values to the extracted values
return [SlotSet(slot, value) for slot, value in slot_values.items()]
когда я печатаю значения (slotvalues
) на консоли, оно всегда пусто.