[英]PyQt4: Signal slot mechanism doesn't work correctly for 'List of buttons'
[英]Slot validation in formaction doesn't work
大家好,我有一個問題。 自從我開始使用rasa-nlu
和rasa-core
已有一段時間以來,我的問題是為什么對我的陣型的驗證不能正確進行? 我正在打印slotvalues
,它總是返回空。 我想知道如何解決這個問題,它只要求第一個插槽,然后就吹了!
這是我的代碼:
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:
slot_values.update(self.extract_requested_slot(dispatcher,tracker, domain))
if not slot_values:
raise ActionExecutionRejection(self.name(),"Failed to validate slot {0} with action {1}".format(slot_to_fill,self.name()))
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
if slot == 'mes':
if value.lower() not in self.meses_db():
dispatcher.utter_template('utter_wrong_mes', tracker)
# validation failed, set slot to None
slot_values[slot] = None
elif slot == 'num_adultos':
if not self.is_int(value) or int(value) <= 0:
dispatcher.utter_template('utter_wrong_num_adultos',tracker)
# validation failed, set slot to None
slot_values[slot] = None
elif slot == 'num_niños':
if not self.is_int(value) or int(value) <= 0:
dispatcher.utter_template('utter_wrong_num_niños',tracker)
# validation failed, set slot to None
slot_values[slot] = None
elif slot == 'dia':
if not self.is_int(value) or int(value) <= 0:
dispatcher.utter_template('utter_wrong_dia',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()]
我可以看到的一個問題是
if not slot_values:
raise ActionExecutionRejection(self.name(),"Failed to validate slot {0} with action {1}".format(slot_to_fill,self.name()))
if slot_to_fill:
應該從內部if slot_to_fill:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.