Невозможно отобразить намерение LUIS при использовании кода Bot Framework v4 - PullRequest
0 голосов
/ 12 февраля 2020

Я запускаю код botframework v4 и тестирую его с помощью эмулятора chatbot. В настоящее время я не могу достичь потока кода, в котором присутствует код намерения luis в [MainDialog.cs] [1].

Ниже приведена строка в файле MainDialog.cs:

 var luisResult = await _luisRecognizer.RecognizeAsync<FlightBooking>(stepContext.Context, cancellationToken);

Но когда я ввожу какое-то сообщение в ChatBot, каждый раз поток заканчивается на [FlightBookingRecognizer.cs] [2], и ниже находится строка, где я ожидаю, что Луис намерен быть найденным.

public virtual async Task<RecognizerResult> RecognizeAsync(ITurnContext turnContext, CancellationToken cancellationToken)
    => await _recognizer.RecognizeAsync(turnContext, cancellationToken);

public virtual async Task<T> RecognizeAsync<T>(ITurnContext turnContext, CancellationToken cancellationToken)
     where T : IRecognizerConvert, new()
    => await _recognizer.RecognizeAsync<T>(turnContext, cancellationToken);

turnContext содержит сообщение, которое мы вводим в чатботе. И я ожидаю, что результат LUIS в _recognizer.RecognizeAsyn c, но в этом нет соответствующих данных. Я пытаюсь сделать что-то вроде ниже: -



But, my code flow ends here and i get error in ChatBot emulator as attached in screenshot.[![enter image description here][3]][3]


Steps to reproduce:
1. Download or pull the project from github and then Open the CoreBot.csproj  in Visual studio from this link .
[CoreBot Project][4]

2. Then select CoreBot and build it (Don't forget to add luis app id,key and host in csharp_dotnetcore\13.core-bot\appsettings.json file).
In Luis you can import this file csharp_dotnetcore\13.core-bot\CognitiveModels\FlightBooking.json and then train and publish it.
In Luis.ai go to My apps, and click Import App. Choose the file JSON file for the app you want to import and click Import.

3. Also put debug breakpoints in MainDialog.cs class (line 67 jus before switch statement) and FlightBookingRecognizer.cs class (last 2 lines ) .

4.Run the project in IIS browser mode and not in console mode ,it will open in browser you will see this link  http://localhost:3978/ 

5. In chatbot Emulator open this link http://localhost:3979/api/messages

6. You will see cards in chatbot as per attached screenshot.

7. Enter a message which is given in chatbot example i.e "Flight to paris"

8. You will see debug point ends at FlightRecognizer.cs class last line and turnContext has your message but _recognizer.RecognizeAsync doesn't carry any information about the Luis intent .

9.Also,it is not clear that LUIS intent is matched from local file or luis.ai 


More info can be found here [Microsoft documentation about this v4 code][5]
Please Help.


  [1]: https://github.com/microsoft/BotBuilder-Samples/blob/master/samples/csharp_dotnetcore/13.core-bot/Dialogs/MainDialog.cs
  [2]: https://github.com/microsoft/BotBuilder-Samples/blob/master/samples/csharp_dotnetcore/13.core-bot/FlightBookingRecognizer.cs
  [3]: https://i.stack.imgur.com/05Rbg.png
  [4]: https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/csharp_dotnetcore/13.core-bot
  [5]: https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-howto-v4-luis?view=azure-bot-service-4.0&tabs=csharp

Ответы [ 2 ]

0 голосов
/ 14 февраля 2020

Эта проблема решена сейчас. Я могу получить намерение от Луиса. Когда я использовал хост Luis, настроенный в appsettings. json в формате https://xxxx.xxxx.xxxx Я не получал Luis Intent, но после удаления https: // я получил результат сейчас. Спасибо всем за ваши усилия.

0 голосов
/ 12 февраля 2020

Контроллер сообщений V4 редко, если вообще когда-либо, должен меняться со скелета. В этой строке:

await _adapter.ProcessAsync(Request, response, _bot);

... вы можете видеть, что Контроллер передает Request в _bot. Используйте вашего бота для обработки диалога.

В примере CoreBot , вы можете увидеть, что после того, как сообщение достигнет BotController (что эквивалентно MessageController, он идет к DialogBot, где он вызывает диалог:

protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
    Logger.LogInformation("Running dialog with Message Activity.");

    // Run the Dialog with the new message Activity.
    await Dialog.RunAsync(turnContext, ConversationState.CreateProperty<DialogState>("DialogState"), cancellationToken);
}

Он «знает», чтобы сделать это, потому что в Startup.cs, он использует Dependecy Injection, чтобы добавить и бота, и диалог, чтобы BotController и DialogBot могли использовать их соответственно:

services.AddTransient<IBot, DialogAndWelcomeBot<MainDialog>>();

Перед миграцией я настоятельно рекомендую настроить CoreBot и читая его, пока не поймете, как он работает. Это, вероятно, будет полезно для будущих вопросов миграции.

...