【问题标题】:Problem when filling slots with custom form (Failed to extract slot)使用自定义表单填充插槽时出现问题(无法提取插槽)
【发布时间】:2020-04-09 07:38:52
【问题描述】:

我正在实施一个操作表单来收集某些处理所需的所有数据,但我收到了这个错误:

2020-04-09 09:19:13 ERROR    rasa_sdk.endpoint  - Failed to extract slot type with action places_form
2020-04-09 09:19:13 ERROR    rasa.core.actions.action  - Failed to extract slot type with action places_form

此自定义表单必须收集两个必需的插槽:citytype。第一个是从意图的实体收集的。例如:Give me all places for [Rennes](city)。这很好用。

但之前的意图不包含type 提示和操作表单,我希望触发一个额外的问题。例如:Which type of places?

这是这个动作表单的代码:

class CustomFormAction(FormAction):
  def name(self):
    return ""

  def request_next_slot(
    self,
    dispatcher: CollectingDispatcher,
    tracker: Tracker,
    domain: Dict[Text, Any],
  ) -> Optional[List[EventType]]:
    """Request the next slot and utter template if needed,
        else return None"""

    for slot in self.required_slots(tracker):
      if self._should_request_slot(tracker, slot):
        # logger.debug(f"Request next slot '{slot}'")
        dispatcher.utter_message(
          template=f"utter_ask_{self.name()}_{slot}", **tracker.slots
        )
        return [SlotSet(REQUESTED_SLOT, slot)]

    return None

class PlacesForm(CustomFormAction):
  def name(self) -> Text:
    return "places_form"

  @staticmethod
  def required_slots(tracker: Tracker) -> List[Text]:
    return ["city", "type"]

  def submit(
    self,
    dispatcher: CollectingDispatcher,
    tracker: Tracker,
    domain: Dict[Text, Any],
  ) -> List[Dict]:
    city = tracker.get_slot("city")
    print("city : {}".format(city))
    print("domain : {}".format(json.dumps(domain)))

    elements = requests.get("http://...").json()

    dispatcher.utter_message(template="utter_places")
    dispatcher.utter_message(json.dumps(elements))
    return []

这是我定义相关故事的方式:

## places
* places
  - places_form
  - form{"name": "places_form"}

还有places 意图:

## intent:places
- Give me places around [Rennes](city)
- What are the places around [Rennes](city)
- I'm looking for places around [Rennes](city)
- Give me all places for [Rennes](city)

我的 config.yml 文件中有 FormPolicy:

policies:
  - name: FallbackPolicy
    nlu_threshold: 0.75
  - name: AugmentedMemoizationPolicy
  - name: FormPolicy
  - name: MappingPolicy
  - name: TEDPolicy
    epochs: 20

以下是有关对话的日志:

Your input ->  Give me all places for Rennes
2020-04-09 09:19:07 DEBUG    rasa.core.tracker_store  - Creating a new tracker for id '8fcaa471f975433ca5e4c1af83b8ca38'.
2020-04-09 09:19:07 DEBUG    rasa.core.processor  - Starting a new session for conversation ID '8fcaa471f975433ca5e4c1af83b8ca38'.
2020-04-09 09:19:07 DEBUG    rasa.core.processor  - Action 'action_session_start' ended with events '[<rasa.core.events.SessionStarted object at 0x7fb3d9ab0e48>, <rasa.core.events.ActionExecuted object at 0x7fb3d9ab0e10>]'.
2020-04-09 09:19:07 DEBUG    rasa.core.processor  - Current slot values: 
    city: None
    requested_slot: None
    type: None
2020-04-09 09:19:08 DEBUG    rasa.nlu.classifiers.diet_classifier  - There is no trained model: component is either not trained or didn't receive enough training data.
2020-04-09 09:19:08 DEBUG    rasa.nlu.selectors.response_selector  - Adding following selector key to message property: default
2020-04-09 09:19:08 DEBUG    rasa.core.processor  - Received user message 'Give me all places for Rennes' with intent '{'name': 'places', 'confidence': 0.9888553619384766}' and entities '[{'entity': 'city', 'start': 31, 'end': 38, 'extractor': 'DIETClassifier', 'value': 'Rennes'}]'
2020-04-09 09:19:08 DEBUG    rasa.core.processor  - Current slot values: 
    city: Rennes
    requested_slot: None
    type: None
