【问题标题】:“No such host is known.” error when publishing bot with LUIS AI to Azure but working fine locally“不知道这样的主人。”将带有 LUIS AI 的机器人发布到 Azure 但在本地正常工作时出错
【发布时间】:2021-04-22 08:38:59
【问题描述】:

我在 Azure 中托管了一个机器人,当通过机器人模拟器使用 ngrok 进行调试时,我收到一条错误消息:不知道这样的主机。我之前有过这样的机器人体验,这意味着 LUIS AI 配置,特别是 LuisAPIHostName 值,在 appsettings.json 中没有以正确的格式写入。

事实证明,当时甚至没有托管应用程序,问题是我从托管的 LUIS 服务中获得了一个端点,https://.api.cognitive .microsoft.com/,但我只需要使用 作为 LuisAPIHostName 的值,并且应用程序开始工作,因为完整的 Endpoint 是在 Luis Recognizer 中编写的(代码来自 Microsoft 文档,下面提供的链接)带有字符串插值。

回到当前问题,我试图通过绕过我的应用程序中的 LUIS 逻辑来隔离问题,并再次发布它,机器人开始在 Azure 网络聊天中正常工作。 所以,我猜问题可能出在 LUIS 配置上。但是,如果它与以前的解决方案一起在本地工作,LUIS 服务与机器人托管在同一个订阅中,要让它在 Azure 上工作需要什么?我为 LuisAPIHostName 尝试了一些组合,包括 Azure 提供的整个字符串,并在末尾添加了一个额外的“/”,但这并没有改变任何事情......

机器人是用:

v4.13.0 Bot Builder 库

.NET Core 3.1 框架

在 Azure 中作为 Web App Bot 托管,并带有相应的 AppService

更新:

添加如何在我的应用中配置 LUIS

BotServices 中的识别器可以在Microsoft LUIS docs找到

public BotServices(IConfiguration configuration)
    {
        // Read the setting for cognitive services (LUIS, QnA) from the appsettings.json
        // If includeApiResults is set to true, the full response from the LUIS api (LuisResult)
        // will be made available in the properties collection of the RecognizerResult

        var luisApplication = new LuisApplication(
            configuration["LuisAppId"],
            configuration["LuisAPIKey"],
           $"https://{configuration["LuisAPIHostName"]}.api.cognitive.microsoft.com");

        // Set the recognizer options depending on which endpoint version you want to use.
        // More details can be found in https://docs.microsoft.com/en-gb/azure/cognitive-services/luis/luis-migration-api-v3
        var recognizerOptions = new LuisRecognizerOptionsV2(luisApplication)
        {
            IncludeAPIResults = true,
            PredictionOptions = new LuisPredictionOptions()
            {
                IncludeAllIntents = true,
                IncludeInstanceData = true
            }
        };

        SampleQnA = new QnAMaker(new QnAMakerEndpoint
        {
            KnowledgeBaseId = configuration["QnAKnowledgebaseId"],
            EndpointKey = configuration["QnAEndpointKey"],
            Host = configuration["QnAEndpointHostName"]
        });

        Dispatch = new LuisRecognizer(recognizerOptions);
    }

    public LuisRecognizer Dispatch { get; private set; }
    public QnAMaker SampleQnA { get; private set; }
}

如何从机器人调用服务,可以在Microsoft docs找到

//First, we use the dispatch model to determine which cognitive service(LUIS or QnA) to use.
var recognizerResult = await _botServices.Dispatch.RecognizeAsync(turnContext, cancellationToken);

// Top intent tell us which cognitive service to use.
var (intent, _) = recognizerResult.GetTopScoringIntent();

// Next, we call the dispatcher with the top intent.
await DispatchToTopIntentAsync(turnContext, intent, recognizerResult, cancellationToken, botUser);

【问题讨论】:

  • 能否提供用于设置 LUIS 连接器和/或调用 LUIS API 的代码(已删除密钥/应用程序详细信息)?此外,您能否确认您正在使用哪些密钥和应用程序名称,因为 LUIS 同时具有预测和创作端点?
  • @billoverton 提供代码
  • Emulator 您正在获得 LUIS App 输出,然后尝试在 prod 或 slot 环境中重新发布该应用并检查输出。还要验证您的 qna 制造商呼叫。
  • 抱歉@Rajeesh 我看不懂你的文字,你能改写一下吗?

标签: c# azure botframework luis.ai


【解决方案1】:

LUIS 应用程序似乎未公开。

在 LUIS 门户中检查此内容:

更新:在 Azure 门户中添加了 LUIS 配置页面

要获取 api 密钥和主机名,您必须检查 Azure 中 LUIS PUBLISHING 资源上的 Keys and Endpoint 部分(您不应使用 AUTHORING 资源, b/c 它的请求数有限,您可能会耗尽它)。

【讨论】:

  • 嘿@Miguel,我试过了,虽然这可能会让我更近一步,但错误仍然存​​在。您还有其他建议吗?
  • 嗯,主机名看起来很奇怪,看看我更新的答案,我添加了您从中获取密钥和端点的 azure 门户页面。
  • 在提供的代码中,您可以看到 Endpoint/LuisAPIHostName 只需要 appsettings 中的区域,因为完整的 Endpoint 是在我的 LUIS 识别器中通过字符串插值创建的。至于钥匙,我的“LuisAPIKey”就是你指出的那些钥匙之一。
  • 嗯,引起我注意的是,您收到的主机是*.api.cognitive.microsoft.com,而我最近(今年)看到的是*.cognitiveservices.azure.com。您是否检查过 Azure 资源页面中的端点是否与识别器中构建的端点相同?
  • 我找到了问题 Miguel,几个小时前发布了,谢谢
【解决方案2】:

在 Azure 托管的 bot App Service(不是 Web App bot)中,左侧有一个配置选项卡,默认情况下,单击它会选择右侧的应用程序设置选项卡(参见 img)

我在创建 LUIS AI 服务时创建了这些密钥和端点。 事实证明,Azure 中的应用程序设置将 appsettings.json 或 web.config(你有什么)覆盖为 stated here。因此,如果您的 appsettings 文件中的值是正确的,但与 Azure 中的应用程序设置不同,则应用会选择 Azure 中的值。

因为在识别器中我有字符串插值,所以我只是从 LUIS 端点写入了区域,而在 Azure 中我有 .api.cognitive.microsoft.com。最后,端点看起来像 https://.api.cognitive.microsoft.com.api.cognitive.microsoft.com/

这就是它在本地工作的原因,但在 Azure 中托管时却不行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-27
    • 1970-01-01
    • 1970-01-01
    • 2021-11-17
    相关资源
    最近更新 更多