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.