What’s the proper way to handle this? I would expect if I designate the slot as a text slot, it won’t sometimes be a list. This causes an exception in my action handler.
Hey @ivanmkc, I guess the slot becomes a list when there are multiple entities of the same type in one utterance. I think the discussion here will help you, and I’m curious to hear any followup questions
@ivanmkc I totally agree that it is unfortunate. How would you improve it, though? I’ve spent some time thinking about this and still can’t see a good solution that would work for most people:
picking up all entity instances is, I think, desirable, or else we have to decide which one to pick up (e.g. always the first one)
making the slot of type list even if it contains just one item is robust but it means unnecessarily complicating the many cases where you just want to condition on a single, simple value…
In any case, I’m open to other opinions and suggestions – this is an open-source project with contributions always welcome
This basically means that the slots are actually all of type list, even when explicitly set to a non-list type.
So to the developer, we always have to check if the slot value is a list in our action code, since there is no guarantee that it won’t be. Hence, you shouldn’t even have a non-list type as it’s not meaningful.
If you want to have a non-list type, it should always be a non-list, using some sensible default, like highest predicted probability (or similar measure). If that doesn’t make sense, then don’t have a non-list type.
You’re right that there’s no guarantee that the slot won’t be of type slot at some point. Which indeed makes the design flawed. Though let’s keep in mind that in 99% of all cases there’ll be none or just one instance of a particular entity in an utterance… In any case, because this issue requires changes to core user-facing parts of Rasa (in this case how slots behave), we can’t make the changes at any point, but we’re looking into it as part of the next major release, along with some other related improvements to slots – stay tuned!