rasa.cli.utils

Documentation for Rasa Open Source Project

You are viewing documentation for our open source project which is maintained by the community. If you want to get started building assistants with Rasa please check out our latest documentation here.

get_validated_path

def get_validated_path(
    current: Optional[Union["Path", Text]],
    parameter: Text,
    default: Optional[Union["Path", Text]] = None,
    none_is_valid: bool = False
) -> Optional[Union["Path", Text]]:

Checks whether a file path or its default value is valid and returns it.

Arguments:

Returns: The current value if it was valid, else the default value of the argument if it is valid, else None.

missing_config_keys

def missing_config_keys(path: Union["Path", Text],
    mandatory_keys: List[Text]) -> List[Text]:

Checks whether the config file at path contains the mandatory_keys.

Arguments:

Returns: The list of missing config keys.

validate_assistant_id_in_config

def validate_assistant_id_in_config(config_file: Union["Path", Text]) -> None:

Verifies that the assistant_id key exists and has a unique value in config.

Issues a warning if the key does not exist or has the default value and replaces it with a pseudo-random string value.

validate_config_path

def validate_config_path(config: Optional[Union[Text, "Path"]],
    default_config: Text = DEFAULT_CONFIG_PATH) -> Text:

Verifies that the config path exists.

Exit if the config file does not exist.

Arguments:

Returns: The path to the config file.

validate_mandatory_config_keys

def validate_mandatory_config_keys(config: Union[Text, "Path"],
    mandatory_keys: List[Text]) -> Text:

Get a config from a config file and check if it is valid.

Exit if the config isn't valid.

Arguments:

Returns: The path to the config file if the config is valid.

get_validated_config

def get_validated_config(config: Optional[Union[Text, "Path"]],
    mandatory_keys: List[Text],
    default_config: Text = DEFAULT_CONFIG_PATH) -> Text:

Validates config and returns path to validated config file.

validate_files

def validate_files(fail_on_warnings: bool,
    max_history: Optional[int],
    importer: TrainingDataImporter,
    stories_only: bool = False) -> None:

Validates either the story structure or the entire project.

Arguments:

cancel_cause_not_found

def cancel_cause_not_found(current: Optional[Union["Path", Text]],
    parameter: Text,
    default: Optional[Union["Path", Text]]) -> None:

Exits with an error because the given path was not valid.

Arguments:

parse_last_positional_argument_as_model_path

def parse_last_positional_argument_as_model_path() -> None:

Fixes the parsing of a potential positional model path argument.

button_to_string

def button_to_string(button: Dict[Text, Any], idx: int = 0) -> Text:

Create a string representation of a button.

element_to_string

def element_to_string(element: Dict[Text, Any], idx: int = 0) -> Text:

Create a string representation of an element.

button_choices_from_message_data

def button_choices_from_message_data(
    message: Dict[Text, Any],
    allow_free_text_input: bool = True) -> List[Text]:

Return list of choices to present to the user.

If allow_free_text_input is True, an additional option is added at the end along with the response buttons that allows the user to type in free text.

payload_from_button_question

async def payload_from_button_question(button_question: "Question") -> Text:

Prompt user with a button question and returns the nlu payload.

signal_handler

def signal_handler(_: int, __: FrameType) -> None:

Kills Rasa when OS signal is received.