2020-04-09 09:19:08 DEBUG    rasa.core.processor  - Logged UserUtterance - tracker now has 5 events.
2020-04-09 09:19:08 DEBUG    rasa.core.policies.fallback  - NLU confidence threshold met, confidence of fallback action set to core threshold (0.3).
2020-04-09 09:19:08 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, None, None, {}, {'intent_places': 1.0, 'entity_city': 1.0, 'prev_action_listen': 1.0}]
2020-04-09 09:19:08 DEBUG    rasa.core.policies.memoization  - Launch DeLorean...
2020-04-09 09:19:08 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, None, None, {}, {'intent_places': 1.0, 'entity_city': 1.0, 'prev_action_listen': 1.0}]
2020-04-09 09:19:08 DEBUG    rasa.core.policies.memoization  - There is no memorised next action
2020-04-09 09:19:08 DEBUG    rasa.core.policies.form_policy  - There is no active form
2020-04-09 09:19:08 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_4_TEDPolicy
2020-04-09 09:19:08 DEBUG    rasa.core.processor  - Predicted next action 'places_form' with confidence 0.92.
2020-04-09 09:19:08 DEBUG    rasa.core.actions.action  - Calling action endpoint to run action 'places_form'.
2020-04-09 09:19:08 DEBUG    rasa.core.processor  - Action 'places_form' ended with events '[BotUttered('Quelle est la valeur du type?', {"elements": null, "quick_replies": null, "buttons": null, "attachment": null, "image": null, "custom": null}, {"city": "Rennes"}, 1586416748.2458563), <rasa.core.events.Form object at 0x7fb3d9a6bcc0>, <rasa.core.events.SlotSet object at 0x7fb3d9ab0da0>, <rasa.core.events.SlotSet object at 0x7fb429a027b8>, <rasa.core.events.SlotSet object at 0x7fb3d9dbb400>]'.
2020-04-09 09:19:08 DEBUG    rasa.core.processor  - Current slot values: 
    city: Rennes
    requested_slot: type
    type: None
