Using Rasa version 3.6.4.Custom python code is not extracting the slot value

43 Views Asked by At

i am using custom slot in my domain file.I have written custom code to check for that slot name and predict action based on that.

Custom code is below:

import logging
from rasa.shared.core.slots import Slot
import os
logger = logging.getLogger(name)

class custom_entity(Slot):
    logger.info('inside custom class')
    
    def type_name(self):
        return "custom_entity"
    
    def feature_dimensionality(self):
        return 2
    
    def _as_feature(self):
        r = [0.0] * self.feature_dimensionality()
        try:
            if self.value is not None:
                if "not found" in self.value:
                    r[1] = 1.0
                else:
                     r[0] = 1.0
                logger.info("slot set")
        except Exception as e:
            logger.exception("Caught an exception in user_option. {}".format(e))
        finally:
            print("done")
        return r

During training, I encounter an issue where the custom_entity value appears as None. This problem persists even when I send a trigger_intent request for both the intent and the custom entity, as I continue to receive a None value for the slot in that file. I'm perplexed as to why I'm not obtaining the slot value in my custom code.

Please note that I observe "self" as custom_entity: None and "self.value" as None when reviewing the logs. My Rasa version is 3.6.4.

0

There are 0 best solutions below