Skip to content

Commit

Permalink
Merge pull request #3707 from RasaHQ/interactive-learning-bug
Browse files Browse the repository at this point in the history
Fix list index out of range error
  • Loading branch information
tabergma committed Jun 7, 2019
2 parents 8ca44a5 + 91ae756 commit e7c8420
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions rasa/core/training/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,22 +899,25 @@ async def _predict_till_next_listen(
endpoint, sender_id, EventVerbosity.AFTER_RESTART
)
events = tracker_dump.get("events", [])
last_event = events[-2] # last event before action_listen
# if bot message includes buttons the user will get a list choice to reply
# the list choice is displayed in place of action listen
if last_event.get("event") == BotUttered.type_name and last_event["data"].get(
"buttons", None
):
data = last_event["data"]
message = last_event.get("text", "")
choices = [
button_to_string(button, idx)
for idx, button in enumerate(data.get("buttons"))
]

question = questionary.select(message, choices)
button_payload = cliutils.payload_from_button_question(question)
await send_message(endpoint, sender_id, button_payload)
if len(events) >= 2:
last_event = events[-2] # last event before action_listen

# if bot message includes buttons the user will get a list choice to reply
# the list choice is displayed in place of action listen
if last_event.get("event") == BotUttered.type_name and last_event["data"].get(
"buttons", None
):
data = last_event["data"]
message = last_event.get("text", "")
choices = [
button_to_string(button, idx)
for idx, button in enumerate(data.get("buttons"))
]

question = questionary.select(message, choices)
button_payload = cliutils.payload_from_button_question(question)
await send_message(endpoint, sender_id, button_payload)


async def _correct_wrong_nlu(
Expand Down

0 comments on commit e7c8420

Please sign in to comment.