rasa/core/server.py
async def train_stack(request: Request):
        """Train a Rasa Stack model."""

        from rasa.train import train_async

        rjs = request.json

        # create a temporary directory to store config, domain and
        # training data
        temp_dir = tempfile.mkdtemp()

        try:
            config_path = os.path.join(temp_dir, 'config.yml')
            dump_obj_as_str_to_file(config_path, rjs["config"])

            domain_path = os.path.join(temp_dir, 'domain.yml')
            dump_obj_as_str_to_file(domain_path, rjs["domain"])

            nlu_path = os.path.join(temp_dir, 'nlu.md')
            dump_obj_as_str_to_file(nlu_path, rjs["nlu"])

            stories_path = os.path.join(temp_dir, 'stories.md')
            dump_obj_as_str_to_file(stories_path, rjs["stories"])
        except KeyError:
            raise ErrorResponse(400,
                                "TrainingError",
                                "The Rasa Stack training request is "
                                "missing a key. The required keys are "
                                "`config`, `domain`, `nlu` and `stories`.")

        # the model will be saved to the same temporary dir
        # unless `out` was specified in the request
        try:
            model_path = await train_async(
                domain=domain_path,
                config=config_path,
                training_files=[nlu_path, stories_path],
                output=rjs.get("out", temp_dir),
                force_training=rjs.get("force", False))

            return await response.file(model_path)
        except Exception as e:
            raise ErrorResponse(400, "TrainingError",
                                "Rasa Stack model could not be trained. "
                                "Error: {}".format(e))
Train a Rasa Stack model.
Train a Rasa Stack model.
Train a Rasa Stack model .
async def train_stack(request: Request):
        from rasa.train import train_async
        rjs = request.json
        temp_dir = tempfile.mkdtemp()
        try:
            config_path = os.path.join(temp_dir, 'config.yml')
            dump_obj_as_str_to_file(config_path, rjs["config"])
            domain_path = os.path.join(temp_dir, 'domain.yml')
            dump_obj_as_str_to_file(domain_path, rjs["domain"])
            nlu_path = os.path.join(temp_dir, 'nlu.md')
            dump_obj_as_str_to_file(nlu_path, rjs["nlu"])
            stories_path = os.path.join(temp_dir, 'stories.md')
            dump_obj_as_str_to_file(stories_path, rjs["stories"])
        except KeyError:
            raise ErrorResponse(400,
                                "TrainingError",
                                "The Rasa Stack training request is "
                                "missing a key. The required keys are "
                                "`config`, `domain`, `nlu` and `stories`.")
        try:
            model_path = await train_async(
                domain=domain_path,
                config=config_path,
                training_files=[nlu_path, stories_path],
                output=rjs.get("out", temp_dir),
                force_training=rjs.get("force", False))
            return await response.file(model_path)
        except Exception as e:
            raise ErrorResponse(400, "TrainingError",
                                "Rasa Stack model could not be trained. "
                                "Error: {}".format(e))
async def train_stack ( request : Request ) : from rasa . train import train_async rjs = request . json temp_dir = tempfile . mkdtemp ( ) try : config_path = os . path . join ( temp_dir , 'config.yml' ) dump_obj_as_str_to_file ( config_path , rjs [ "config" ] ) domain_path = os . path . join ( temp_dir , 'domain.yml' ) dump_obj_as_str_to_file ( domain_path , rjs [ "domain" ] ) nlu_path = os . path . join ( temp_dir , 'nlu.md' ) dump_obj_as_str_to_file ( nlu_path , rjs [ "nlu" ] ) stories_path = os . path . join ( temp_dir , 'stories.md' ) dump_obj_as_str_to_file ( stories_path , rjs [ "stories" ] ) except KeyError : raise ErrorResponse ( 400 , "TrainingError" , "The Rasa Stack training request is " "missing a key. The required keys are " "`config`, `domain`, `nlu` and `stories`." ) try : model_path = await train_async ( domain = domain_path , config = config_path , training_files = [ nlu_path , stories_path ] , output = rjs . get ( "out" , temp_dir ) , force_training = rjs . get ( "force" , False ) ) return await response . file ( model_path ) except Exception as e : raise ErrorResponse ( 400 , "TrainingError" , "Rasa Stack model could not be trained. " "Error: {}" . format ( e ) )
Train a Rasa Stack model.
Train a Rasa Stack model .
"""Train a Rasa Stack model.""" # create a temporary directory to store config, domain and # training data # the model will be saved to the same temporary dir # unless `out` was specified in the request
request
Request