web-dev-qa-db-ja.com

カスタムフォームでスロットを埋めるときの問題(スロットの抽出に失敗しました)

一部の処理に必要なすべてのデータを収集するアクションフォームを実装していますが、次のエラーが発生しました。

_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
_

このカスタムフォームは、2つの必須スロット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
_
1

slot_mappingsを定義しないため、同じ名前のエンティティからスロットを設定する必要があると想定します。しかし、注釈付きのtypeエンティティがないため、抽出できず、スロットを設定できません。 slot_mappingsを定義するか、typeエンティティの例を追加します。

1
Melinda