Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow LuisRecognizer to handle textless messages #1566

Merged
merged 2 commits into from
Apr 3, 2019

Conversation

v-kydela
Copy link
Contributor

Fixes #1349

With this change, LuisRecognizer.RecognizeAsync will no longer throw an exception when the turn context's activity has no text. Instead it will bypass the LUIS endpoint (saving the expense of an API call) and create a fake RecognizerResult with a string.Empty intent. This will allow bots to handle textless messages gracefully when they're not designed to explicitly check if the text is null or empty before calling RecognizeAsync. If the bot has a switch statement with a default clause then that will be triggered, probably responding the same as a None intent. Otherwise, nothing will happen.

@coveralls
Copy link
Collaborator

coveralls commented Mar 27, 2019

Pull Request Test Coverage Report for Build 52947

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 9 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.09%) to 76.076%

Files with Coverage Reduction New Missed Lines %
/libraries/Microsoft.Bot.Builder.AI.LUIS/LuisRecognizer.cs 9 79.49%
Totals Coverage Status
Change from base Build 52422: 0.09%
Covered Lines: 4350
Relevant Lines: 5718

💛 - Coveralls

@cleemullins
Copy link
Contributor

Please include a note regarding the JS behavior. We need to keep the two aligned.

@v-kydela
Copy link
Contributor Author

v-kydela commented Apr 2, 2019

While the Node SDK does not have this bug, it does behave slightly differently compared to this PR. In Node, the empty utterance is sent to the LUIS endpoint, resulting in a needless endpoint call. Then the returned value is different in that there are no intents in Node, whereas this PR creates a fake intent like V3 did. It's uncertain whether these differences warrant changing the behavior of the Node SDK.

In luisRecognizer.test.js there was already a test that accounts for empty utterances, which confirms the need for this .NET PR since in Node an empty utterance produced no error.

I will amend this PR with your requested change ASAP.

@v-kydela
Copy link
Contributor Author

v-kydela commented Apr 2, 2019

Curiously, the test I referred to in luisRecognizer.test.js reflects inaccurate behavior. The LUIS recognizer tests in both SDK's work using a mock HTTP client and so they're not actually calling any real LUIS endpoint. The tests just load files with fake LUIS results that are already built into the projects and then test to see if those fake results are what they've already been made to be. So even though the test says an empty utterance should return a None intent, that's not what really happens when an actual endpoint is used.

@cahann cahann requested a review from chrimc62 April 2, 2019 21:15
@cleemullins
Copy link
Contributor

No issues found in Microsoft.Bot.Builder.dll
No issues found in Microsoft.Bot.Builder.AI.Luis.dll
No issues found in Microsoft.Bot.Builder.AI.QnA.dll
No issues found in Microsoft.Bot.Builder.ApplicationInsights.dll
No issues found in Microsoft.Bot.Builder.Azure.dll
No issues found in Microsoft.Bot.Builder.Dialogs.dll
No issues found in Microsoft.Bot.Builder.TemplateManager.dll
No issues found in Microsoft.Bot.Configuration.dll
Compat issues with assembly Microsoft.Bot.Connector:
MembersMustExist : Member 'System.String Microsoft.Bot.Connector.Authentication.AuthenticationConstants.ToChannelFromBotLoginUrl' does not exist in the implementation but it does exist in the contract.

No issues found in Microsoft.Bot.Schema.dll

@v-kydela
Copy link
Contributor Author

v-kydela commented Apr 2, 2019

@cleemullins - You can see in my commits that I've made no changes to the Microsoft.Bot.Connector project. I just had a look in the master branch and it looks like ToChannelFromBotLoginUrl was changed to ToChannelFromBotLoginUrlTemplate in the latest commit. I presume the discrepancy you're seeing would be fixed upon merge.

Copy link
Contributor

@chrimc62 chrimc62 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good solution to this issue.

@v-kydela v-kydela requested a review from chrimc62 April 3, 2019 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants