我正在尝试使用Rasa的FormAction。以下是我的详细信息:
MyForm
class MyForm(FormAction):
"""My form action"""
def name(self):
return "my_form"
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
"""A list of required slots that the form has to fill"""
return ["slot_a", "slot_b", "slot_c", "slot_d"]
def slot_mappings(self):
# type: () -> Dict[Text: Union[Dict, List[Dict]]]
"""A dictionary to map required slots to
- an extracted entity
- intent: value pairs
- a whole message
or a list of them, where a first match will be picked"""
return {"slot_a":[self.from_entity(entity="slot_a", intent=["inform"])],
"slot_b": [self.from_entity(entity="slot_b", intent=["inform"])],
"slot_c": [self.from_entity(entity="slot_c", intent=["inform"])],
"slot_d": [self.from_entity(entity="slot_d", intent=["inform"])]}
def submit(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict]:
"""Define what the form has to do
after all required slots are filled"""
dispatcher.utter_template('utter_submit', tracker)
return []
下面是我的domain.yml
文件,其中仅出于NDA原因显示了插槽和表单值。
MyDomain
# actions, entities, intents, templates
slots:
slot_c:
type: unfeaturized
auto_fill: false
slot_b:
type: unfeaturized
auto_fill: false
slot_d:
type: unfeaturized
auto_fill: false
slot_a:
type: unfeaturized
auto_fill: false
slot_e:
type: text
auto_fill: false
slot_f:
type: categorical
values:
- val_1
- val_2
- val_3
forms:
- my_form
下面是我的stories.yml
:
## Story 1
* greet
- utter_greet
* create_slot_vals
- my_form
- form{"name": "my_form"}
- form{"name": null}
- utter_saving_slots_values
* thank_you
- utter_thanks
填写表格后,我有一个话语动作,显示了所有由表格填写的广告位值。
Rasa Utter操作
The form details are:
- Slot A: Software
- Slot B: Anderson
- Slot C: 12
- Slot D: ['permanent', 'permanent']
问题是,即使用户只输入一次slot_d
的值作为“永久”,也将再次请求相同的插槽,并且相同的值会在列表中自动填充两次并保存。
有人在Rasa中遇到过这样的问题吗?
答案 0 :(得分:0)
如果在配置文件中使用多个实体提取器,则导致此错误,因此运行rasa shell nlu
以了解哪种类型的实体提取器正在获取值