LuisRecognizer 构造函数已弃用。请使用 LuisRecognizerOptions

LuisRecognizer Constructor is deprecated. Please use LuisRecognizerOptions

我正在使用 Microsoft 机器人生成器 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 ... is obsolete: ... please use LuisRecognizer(LuisRecognizerOptions recognizer)"。

我按照这个 Microsoft 教程进行了设置。即使按照教程进行操作,也会在行中给出相同的 "obsolete" 错误:

Dispatch = new LuisRecognizer(luisApplication);

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

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

谢谢:)

该教程似乎已过时。请参阅示例以获取最新代码。 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"