JustinaPetr / Weatherbot_Tutorial

275 stars 446 forks source link

Faced issue with rasa_core/slots.py #77

Open gaurkuber opened 5 years ago

gaurkuber commented 5 years ago

print(rasa_core.version) 0.13.5 print(rasa_core.file) /home/ec2-user/anaconda3/envs/cpy0/lib/python3.6/site-packages/rasa_core/init.py

While executing dialogue_management_model.py, I kept getting the following error

ValueError: Failed to find slot type. Neither a known type nor. If you are creating your own slot type, make sure its module path is correct: rasa_core.slots.TextSlot

The concerned file in my isntallation was - /home/ec2-user/anaconda3/envs/cpy0/lib/python3.6/site-packages/rasa_core/slots.py I replaced the file contents with the version present on git - https://github.com/RasaHQ/rasa_core/blob/master/rasa/core/slots.py After that I had to modify the "resolve_by_type" function in slots.py to below to make it work. Please consider if the file needs to be modified in the distribution.

Around line 67.

def resolve_by_type(type_name):
    """Returns a slots class by its type name."""
    ##########################################
    for cls in utils.all_subclasses(Slot):
        if 'slots' in type_name:
            if str(cls)[8:-2] == type_name:
                return cls
        else:
            if cls.type_name == type_name:
                return cls
    ##########################################
    try:
        return utils.class_from_module_path(type_name)
    except(ImportError, AttributeError):
        raise ValueError(
            "Failed to find slot type, '{}' is neither a known type nor "
            "user-defined. If you are creating your own slot type, make "
            "sure its module path is correct.".format(type_name))
gaurkuber commented 5 years ago

The stack trace -

Traceback (most recent call last): File "dialogue_management_model.py", line 41, in run_weather_bot() File "dialogue_management_model.py", line 34, in run_weather_bot agent = Agent.load('./models/dialogue', interpreter=interpreter, action_endpoint=action_endpoint) File "/home/ec2-user/anaconda3/envs/cpy1/lib/python3.6/site-packages/rasa_core/agent.py", line 261, in load domain = Domain.load(os.path.join(path, "domain.yml")) File "/home/ec2-user/anaconda3/envs/cpy1/lib/python3.6/site-packages/rasa_core/domain.py", line 88, in load return cls.from_yaml(read_file(filename)) File "/home/ec2-user/anaconda3/envs/cpy1/lib/python3.6/site-packages/rasa_core/domain.py", line 94, in from_yaml return cls.from_dict(data) File "/home/ec2-user/anaconda3/envs/cpy1/lib/python3.6/site-packages/rasa_core/domain.py", line 99, in from_dict slots = cls.collect_slots(data.get("slots", {})) File "/home/ec2-user/anaconda3/envs/cpy1/lib/python3.6/site-packages/rasa_core/domain.py", line 187, in collect_slots slot_class = Slot.resolve_by_type(slot_dict[slot_name].get("type")) File "/home/ec2-user/anaconda3/envs/cpy1/lib/python3.6/site-packages/rasa_core/slots.py", line 76, in resolve_by_type "module path is correct: {}.".format(type_name)) ValueError: Failed to find slot type. Neither a known type nor. If you are creating your own slot type, make sure its module path is correct: rasa_core.slots.TextSlot.