rasa.core.domain
InvalidDomain Objects
Exception that can be raised when domain is not valid.
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.
from_directory
Loads and merges multiple domain files recursively from a directory tree.
merge
Merge this domain with another one, combining their attributes.
List attributes like intents
and actions
will be deduped
and merged. Single attributes will be taken from self
unless
override is True
, in which case they are taken from domain
.
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.entities
- All entities as provided by a domain file.
Returns:
The intent properties to be stored in 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.
add_categorical_slot_default_value
Add a default value to all categorical slots.
All unseen values found for the slot will be mapped to this default value for featurization.
add_requested_slot
Add a slot called requested_slot
to the list of slots.
The value of this slot will hold the name of the slot which the user needs to fill in next (either explicitly or implicitly) as part of a form.
add_knowledge_base_slots
Add slots for the knowledge base action to the list of slots, if the default knowledge base action name is present.
As soon as the knowledge base action is not experimental anymore, we should consider creating a new section in the domain file dedicated to knowledge base slots.
action_for_name
Look up which action corresponds to this action name.
action_for_index
Integer index corresponding to an actions index in the action list.
This method resolves the index to the actions name.
index_for_action
Look up which action index corresponds to this action name.
slot_states
Returns all available slot state strings.
input_state_map
Provide a mapping from state names to indices.
input_states
Returns all available states.
get_active_states
Return a bag of active states from the tracker state.
states_for_tracker_history
Array of states for each state of the trackers history.
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.
persist
Write domain to a file.
cleaned_domain
Fetch cleaned domain to display or write into a file.
The internal used_entities
property is replaced by use_entities
or
ignore_entities
and redundant keys are replaced with default values
to make the domain easier readable.
Returns:
A cleaned dictionary version of the domain.
persist_clean
Write cleaned domain to a file.
intent_config
Return the configuration for an intent.
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
of type UnfeaturizedSlot
from domain warnings.
check_missing_templates
Warn user of utterance names which have no specified template.
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
.
slot_mapping_for_form
Retrieve the slot mappings for a form which are defined in the domain.
Options:
- an extracted entity
- intent: value pairs
- trigger_intent: value pairs
- a whole message or a list of them, where the first match will be picked
Arguments:
form_name
- The name of the form.
Returns:
The slot mapping or an empty dictionary in case no mapping was found.