Microsoft.Bot.Builder.CognitiveServices.QnAMaker.QnAMakerDialog如何覆盖未找到的内容? [英] Microsoft.Bot.Builder.CognitiveServices.QnAMaker.QnAMakerDialog How to override not found?
问题描述
我正在使用QnAMakerDialog
,无法弄清楚如何覆盖未找到".我可以覆盖RespondFromQnAMakerResultAsync
,但是找不到答案时不会调用它.我尝试将默认消息设置为null或空字符串,但是QnAMakerDialog
会自动响应找不到匹配项!"当找不到匹配项时!
I'm working with QnAMakerDialog
and cannot figure out how to override the "not found". I am able to override RespondFromQnAMakerResultAsync
but that is not called when no answer is found. I tried setting the default message to null or empty string but then QnAMakerDialog
automatically response "No match found!" when it doesn't find a match!
当找不到匹配项时,我不需要消息,因为我只是将消息转发到LuisDialog
.我如何停止此消息!!!
I don't want a message when no match is found because I'm just forwarding the message to a LuisDialog
. How do I stop this message!!!
侧面说明:我知道有些Gary家伙使用的QnAMakerDialog
版本与此不同,但是我真的想只使用Microsoft的标准版本.这可能吗?
Side note: I understand that some Gary guy has a different version of a QnAMakerDialog
that does this but I'd really like to just use the standard one from Microsoft. Is this possible?
推荐答案
那个加里的家伙"是加里·普莱特(Gary Pretty).他在QnAMaker
上做得很好,尤其是几天前,他通过一个软件包提供了对QnAMaker API v3的访问,与QnAMakerDialog
相比,该软件包提供了许多新功能.
That "Gary guy" is Gary Pretty. He made a nice job on QnAMaker
, especially a few days ago by providing access to QnAMaker API v3 through a package, which provides a lot of new features compared to QnAMakerDialog
.
对于每个遇到您的问题并寻求类似答案的用户,您都应该对他的包裹进行一下检查:
For every user coming to your question and looking for a similar answer, you should definitely have a look to his package:
-
它是开源的!因此,在 GitHub
在Nuget上此处
使用他的软件包,您可以直接覆盖NoMatchHandler
并已完成.
With his package, you can directly override NoMatchHandler
and you're done.
对于那些不愿使用第三方程序包的人,即使您有代码,官方" QnAMakerDialog
也来自Microsoft.Bot.Builder.CognitiveServices
程序包,该程序包的来源也...
For those who are reluctant to use a third-party package, even if you have the code, the "official" QnAMakerDialog
comes from Microsoft.Bot.Builder.CognitiveServices
package, which sources are... also on GitHub.
因此,如果您查看QnAMakerDialog.cs
,您将看到所需的所有内容都在MessageReceivedAsync
方法内部,尤其是消息是通过此
So if you look in QnAMakerDialog.cs
you will see that everything you need is inside MessageReceivedAsync
method, in particular the message is sent by this line:
await context.PostAsync(qnaMakerResults.ServiceCfg.DefaultMessage);
您还可以看到:
-
MessageReceivedAsync
不能轻松覆盖
即使您用new
隐藏该方法并复制粘贴除行之外的所有方法,您也会遇到某些内部属性,例如serviceCfg
,因此无法在您自己的命名空间中使用
even if you hide this method with new
and copy paste all the method except the line, you will have problems with some properties like serviceCfg
that are internal so can't be used in your own namespace
所以最后一个选择是从Microsoft Github的项目中复制所有QnA类,只是要删除此行...
So the last option will be to copy all the QnA classes from Microsoft Github's project just to remove this line...
您可以在 https://github.com/Microsoft/BotBuilder-CognitiveServices,围绕此问题有几个待解决的问题:
As you can see on https://github.com/Microsoft/BotBuilder-CognitiveServices, there are several issues pending around this problem:
- https://github.com/Microsoft/BotBuilder-CognitiveServices/issues/50
- https://github.com/Microsoft/BotBuilder-CognitiveServices/issues/58
- https://github.com/Microsoft/BotBuilder-CognitiveServices/issues/75
- https://github.com/Microsoft/BotBuilder-CognitiveServices/issues/50
- https://github.com/Microsoft/BotBuilder-CognitiveServices/issues/58
- https://github.com/Microsoft/BotBuilder-CognitiveServices/issues/75
我希望很快会在软件包中进行集成,因为围绕它提供了几个Pull Request
I hope there will be an integration in the package soon, as several Pull Request have been provided around that
这篇关于Microsoft.Bot.Builder.CognitiveServices.QnAMaker.QnAMakerDialog如何覆盖未找到的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!