【问题标题】:How to make a CURL call to rasa nlu trainer如何对 rasa nlu 培训师进行 CURL 调用
【发布时间】:2017-07-05 05:17:35
【问题描述】:

我在 xxxx 端口上运行了 rasa nlu 训练器。每当我的应用程序(流星)向 rasa nlu 训练器发出呼叫时,我想为 nlu 训练器提供不同的来源。我想到了对 nlu 训练器的 curl 请求,但我们怎么能用 curl 命令给 rasa nlu 训练器喂 --source 标志?

或者我是否有另一种选择来为 rasa nlu 训练器提供来自我的流星应用程序的动态源路径? 请指导我。

【问题讨论】:

    标签: curl meteor rasa-nlu


    【解决方案1】:

    As mentioned in their official documentation,可以做cURL 使用 /train 端点对 RASA NLU 的请求。它是一个 HTTP POST 请求,因此请确保将语料库作为请求正文发送。

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

    或者,您可以这样做:

    制作一个用于训练 RASA 的批处理文件,例如 TrainRASA.bat,其中包含以下 python 命令:

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

    如下制作 config_spacy.json 文件:

    {
        "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
      }
    

    现在制作一个 C# Web API 来训练您的 RASA 模型,如下所示:

    [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;
                }
    }
    

    现在只需从 Chrome 发送一个 HTTP GET,将批处理文件目录作为参数传递。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-06
    • 2021-11-28
    • 2017-08-18
    • 2021-02-18
    • 1970-01-01
    • 2018-09-22
    相关资源
    最近更新 更多