背景描述
今天在用 rasa 模型构造任务型机器人的过程中,项目原来为:输入餐厅、用餐人数后推荐餐厅的对话型机器人。期望将项目修改为:输入时间、餐厅、用餐人数后推荐餐厅的对话机器人。
错误描述
Your form ‘restaurant_form’ uses an invalid slot mapping of type ‘form_entity’ for slot ‘order_datetime’
解决方案
将 type: from_entity
误写成了 type:form_entity
。(流下了写习惯了前端 form 表单的泪水)
完整修改代码
domain.yml
version: "2.0"
#rasa train --domain path_to_domain_directory if multiple domain files
intents:
- say_hi
- thankyou
- goodbye
- affirm
- deny
- recognition
- nlu_fallback
- out_of_scope
- request_restaurant
slots:
order_datetime:
type: text
plant:
type: text
cuisine:
type: text
num_people:
type: float
entities:
- order_datetime
- plant
- cuisine
- num_people
responses:
utter_say_hi:
- text: "你好,很高兴认识你!"
- text: "hi, 我是小鹰,记得关注我哦。"
utter_no_thanks:
- text: "不用谢。"
- text: "you are welcomed."
utter_goodbye:
- text: "byebye."
- text: "再见"
utter_ask_restaurant_form_cuisine:
- text: "请问要订什么类型的餐厅?"
utter_ask_restaurant_form_num_people:
- text: "有几个人就餐?"
utter_ask_restaurant_form_order_datetime:
- text: "什么时间的?"
utter_restaurant_done:
- text: "好的,已帮您预订 {order_datetime} 的餐厅:{cuisine},人数:{num_people}"
forms:
restaurant_form:
required_slots:
order_datetime:
- type: from_entity
entity: order_datetime
cuisine:
- type: from_entity
entity: cuisine
num_people:
- type: from_entity
entity: num_people
actions:
- action_recognize
- utter_say_hi
- utter_no_thanks
- utter_goodbye
- action_chitchat
- action_resetSlot
session_config:
session_expiration_time: 60
carry_over_slots_to_new_session: true
nlu.yml
version: "2.0"
nlu:
- intent: say_hi
examples: |
- 你好
- 小鹰小鹰
- 早上好
- hi
- hello
- intent: thankyou
examples: |
- 谢谢
- 感谢
- 多谢
- thank you
- thanks
- intent: goodbye
examples: |
- 再见
- 就这样吧
- 再会
- bye
- intent: out_of_scope
examples: |
- 来聊聊吧
- 你长得好看不
- 吃饭了
- 起来嗨
- 下班了
- intent: request_restaurant
examples: |
- 给我订个餐厅
- 我想订个餐厅
- 你会订餐厅吗
- [中餐厅]{"entity":"cuisine"}
- [西餐厅]{"entity":"cuisine"}
- [川菜馆]{"entity":"cuisine"}
- [火锅]{"entity":"cuisine"}
- [3]{"entity":"num_people"}个人
- [5]{"entity":"num_people"}人
- [9]{"entity":"num_people"}位
- [7]{"entity":"num_people"}人
- [明天]{"entity": "order_datetime"}
- [今天]{"entity": "order_datetime"}的