如何更改 .BOT 文件中聊天机器人的 LUIS 应用程序?

How to change LUIS application for a chatbot in the .BOT file?

我正在使用 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 的参数,它将指定我是在暂存模式还是生产模式下使用 LUIS 应用程序。

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

TL;DR

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

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


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

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

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

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

在 Bot Builder 中实现

您可以在 BotBuilder 源代码中看到 staging 从未在配置中使用。但是,在名为 LuisRecognizer 的 class 中,您可以在有 staging 布尔值的地方传递 options,参见 here for .Net, here for js.

所以在你的情况下在 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);