2020-04-09 09:19:08 DEBUG    rasa.core.policies.fallback  - NLU confidence threshold met, confidence of fallback action set to core threshold (0.3).
2020-04-09 09:19:08 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, None, None, {}, {'intent_places': 1.0, 'entity_city': 1.0, 'prev_action_listen': 1.0}]
2020-04-09 09:19:08 DEBUG    rasa.core.policies.memoization  - Launch DeLorean...
2020-04-09 09:19:08 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, None, None, None, {}]
2020-04-09 09:19:08 DEBUG    rasa.core.policies.memoization  - There is a memorised next action 'action_listen'
2020-04-09 09:19:08 DEBUG    rasa.core.policies.form_policy  - There is an active form 'places_form'
2020-04-09 09:19:08 DEBUG    rasa.core.policies.mapping_policy  - There is no mapped action for the predicted intent, 'places'.
2020-04-09 09:19:08 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_2_FormPolicy
2020-04-09 09:19:08 DEBUG    rasa.core.processor  - Predicted next action 'action_listen' with confidence 1.00.
2020-04-09 09:19:08 DEBUG    rasa.core.processor  - Action 'action_listen' ended with events '[]'.
2020-04-09 09:19:08 DEBUG    rasa.core.lock_store  - Deleted lock for conversation '8fcaa471f975433ca5e4c1af83b8ca38'.
Quelle est la valeur du type?
Your input ->  tt                                                                                                                                                            
2020-04-09 09:19:13 DEBUG    rasa.core.tracker_store  - Recreating tracker for id '8fcaa471f975433ca5e4c1af83b8ca38'
2020-04-09 09:19:13 DEBUG    rasa.nlu.classifiers.diet_classifier  - There is no trained model: component is either not trained or didn't receive enough training data.
2020-04-09 09:19:13 DEBUG    rasa.nlu.selectors.response_selector  - Adding following selector key to message property: default
2020-04-09 09:19:13 DEBUG    rasa.core.processor  - Received user message 'tt' with intent '{'name': 'deny', 'confidence': 0.5609110593795776}' and entities '[]'
2020-04-09 09:19:13 DEBUG    rasa.core.processor  - Logged UserUtterance - tracker now has 13 events.
2020-04-09 09:19:13 DEBUG    rasa.core.policies.fallback  - NLU confidence 0.5609110593795776 is lower than NLU threshold 0.75. 
2020-04-09 09:19:13 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, {}, {'intent_places': 1.0, 'entity_city': 1.0, 'prev_action_listen': 1.0}, {'intent_places': 1.0, 'entity_city': 1.0, 'active_form_places_form': 1.0, 'prev_places_form': 1.0}, {'intent_deny': 1.0, 'prev_action_listen': 1.0, 'active_form_places_form': 1.0}]
2020-04-09 09:19:13 DEBUG    rasa.core.policies.memoization  - Launch DeLorean...
2020-04-09 09:19:13 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, None, None, {}, {'intent_deny': 1.0, 'prev_action_listen': 1.0}]
2020-04-09 09:19:13 DEBUG    rasa.core.policies.memoization  - There is no memorised next action
2020-04-09 09:19:13 DEBUG    rasa.core.policies.form_policy  - There is an active form 'places_form'
2020-04-09 09:19:13 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_2_FormPolicy
2020-04-09 09:19:13 DEBUG    rasa.core.processor  - Predicted next action 'places_form' with confidence 1.00.
2020-04-09 09:19:13 DEBUG    rasa.core.actions.action  - Calling action endpoint to run action 'places_form'.
2020-04-09 09:19:13 ERROR    rasa_sdk.endpoint  - Failed to extract slot type with action places_form
2020-04-09 09:19:13 ERROR    rasa.core.actions.action  - Failed to extract slot type with action places_form
2020-04-09 09:19:13 DEBUG    rasa.core.policies.fallback  - NLU confidence 0.5609110593795776 is lower than NLU threshold 0.75. 
2020-04-09 09:19:13 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, {}, {'intent_places': 1.0, 'entity_city': 1.0, 'prev_action_listen': 1.0}, {'intent_places': 1.0, 'entity_city': 1.0, 'active_form_places_form': 1.0, 'prev_places_form': 1.0}, {'intent_deny': 1.0, 'prev_action_listen': 1.0, 'active_form_places_form': 1.0}]
2020-04-09 09:19:13 DEBUG    rasa.core.policies.memoization  - Launch DeLorean...
2020-04-09 09:19:13 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, None, None, {}, {'intent_deny': 1.0, 'prev_action_listen': 1.0}]
2020-04-09 09:19:13 DEBUG    rasa.core.policies.memoization  - There is no memorised next action
2020-04-09 09:19:13 DEBUG    rasa.core.policies.form_policy  - There is an active form 'places_form'
2020-04-09 09:19:13 DEBUG    rasa.core.policies.ensemble  - Execution of 'places_form' was rejected. Setting its confidence to 0.0 in all predictions.
2020-04-09 09:19:13 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_0_FallbackPolicy
2020-04-09 09:19:13 DEBUG    rasa.core.processor  - Predicted next action 'action_default_fallback' with confidence 1.00.
2020-04-09 09:19:13 DEBUG    rasa.core.processor  - Action 'action_default_fallback' ended with events '[<rasa.core.events.UserUtteranceReverted object at 0x7fb3d99625c0>]'.
2020-04-09 09:19:13 DEBUG    rasa.core.processor  - Current slot values: 
    city: Rennes
    requested_slot: type
    type: None
2020-04-09 09:19:13 DEBUG    rasa.core.policies.fallback  - NLU confidence threshold met, confidence of fallback action set to core threshold (0.3).
2020-04-09 09:19:13 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, None, None, {}, {'intent_places': 1.0, 'entity_city': 1.0, 'prev_action_listen': 1.0}]
2020-04-09 09:19:13 DEBUG    rasa.core.policies.memoization  - Launch DeLorean...
2020-04-09 09:19:13 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, None, None, None, {}]
2020-04-09 09:19:13 DEBUG    rasa.core.policies.memoization  - There is a memorised next action 'action_listen'
2020-04-09 09:19:13 DEBUG    rasa.core.policies.form_policy  - There is an active form 'places_form'
2020-04-09 09:19:13 DEBUG    rasa.core.policies.mapping_policy  - There is no mapped action for the predicted intent, 'places'.
2020-04-09 09:19:13 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_2_FormPolicy
2020-04-09 09:19:13 DEBUG    rasa.core.processor  - Predicted next action 'action_listen' with confidence 1.00.
2020-04-09 09:19:13 DEBUG    rasa.core.processor  - Action 'action_listen' ended with events '[]'.
2020-04-09 09:19:13 DEBUG    rasa.core.lock_store  - Deleted lock for conversation '8fcaa471f975433ca5e4c1af83b8ca38'.```

Thanks very much for your help!
Thierry

【问题讨论】:

    标签: rasa-nlu rasa


    【解决方案1】:

    您没有定义slot_mappings,因此它将假定它应该从同名实体设置插槽。但是您似乎没有任何带注释的type 实体,因此无法提取它,也无法设置插槽。定义slot_mappings 或添加type 实体的示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多