【发布时间】:2020-02-11 22:47:43
【问题描述】:
我正在运行 botframework v4 代码并使用 chatbot emulator 对其进行测试。目前我无法访问 luis 意图代码存在于 [MainDialog.cs][1] 中的代码流。
下面是 MainDialog.cs 文件中的一行:
var luisResult = await _luisRecognizer.RecognizeAsync<FlightBooking>(stepContext.Context, cancellationToken);
但是,当我在 ChatBot 中输入一些消息时,每次流程都会在 [FlightBookingRecognizer.cs][2] 处结束,下面是我期望匹配/获取 luis 意图的行。
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 有我们在聊天机器人中输入的消息。 我期待 _recognizer.RecognizeAsync 中的 LUIS 结果,但其中没有相关数据。 我正在尝试执行以下操作:-
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
【问题讨论】:
-
请启用调试并在遇到错误时将其中断。然后,请使用错误以及导致错误的相关代码编辑您的问题。
-
我已经更新了调试期间代码流结束的那些行和 RecognizeAsync api 调用。
-
如果有语法错误,你应该修复它们。就目前而言,我仍然不确定您的实际问题是什么。您需要提供有关错误、发生位置以及您期望发生的情况的更详细信息。
-
@mdrichardson-MSFT 我已经解决了该语法错误,但根据聊天机器人模拟器屏幕截图,源代码中仍然存在异常,并且如重现步骤中所述,FlightBookingRecognizer.cs 类中发生了问题。 _recognizer.RecognizeAsync 应该包含预期的意图匹配或得分,但我无法在该行中看到任何此类值。
标签: c# botframework azure-language-understanding