0

我正在使用 Microsoft bot builder SDKv4 创建聊天机器人,使用 LUIS.ai 来获得最高意图。我使用以下代码在我的 .net core 2.1 项目中配置 luis。

public BotServices(IConfiguration configuration)
    {
        // Read the setting for cognitive services from the appsettings.json
        Dispatch = new LuisRecognizer(new LuisApplication(
            configuration["LuisAppId"],
            configuration["LuisAPIKey"],
            $"https://{configuration["LuisAPIHostName"]}.api.cognitive.microsoft.com"),
            new LuisPredictionOptions { IncludeAllIntents = true, IncludeInstanceData = true },
            true);
    }

但我收到此警告:“LuisRecognizer,LuisRecognizer ...已过时:...请使用 LuisRecognizer(LuisRecognizerOptions 识别器)”。

我按照这个 Microsoft 教程进行了设置。即使遵循本教程也会在以下行给出相同的“过时”错误:

Dispatch = new LuisRecognizer(luisApplication);

https://docs.microsoft.com/en-us/azure/cognitive-services/luis/luis-csharp-tutorial-bf-v4

在这种情况下如何配置 luis?

谢谢 :)

4

1 回答 1

3

该教程似乎已过时。请参阅示例以获取最新的代码。 https://github.com/microsoft/BotBuilder-Samples/blob/master/samples/csharp_dotnetcore/13.core-bot/FlightBookingRecognizer.cs#L27

var luisApplication = new LuisApplication(
    configuration["LuisAppId"],
    configuration["LuisAPIKey"],
    "https://" + configuration["LuisAPIHostName"]);

var recognizerOptions = new LuisRecognizerOptionsV3(luisApplication)
{
    PredictionOptions = new Bot.Builder.AI.LuisV3.LuisPredictionOptions
    {
        IncludeInstanceData = true,
    }
};

Dispatch = new LuisRecognizer(recognizerOptions);

使用应用程序设置:

"LuisAPIHostName": "westus.api.cognitive.microsoft.com"
于 2020-06-02T21:15:48.107 回答