Create a custom slot that stores custom Python object

Hi, how could I store a custom Python object in a custom slot?

I though it would be possible following the example here: https://rasa.com/docs/rasa/domain#custom-slot-types

When I try to train the model, Rasa raises a Type error:

TypeError: Can't instantiate abstract class MySlot with abstract methods _as_feature, type_name

Any idea why this could happen? Is it even possible what I want to do?

After using ChatGPT I found out that one method is missing in the documentation and one has a typo (it seems). I think the example in the docu has to be like this (added missing method + added missing “_”):

from rasa.shared.core.slots import Slot

class NumberOfPeopleSlot(Slot):

    def type_name(self):
        return "NumberOfPeopleSlot"

    def feature_dimensionality(self):
        return 2

    def _as_feature(self):
        r = [0.0] * self.feature_dimensionality()
        if self.value:
            if self.value <= 6:
                r[0] = 1.0
            else:
                r[1] = 1.0
        return r