Проблема при заполнении слотов пользовательской формой (Не удалось извлечь слот) - PullRequest
0 голосов
/ 09 апреля 2020

Я реализую форму действия для сбора всех необходимых данных для некоторой обработки, но я получил эту ошибку:

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

Эта пользовательская форма должна собирать два обязательных слота: city и type , Первый собран из объекта намерения. Например: 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)

У меня есть FormPolicy в моем config.yml файле:

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 Ответ

0 голосов
/ 14 апреля 2020

Вы не определяете slot_mappings, поэтому предполагается, что он должен установить слот из объекта с таким же именем. Но, похоже, у вас нет аннотированных type сущностей, поэтому он не может извлечь их и не может установить слот. Либо определите slot_mappings, либо добавьте примеры сущности type.

...