botbuilder-dotnet: QnAMakerOptions doesn't reset filters values

Version

4.3.2

Describe the bug

We are working with a bot using QnAMaker class from Microsoft.Bot.Builder.AI.QnA StrictFilters from QnAMakerOptions doesn’t work with an empty value after using it with a filter

To Reproduce

Call GetAnswersAsync using an QnAMakerOptions without any StrictFilter

var options1 = new QnAMakerOptions
{
    Top = 10,
    ScoreThreshold = 0.6f,
};
var response = await _services.QnAServices[QnAMakerKey].GetAnswersAsync(turnContext, options1);
if (response != null && response.Length > 0)
{
    await turnContext.SendActivityAsync($"QnA Results: {response.Length}");
}

Now, make another call with a StrictFilter

var options2 = new QnAMakerOptions
{
    Top = 10,
    ScoreThreshold = 0.6f,
    StrictFilters = new Metadata[] { new Metadata() { Name = "Topic", Value = "sharepoint" } },
};
var response2 = await _services.QnAServices[QnAMakerKey].GetAnswersAsync(turnContext, options2);
if (response2 != null && response2.Length > 0)
{
    await turnContext.SendActivityAsync($"QnA Results: {response2.Length}");
}

Repeat the first call without and StrictFilter

var options3 = new QnAMakerOptions
{
    Top = 10,
    ScoreThreshold = 0.6f,
};
var response3 = await _services.QnAServices[QnAMakerKey].GetAnswersAsync(turnContext, options3);
if (response3 != null && response3.Length > 0)
{
    await turnContext.SendActivityAsync($"QnA Results: {response3.Length}");
}

Expected behavior

From the third call, I expected to have the same results we had on the first one, but for any reason the StrictFilters didn’t reset its values well.

Screenshots

image

[bug]

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

The PR for this has been merged. The fix will start showing up on our daily build server tonight, and be shipped in the 4.5 cycle currently planned around July 15.

Ok, had time to get a repro properly this time. image ^ last one should be 4

Still unsure how I wasn’t able to repro it properly last time… But regardless, should have a fix sometime before EoD 😃

Also, this is really an issue since it is not possible to reset the StrictFilters property to become empty.

Since HydrateOptions checks whether StrictFilters?.Length > 0, you cannot pass an empty array to make it empty.

The only workaround I see is by throwing away the old instance of QnaMaker and generate a new QnaMaker object instance.

Chris has already closed the issue, but I did get confirmation from the QnA team that I wanted to put out here. There was in fact a bug introduced in their latest roll out, causing an issue with strictfilters. They fixed the bug on 4/19. They say to

“please try now. You don’t need to restart your app service to get the fix. It was automatically rolled out to all services”