【问题标题】:How to change LUIS application for a chatbot in the .BOT file?如何在 .BOT 文件中更改聊天机器人的 LUIS 应用程序?
【发布时间】:2019-08-19 02:15:33
【问题描述】:

我正在使用 botbuilder SDK V4 为 Node.js 和 Microsoft Azure 服务开发一个机器人……

.bot 文件中,我们找到了加密的 LUIS 应用信息。

{
  "type": "luis",
  "name": "luis",
  "appId": <appId>,
  "authoringKey": <authoringKey>,
  "subscriptionKey": <subscriptionKey>,
  "version": "0.1",
  "region": <region>,
  "id": <id>
}

我的问题是如何在 .bot 文件中更改我的机器人使用的 LUIS 应用程序?

在 LUIS 端点中,有一个名为 staging 的参数,它将指定我是在 staging 模式还是生产模式下使用 LUIS 应用。

那么,如何在 .bot 文件中指定暂存或生产模式?

【问题讨论】:

    标签: node.js azure botframework azure-language-understanding


    【解决方案1】:

    TL;DR

    您不能仅通过编辑机器人的配置来使用暂存槽。

    但是您可以通过识别器的选项使用 staging,因此请使用另一个参数来激活 Staging 使用。


    详细信息 - 在 LUIS 中使用暂存与生产

    从技术上讲,对 LUIS 应用程序的 StagingProduction 插槽的调用之间的区别可以在调用的 URL 中看到,其中有一个 staging=true字段:

    • 暂存:https://_AzureRegion_.api.cognitive.microsoft.com/luis/v2.0/apps/_AppId_?staging=true&amp;verbose=true&amp;timezoneOffset=60&amp;subscription-key=_YourKey_&amp;q=_YourQuery_

    • 产品:https://_AzureRegion_.api.cognitive.microsoft.com/luis/v2.0/apps/_AppId_?verbose=true&amp;timezoneOffset=60&amp;subscription-key=_YourKey_&amp;q=_YourQuery_

    在 Bot Builder 中实现

    您可以在 BotBuilder 源代码中看到 staging 从未在配置中使用。但是,在名为LuisRecognizer 的类中,您可以传递options,其中有一个staging 布尔值,对于.Net,请参见here,对于js,请参见here

    所以在你的情况下,在 js 中:

    // Map the contents to the required format for `LuisRecognizer`.
    const luisApplication = {
        applicationId: process.env.appId,
        endpointKey: process.env.subscriptionKey,
        azureRegion: process.env.region
    }
    
    // Create configuration for LuisRecognizer's runtime behavior.
    const luisPredictionOptions = {
        includeAllIntents: true,
        log: true,
        staging: **POINT TO A CONFIG VARIABLE FOR EXAMPLE**
    }
    
    const luisRecognizer = new LuisRecognizer(luisApplication, luisPredictionOptions, true);
    

    【讨论】:

      猜你喜欢
      • 2018-07-04
      • 1970-01-01
      • 1970-01-01
      • 2020-07-30
      • 1970-01-01
      • 2019-01-02
      • 1970-01-01
      • 1970-01-01
      • 2018-06-23
      相关资源
      最近更新 更多