[英]How to give out user input error messages in rasa?
如果用戶輸入與任何意圖不匹配,如何發出錯誤消息。 示例:我正在制作一家餐廳尋找 rasa 機器人,所以我正在考慮讓 rasa 機器人詢問用戶在哪里尋找餐廳的位置,所以如果用戶輸入的位置沒有餐廳如何返回“對不起此位置沒有餐廳”消息。
您應該能夠使用規則和插槽創建此行為。 例如:
- rule: nothing found
condition:
- slot_was_set:
- restaurant_found: false
steps:
- action: utter_no_restaurants_found
您需要為restaurant_found
創建一個 boolean 插槽,並在自定義操作中將其設置為 false 或 true。
slots:
restaurant_found:
type: bool
自定義操作看起來像這樣(您需要添加“成功”條件,以及您的代碼為搜索餐廳所做的任何事情。)
class RestaurantSearchAction(Action):
def name(self) -> Text:
return "restaurant_search"
async def run(
self, dispatcher, tracker: Tracker, domain: Dict[Text, Any],
) -> List[Dict[Text, Any]]:
# search for restaurant with your
# custom code here. You can get entities
# from the tracker like so: tracker.get_latest_entity_values
if <successful>:
return [SlotSet(restaurant_found, True)]
else:
return [SlotSet(restaurant_found, False)]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.