Reputation: 77
I'm having a LUIS model where i'm trying to enumerate my entities using the following code.
I'm getting the below error while executing the second line.
"The given key 'luisResult' was not present in the dictionary"
Has LUIS implementation changed recently? What are the alternate ways to enumerate all entities in LUIS?
var result = await _botServices.Dispatch.RecognizeAsync(stepContext.Context, cancellationToken);
var luisResult = result.Properties["luisResult"] as LuisResult;
var entities = luisResult.Entities;
foreach (var entity in entities)
{
if (Common.BugTypes.Any(s => s.Equals(entity.Entity,
StringComparison.OrdinalIgnoreCase)))
{
await stepContext.Context.SendActivityAsync(
MessageFactory.Text(String.Format("Yes! {0} is a Bug Type!",
entity.Entity)), cancellationToken);
}
else
{
await stepContext.Context.SendActivityAsync(
MessageFactory.Text(String.Format("No! {0} is not a Bug Type!", entity.Entity)), cancellationToken);
}
}
return await stepContext.NextAsync(null, cancellationToken);
Upvotes: 1
Views: 72
Reputation: 77
I kind of fixed this. There were two issues.
When I was building my recognizer options, I failed to mention the parameter "IncludeAPIResults = true"
However it still didn't work and luisResult was always returning null when using LuisRecognizerOptionsV3. I finally resorted to using LuisRecognizerOptionsV2 which worked. I'll probably file a bug regarding this.
Upvotes: 1
Reputation: 2728
How about if you change
var luisResult = result.Properties["luisResult"] as LuisResult;
to
var luisResult = result;
then access the Entities
property of the RecognizerResult class.
You could even forgo creating the luisResult
variable and just use result.Entities
.
Upvotes: 0