def set_convert_arguments(parser: argparse.ArgumentParser, data_type: Text) -> None: parser.add_argument( "-f", "--format", default="yaml", choices=["json", "md", "yaml"], help="Output format the training data should be converted into. " "Note: currently training data can be converted to 'yaml' format " "only from 'md' format", ) add_data_param(parser, required=True, data_type=data_type) add_out_param( parser, default=DEFAULT_CONVERTED_DATA_PATH, help_text="File (for `json` and `md`) or existing path (for `yaml`) " "where to save training data in Rasa format.", ) parser.add_argument("-l", "--language", default="en", help="Language of data.")
def set_train_nlu_arguments(parser: argparse.ArgumentParser): add_config_param(parser) add_out_param(parser, help_text="Directory where your models should be stored.") add_nlu_data_param(parser, help_text="File or folder containing your NLU data.") add_model_name_param(parser)
def set_train_nlu_arguments(parser: argparse.ArgumentParser): add_config_param(parser) add_out_param(parser) add_nlu_data_param(parser) add_model_name_param(parser) add_compress_param(parser)
def add_test_nlu_argument_group( parser: Union[argparse.ArgumentParser, argparse._ActionsContainer]) -> None: add_nlu_data_param(parser, help_text="File or folder containing your NLU data.") add_out_param( parser, default=DEFAULT_RESULTS_PATH, help_text="Output path for any files created during the evaluation.", ) parser.add_argument( "-c", "--config", nargs="+", default=None, help="Model configuration file. If a single file is passed and cross " "validation mode is chosen, cross-validation is performed, if " "multiple configs or a folder of configs are passed, models " "will be trained and compared directly.", ) cross_validation_arguments = parser.add_argument_group("Cross Validation") cross_validation_arguments.add_argument( "--cross-validation", action="store_true", default=False, help= "Switch on cross validation mode. Any provided model will be ignored.", ) cross_validation_arguments.add_argument( "-f", "--folds", required=False, default=5, help="Number of cross validation folds (cross validation only).", ) comparison_arguments = parser.add_argument_group("Comparison Mode") comparison_arguments.add_argument( "-r", "--runs", required=False, default=3, type=int, help="Number of comparison runs to make.", ) comparison_arguments.add_argument( "-p", "--percentages", required=False, nargs="+", type=int, default=[0, 25, 50, 75], help="Percentages of training data to exclude during comparison.", ) add_no_plot_param(parser) add_errors_success_params(parser)
def set_migrate_arguments(parser: argparse.ArgumentParser) -> None: """Sets migrate command arguments.""" add_domain_param(parser) add_out_param( parser, default=DEFAULT_DOMAIN_PATH, help_text="Path (for `yaml`) where to save migrated domain in Rasa 3.0 format.", )
def set_train_arguments(parser: argparse.ArgumentParser): add_data_param(parser) add_config_param(parser) add_domain_param(parser) add_out_param(parser, help_text="Directory where your models should be stored.") add_augmentation_param(parser) add_debug_plots_param(parser) add_dump_stories_param(parser) add_model_name_param(parser) add_force_param(parser)
def set_migrate_arguments(parser: argparse.ArgumentParser) -> None: """Sets migrate command arguments.""" add_domain_param(parser) add_out_param( parser, default=None, help_text= "Path (for `yaml`) where to save migrated domain in Rasa 3.0 format." "If none is specified, either a `new_domain.yml` file or `new_domain` folder " "will be created in the folder that contains the given domain.", )
def set_train_arguments(parser: argparse.ArgumentParser): add_data_param(parser) add_config_param(parser) add_domain_param(parser) add_out_param(parser) add_augmentation_param(parser) add_debug_plots_param(parser) add_dump_stories_param(parser) add_model_name_param(parser) add_force_param(parser) add_compress_param(parser)
def add_test_core_argument_group( parser: Union[argparse.ArgumentParser, argparse._ActionsContainer], include_e2e_argument: bool = False, ) -> None: add_stories_param(parser, "test") parser.add_argument( "--max-stories", type=int, help="Maximum number of stories to test on." ) add_out_param( parser, default=DEFAULT_RESULTS_PATH, help_text="Output path for any files created during the evaluation.", ) if include_e2e_argument: parser.add_argument( "--e2e", "--end-to-end", action="store_true", help="Run an end-to-end evaluation for combined action and " "intent prediction. Requires a story file in end-to-end " "format.", ) add_endpoint_param( parser, help_text="Configuration file for the connectors as a yml file." ) parser.add_argument( "--fail-on-prediction-errors", action="store_true", help="If a prediction error is encountered, an exception " "is thrown. This can be used to validate stories during " "tests, e.g. on travis.", ) parser.add_argument( "--url", type=str, help="If supplied, downloads a story file from a URL and " "trains on it. Fetches the data by sending a GET request " "to the supplied URL.", ) parser.add_argument( "--evaluate-model-directory", default=False, action="store_true", help="Should be set to evaluate models trained via " "'rasa train core --config <config-1> <config-2>'. " "All models in the provided directory are evaluated " "and compared against each other.", ) add_no_plot_param(parser) add_errors_success_params(parser)
def set_split_arguments(parser: argparse.ArgumentParser): add_nlu_data_param(parser, help_text="File or folder containing your NLU data.") parser.add_argument( "--training-fraction", type=float, default=0.8, help="Percentage of the data which should be in the training data.", ) add_out_param( parser, default="train_test_split", help_text="Directory where the split files should be stored.", )
def set_train_nlu_arguments(parser: argparse.ArgumentParser) -> None: """Specifies CLI arguments for `rasa train nlu`.""" add_config_param(parser) add_domain_param(parser, default=None) add_out_param(parser, help_text="Directory where your models should be stored.") add_nlu_data_param(parser, help_text="File or folder containing your NLU data.") _add_num_threads_param(parser) _add_model_name_param(parser) add_persist_nlu_data_param(parser) add_finetune_params(parser)
def set_train_core_arguments(parser: argparse.ArgumentParser): add_stories_param(parser) add_domain_param(parser) add_core_config_param(parser) add_out_param(parser, help_text="Directory where your models should be stored.") add_augmentation_param(parser) add_debug_plots_param(parser) add_dump_stories_param(parser) add_force_param(parser) add_model_name_param(parser) compare_arguments = parser.add_argument_group("Comparison Arguments") add_compare_params(compare_arguments)
def set_test_arguments(parser: argparse.ArgumentParser) -> None: add_model_param(parser, add_positional_arg=False) core_arguments = parser.add_argument_group("Core Test Arguments") add_test_core_argument_group(core_arguments) nlu_arguments = parser.add_argument_group("NLU Test Arguments") add_test_nlu_argument_group(nlu_arguments) add_no_plot_param(parser) add_errors_success_params(parser) add_out_param( parser, default=DEFAULT_RESULTS_PATH, help_text="Output path for any files created during the evaluation.", )
def set_train_core_arguments(parser: argparse.ArgumentParser): add_stories_param(parser) add_domain_param(parser) add_core_config_param(parser) add_out_param(parser) add_augmentation_param(parser) add_debug_plots_param(parser) add_dump_stories_param(parser) add_force_param(parser) add_model_name_param(parser) add_compress_param(parser) compare_arguments = parser.add_argument_group("Comparison Arguments") add_compare_params(compare_arguments)
def set_train_core_arguments(parser: argparse.ArgumentParser) -> None: """Specifies CLI arguments for `rasa train core`.""" add_stories_param(parser) add_domain_param(parser) _add_core_config_param(parser) add_out_param(parser, help_text="Directory where your models should be stored.") add_augmentation_param(parser) add_debug_plots_param(parser) add_force_param(parser) _add_model_name_param(parser) compare_arguments = parser.add_argument_group("Comparison Arguments") _add_compare_params(compare_arguments) add_finetune_params(parser)
def set_train_arguments(parser: argparse.ArgumentParser) -> None: """Specifies CLI arguments for `rasa train`.""" add_data_param(parser) add_config_param(parser) add_domain_param(parser) add_out_param(parser, help_text="Directory where your models should be stored.") add_dry_run_param(parser) add_augmentation_param(parser) add_debug_plots_param(parser) _add_num_threads_param(parser) _add_model_name_param(parser) add_persist_nlu_data_param(parser) add_force_param(parser) add_finetune_params(parser)
def set_convert_arguments(parser: argparse.ArgumentParser): add_data_param(parser, required=True, default=None, data_type="Rasa NLU ") add_out_param( parser, required=True, default=None, help_text="File where to save training data in Rasa format.", ) parser.add_argument("-l", "--language", default="en", help="Language of data.") parser.add_argument( "-f", "--format", required=True, choices=["json", "md"], help="Output format the training data should be converted into.", )
def add_test_core_argument_group( parser: Union[argparse.ArgumentParser, argparse._ActionsContainer] ): add_stories_param(parser, "test") parser.add_argument( "--max-stories", type=int, help="Maximum number of stories to test on." ) add_out_param( parser, default="results", help_text="Output path for any files created during the evaluation.", ) parser.add_argument( "--e2e", "--end-to-end", action="store_true", help="Run an end-to-end evaluation for combined action and " "intent prediction. Requires a story file in end-to-end " "format.", ) add_endpoint_param( parser, help_text="Configuration file for the connectors as a yml file." ) parser.add_argument( "--fail-on-prediction-errors", action="store_true", help="If a prediction error is encountered, an exception " "is thrown. This can be used to validate stories during " "tests, e.g. on travis.", ) parser.add_argument( "--NLUHttpInterpreter", action="store_true", help="This flag is for enabling Rasa NLU Http interpreter", ) parser.add_argument( "--url", type=str, help="If supplied, downloads a story file from a URL and " "trains on it. Fetches the data by sending a GET request " "to the supplied URL.", )
def set_visualize_stories_arguments(parser: argparse.ArgumentParser): add_domain_param(parser) add_stories_param(parser) add_config_param(parser) add_out_param( parser, default="graph.html", help_text="Filename of the output path, e.g. 'graph.html'.", ) parser.add_argument( "--max-history", default=2, type=int, help="Max history to consider when merging paths in the output graph.", ) add_nlu_data_param( parser, default=None, help_text="File or folder containing your NLU data, " "used to insert example messages into the graph.", )
def set_convert_arguments(parser: argparse.ArgumentParser, data_type: Text): add_data_param(parser, required=True, default=None, data_type=data_type) add_out_param( parser, required=True, default=None, help_text="File where to save training data in Rasa format.", ) parser.add_argument("-l", "--language", default="en", help="Language of data.") parser.add_argument( "-f", "--format", required=True, choices=["json", "md", "yaml"], help="Output format the training data should be converted into. " "Note: currently training data can be converted to 'yaml' format " "only from 'md' format", )
def add_test_nlu_argument_group(parser: Union[argparse.ArgumentParser, argparse._ActionsContainer]): add_nlu_data_param(parser, help_text="File or folder containing your NLU data.") add_out_param( parser, default=DEFAULT_RESULTS_PATH, help_text="Output path for any files created during the evaluation.", ) parser.add_argument( "--report", required=False, nargs="?", const="reports", default=None, help="Output path to save the intent/entity metrics report.", ) parser.add_argument( "--successes", required=False, nargs="?", const="successes.json", default=None, help="Output path to save successful predictions.", ) parser.add_argument( "--errors", required=False, default="errors.json", help="Output path to save model errors.", ) parser.add_argument( "--histogram", required=False, default="hist.png", help="Output path for the confidence histogram.", ) parser.add_argument( "--confmat", required=False, default="confmat.png", help="Output path for the confusion matrix plot.", ) parser.add_argument( "-c", "--config", nargs="+", default=None, help="Model configuration file. If a single file is passed and cross " "validation mode is chosen, cross-validation is performed, if " "multiple configs or a folder of configs are passed, models " "will be trained and compared directly.", ) cross_validation_arguments = parser.add_argument_group("Cross Validation") cross_validation_arguments.add_argument( "--cross-validation", action="store_true", default=False, help= "Switch on cross validation mode. Any provided model will be ignored.", ) cross_validation_arguments.add_argument( "-f", "--folds", required=False, default=10, help="Number of cross validation folds (cross validation only).", ) comparison_arguments = parser.add_argument_group("Comparison Mode") comparison_arguments.add_argument( "-r", "--runs", required=False, default=3, type=int, help="Number of comparison runs to make.", ) comparison_arguments.add_argument( "-p", "--percentages", required=False, nargs="+", type=int, default=[0, 25, 50, 75], help="Percentages of training data to exclude during comparison.", )
def _add_data_convert_parsers(data_subparsers, parents: List[argparse.ArgumentParser]) -> None: convert_parser = data_subparsers.add_parser( "convert", formatter_class=argparse.ArgumentDefaultsHelpFormatter, parents=parents, help="Converts Rasa data between different formats.", ) convert_parser.set_defaults(func=lambda _: convert_parser.print_help(None)) convert_subparsers = convert_parser.add_subparsers() convert_nlu_parser = convert_subparsers.add_parser( "nlu", formatter_class=argparse.ArgumentDefaultsHelpFormatter, parents=parents, help="Converts NLU data between formats.", ) convert_nlu_parser.set_defaults(func=_convert_nlu_data) arguments.set_convert_arguments(convert_nlu_parser, data_type="Rasa NLU") convert_nlg_parser = convert_subparsers.add_parser( "nlg", formatter_class=argparse.ArgumentDefaultsHelpFormatter, parents=parents, help= ("Converts NLG data between formats. If you're migrating from 1.x, " "please run `rasa data convert responses` to adapt the training data " "to the new response selector format."), ) convert_nlg_parser.set_defaults(func=_convert_nlg_data) arguments.set_convert_arguments(convert_nlg_parser, data_type="Rasa NLG") convert_core_parser = convert_subparsers.add_parser( "core", formatter_class=argparse.ArgumentDefaultsHelpFormatter, parents=parents, help="Converts Core data between formats.", ) convert_core_parser.set_defaults(func=_convert_core_data) arguments.set_convert_arguments(convert_core_parser, data_type="Rasa Core") migrate_config_parser = convert_subparsers.add_parser( "config", formatter_class=argparse.ArgumentDefaultsHelpFormatter, parents=parents, help="Migrate model configuration between Rasa Open Source versions.", ) migrate_config_parser.set_defaults(func=_migrate_model_config) default_arguments.add_config_param(migrate_config_parser) default_arguments.add_domain_param(migrate_config_parser) default_arguments.add_out_param( migrate_config_parser, default=os.path.join(DEFAULT_DATA_PATH, "rules.yml"), help_text= "Path to the file which should contain any rules which are created " "as part of the migration. If the file doesn't exist, it will be created.", ) convert_responses_parser = convert_subparsers.add_parser( "responses", formatter_class=argparse.ArgumentDefaultsHelpFormatter, parents=parents, help= ("Convert retrieval intent responses between Rasa Open Source versions. " "Please also run `rasa data convert nlg` to convert training data files " "to the right format."), ) convert_responses_parser.set_defaults(func=_migrate_responses) arguments.set_convert_arguments(convert_responses_parser, data_type="Rasa stories") default_arguments.add_domain_param(convert_responses_parser)