Version: 3.x

rasa.shared.core.slots

InvalidSlotTypeException Objects

class InvalidSlotTypeException(RasaException)

Raised if a slot type is invalid.

InvalidSlotConfigError Objects

class InvalidSlotConfigError(RasaException, ValueError)

Raised if a slot's config is invalid.

Slot Objects

class Slot(ABC)

Key-value store for storing information during a conversation.

type_name

@property
@abstractmethod
def type_name() -> Text

Name of the type of slot.

__init__

def __init__(name: Text,
mappings: List[Dict[Text, Any]],
initial_value: Any = None,
value_reset_delay: Optional[int] = None,
influence_conversation: bool = True) -> None

Create a Slot.

Arguments:

  • name - The name of the slot.
  • initial_value - The initial value of the slot.
  • mappings - List containing slot mappings.
  • value_reset_delay - After how many turns the slot should be reset to the initial_value. This is behavior is currently not implemented.
  • influence_conversation - If True the slot will be featurized and hence influence the predictions of the dialogue polices.

feature_dimensionality

def feature_dimensionality() -> int

How many features this single slot creates.

Returns:

The number of features. 0 if the slot is unfeaturized. The dimensionality of the array returned by as_feature needs to correspond to this value.

has_features

def has_features() -> bool

Indicate if the slot creates any features.

value_reset_delay

def value_reset_delay() -> Optional[int]

After how many turns the slot should be reset to the initial_value.

If the delay is set to None, the slot will keep its value forever.

reset

def reset() -> None

Resets the slot's value to the initial value.

value

@property
def value() -> Any

Gets the slot's value.

value

@value.setter
def value(value: Any) -> None

Sets the slot's value.

has_been_set

@property
def has_been_set() -> bool

Indicates if the slot's value has been set.

resolve_by_type

@staticmethod
def resolve_by_type(type_name: Text) -> Type["Slot"]

Returns a slots class by its type name.

persistence_info

def persistence_info() -> Dict[str, Any]

Returns relevant information to persist this slot.

fingerprint

def fingerprint() -> Text

Returns a unique hash for the slot which is stable across python runs.

Returns:

fingerprint of the slot

FloatSlot Objects

class FloatSlot(Slot)

A slot storing a float value.

__init__

def __init__(name: Text,
mappings: List[Dict[Text, Any]],
initial_value: Optional[float] = None,
value_reset_delay: Optional[int] = None,
max_value: float = 1.0,
min_value: float = 0.0,
influence_conversation: bool = True) -> None

Creates a FloatSlot.

Raises:

InvalidSlotConfigError, if the min-max range is invalid. UserWarning, if initial_value is outside the min-max range.

persistence_info

def persistence_info() -> Dict[Text, Any]

Returns relevant information to persist this slot.

BooleanSlot Objects

class BooleanSlot(Slot)

A slot storing a truth value.

bool_from_any

def bool_from_any(x: Any) -> bool

Converts bool/float/int/str to bool or raises error.

ListSlot Objects

class ListSlot(Slot)

value

@Slot.value.setter
def value(value: Any) -> None

Sets the slot's value.

CategoricalSlot Objects

class CategoricalSlot(Slot)

Slot type which can be used to branch conversations based on its value.

__init__

def __init__(name: Text,
mappings: List[Dict[Text, Any]],
values: Optional[List[Any]] = None,
initial_value: Any = None,
value_reset_delay: Optional[int] = None,
influence_conversation: bool = True) -> None

Creates a Categorical Slot (see parent class for detailed docstring).

add_default_value

def add_default_value() -> None

Adds the special default value to the list of possible values.

persistence_info

def persistence_info() -> Dict[Text, Any]

Returns serialized slot.

AnySlot Objects

class AnySlot(Slot)

Slot which can be used to store any value.

Users need to create a subclass of Slot in case the information is supposed to get featurized.

__init__

def __init__(name: Text,
mappings: List[Dict[Text, Any]],
initial_value: Any = None,
value_reset_delay: Optional[int] = None,
influence_conversation: bool = False) -> None

Creates an Any Slot (see parent class for detailed docstring).

Raises:

InvalidSlotConfigError, if slot is featurized.

__eq__

def __eq__(other: Any) -> bool

Compares object with other object.