rasa.shared.core.domain
InvalidDomain Objects
Exception that can be raised when domain is not valid.
ActionNotFoundException Objects
Raised when an action name could not be found.
SessionConfig Objects
The Session Configuration.
default
Returns the SessionConfig with the default values.
are_sessions_enabled
Returns a boolean value depending on the value of session_expiration_time.
as_dict
Return serialized SessionConfig
.
EntityProperties Objects
Class for keeping track of the properties of entities in the domain.
Domain Objects
The domain specifies the universe in which the bot's policy acts.
A Domain subclass provides the actions the bot can take, the intents and entities it can recognise.
empty
Returns empty Domain.
load
Returns loaded Domain after merging all domain files.
from_path
Loads the Domain
from a path.
from_file
Loads the Domain
from a YAML file.
from_yaml
Loads the Domain
from YAML text after validating it.
from_dict
Deserializes and creates domain.
Arguments:
data
- The serialized domain.
Returns:
The instantiated Domain
object.
from_directory
Loads and merges multiple domain files recursively from a directory tree.
merge
Merges this domain dict with another one, combining their attributes.
This method merges domain dicts, and ensures all attributes (like intents
,
entities
, and actions
) are known to the Domain when the
object is created.
List attributes like intents
and actions
are deduped
and merged. Single attributes are taken from 0 unless
override is
1, in which case they are taken from ``2.
merge_domain_dicts
Combines two domain dictionaries.
collect_slots
Collects a list of slots from a dictionary.
retrieval_intents
List retrieval intents present in the domain.
collect_entity_properties
Get entity properties for a domain from what is provided by a domain file.
Arguments:
domain_entities
- The entities as provided by a domain file.
Returns:
An instance of EntityProperties.
collect_intent_properties
Get intent properties for a domain from what is provided by a domain file.
Arguments:
intents
- The intents as provided by a domain file.entity_properties
- Entity properties as provided by the domain file.
Returns:
The intent properties to be stored in the domain.
__init__
Create a Domain
.
Arguments:
intents
- Intent labels.entities
- The names of entities which might be present in user messages.slots
- Slots to store information during the conversation.responses
- Bot responses. If an action with the same name is executed, it will send the matching response to the user.action_names
- Names of custom actions.forms
- Form names and their slot mappings.data
- original domain dict representation.action_texts
- End-to-End bot utterances from end-to-end stories.store_entities_as_slots
- Ifintents
0 Rasa will automatically createintents
1 events for entities if there are slots with the same name as the entity.intents
2 - Configuration for conversation sessions. Conversations are restarted at the end of a session.
__deepcopy__
Enables making a deep copy of the Domain
using copy.deepcopy
.
See https://docs.python.org/3/library/copy.html#copy.deepcopy for more implementation.
Arguments:
memo
- Optional dictionary of objects already copied during the current copying pass.
Returns:
A deep copy of the current domain.
count_conditional_response_variations
Returns count of conditional response variations.
__hash__
Returns a unique hash for the domain.
fingerprint
Returns a unique hash for the domain which is stable across python runs.
Returns:
fingerprint of the domain
user_actions_and_forms
Returns combination of user actions and forms.
num_actions
Returns the number of available actions.
num_states
Number of used input states for the action prediction.
retrieval_intent_responses
Return only the responses which are defined for retrieval intents.
is_retrieval_intent_response
Check if the response is for a retrieval intent.
These responses have a /
symbol in their name. Use that to filter them from
the rest.
index_for_action
Looks up which action index corresponds to this action name.
raise_action_not_found_exception
Raises exception if action name or text not part of the domain or stories.
Arguments:
action_name_or_text
- Name of an action or its text in case it's an end-to-end bot utterance.
Raises:
ActionNotFoundException
- Ifaction_name_or_text
are not part of this domain.
slot_states
Returns all available slot state strings.
entity_states
Returns all available entity state strings.
concatenate_entity_labels
Concatenates the given entity labels with their corresponding sub-labels.
If a specific entity label is given, only this entity label will be concatenated with its corresponding sub-labels.
Arguments:
entity_labels
- A map of an entity label to its sub-label list.entity
- If present, only this entity will be considered.
Returns:
A list of labels.
input_state_map
Provide a mapping from state names to indices.
input_states
Returns all available states.
get_active_state
Given a dialogue tracker, makes a representation of current dialogue state.
Arguments:
tracker
- dialog state tracker containing the dialog so faromit_unset_slots
- IfTrue
do not include the initial values of slots.
Returns:
A representation of the dialogue's current state.
states_for_tracker_history
List of states for each state of the trackers history.
Arguments:
tracker
- Dialogue state tracker containing the dialogue so far.omit_unset_slots
- IfTrue
do not include the initial values of slots.ignore_rule_only_turns
- If True ignore dialogue turns that are present only in rules.rule_only_data
- Slots and loops, which only occur in rules but not in stories.
Returns:
A list of states.
slots_for_entities
Creates slot events for entities if from_entity mapping matches.
Arguments:
entities
- The list of entities.
Returns:
A list of SlotSet
events.
persist_specification
Persist the domain specification to storage.
load_specification
Load a domains specification from a dumped model directory.
compare_with_specification
Compare the domain spec of the current and the loaded domain.
Throws exception if the loaded domain specification is different to the current domain are different.
as_dict
Return serialized Domain
.
get_responses_with_multilines
Returns responses
with preserved multilines in the text
key.
Arguments:
responses
- Originalresponses
.
Returns:
responses
with preserved multilines in the text
key.
persist
Write domain to a file.
as_yaml
Dump the Domain
object as a YAML string.
This function preserves the orders of the keys in the domain.
Returns:
A string in YAML format representing the domain.
intent_config
Return the configuration for an intent.
intents
Returns sorted list of intents.
entities
Returns sorted list of entities.
domain_warnings
Generate domain warnings from intents, entities, actions and slots.
Returns a dictionary with entries for intent_warnings
,
entity_warnings
, action_warnings
and slot_warnings
. Excludes domain slots
from domain warnings in case they are not featurized.
utterances_for_response
Returns utterance set which should have a response.
Will filter out utterances which are subintent (retrieval intent) types. eg. if actions have ['utter_chitchat', 'utter_chitchat/greet'], this will only return ['utter_chitchat/greet'] as only that will need a response.
check_missing_responses
Warn user of utterance names which have no specified response.
is_empty
Check whether the domain is empty.
is_domain_file
Checks whether the given file path is a Rasa domain file.
Arguments:
filename
- Path of the file which should be checked.
Returns:
True
if it's a domain file, otherwise False
.
Raises:
YamlException
- if the file seems to be a YAML file (extension) but can not be read / parsed.
required_slots_for_form
Retrieve the list of required slot names for a form defined in the domain.
Arguments:
form_name
- The name of the form.
Returns:
The list of slot names or an empty list if no form was found.
count_slot_mapping_statistics
Counts the total number of slot mappings and custom slot mappings.
Returns:
A triple of integers where the first entry is the total number of mappings, the second entry is the total number of custom mappings, and the third entry is the total number of mappings which have conditions attached.
does_custom_action_explicitly_need_domain
Assert if action has explicitly stated that it needs domain.
Arguments:
action_name
- Name of the action to be checked
Returns:
True if action has explicitly stated that it needs domain. Otherwise, it returns false.
__repr__
Returns text representation of object.
warn_about_duplicates_found_during_domain_merging
Emits warning about found duplicates while loading multiple domain paths.