0

I had rasa nlu trainer running on xxxx port.I want to feed nlu trainer with a different source whenever a call made from my app(meteor) to rasa nlu trainer.I thought of curl request to nlu trainer but how can we fed --source flag of rasa nlu trainer with curl command?

or Do I have an another option to feed rasa nlu trainer with a dynamic source path from my meteor application? PLease direct me.

user3405478
  • 47
  • 1
  • 9

1 Answers1

0

As mentioned in their official documentation, you can make cURL Requests to RASA NLU using the /train endpoint. Its a HTTP POST request, so make sure sending the corpus as request body.

$ curl -XPOST localhost:5000/train?project=my_project -d @data/examples/rasa/demo-rasa.json

Alternatively, you can do:

Make a batch file having for training RASA like TrainRASA.bat which will have the following python command:

cd <Your Path>
python -m rasa_nlu.train -c config_spacy.json

Make the config_spacy.json file as follows:

{
    "project": "Travel",
    "pipeline": "spacy_sklearn",
    "language": "en",
    "num_threads": 1,
    "max_training_processes": 1,
    "path": "C:\\Users\\Kunal\\Desktop\\RASA\\models",
    "response_log": "C:\\Users\\Kunal\\Desktop\\RASA\\log",
    "config": "C:\\Users\\Kunal\\Desktop\\RASA\\config_spacy.json",
    "log_level": "INFO",
    "port": 5000,
    "data": "C:\\Users\\Kunal\\Desktop\\RASA\\data\\FlightBotFinal.json",
    "emulate": "luis",
    "spacy_model_name": "en",
    "token": null,
    "cors_origins": ["*"],
    "aws_endpoint_url": null
  }

Now make a C# Web API to train your RASA Model like follows:

[HttpGet]
[Route("api/TrainRASA")]
[EnableCors("*", "*", "*")]
public Task TrainRASA([FromUri] string BatchFilePath, [FromUri] string BatchFileDirectory)
{
            try
            {
             return Task.Run(() => 
              {
                ProcessStartInfo startInfo = new ProcessStartInfo()
                {
                    FileName = BatchFilePath,
                    CreateNoWindow = false,
                    UseShellExecute = true,
                    WindowStyle = ProcessWindowStyle.Normal,
                    WorkingDirectory = BatchFileDirectory
                };

                // Start the process with the info we specified.
                // Call WaitForExit and then the using-statement will close.
                using (System.Diagnostics.Process exeProcess = System.Diagnostics.Process.Start(startInfo))
                {
                    exeProcess.WaitForExit();
                }
           });
         }
            catch (Exception ex)
            {
                throw;
            }
}

Now just make a HTTP GET from Chrome passing the batch file directory as arguments.

Kunal Mukherjee
  • 5,775
  • 3
  • 25
  • 53
  • How about RASA Core Stack? https://github.com/RasaHQ/starter-pack-rasa-stack I would like to access my bot with curl command instead of using make cmdline. – webmastx Oct 12 '18 at 01:11