LUIS中用于多轮对话的新意图 [英] New intent in LUIS for multi turn dialogs
问题描述
我要创建一个多转对话框.我不知道如何将它与LUIS模型联系起来.我签出了文档,但是有些示例只有一个转弯对话框.另外,我使用Virtual Assistant模板. 我想做这样的事情.
I am going to create a multi-turn dialog. I didn't get how it should be connected with LUIS models. I checked out documentation, but there are samples with only one turn dialogs. Also, I use Virtual Assistant template. I want to do something like this.
用户:我要预订航班
User: I want to book a flight
Bot:目的地是什么?
Bot: What is the destination?
用户:伦敦
Bot:什么时候?
用户:9月21日.
Bot:机票已购买.
Bot: The ticket was bought.
问题是第二步会发生什么?我应该检查调度员吗?我应该为意图内的所有步骤添加所有可能的短语吗?
The questions are what happens on the second step? Should I check out dispatcher? Should I add all possible phrases for all steps inside the intent?
推荐答案
LUIS常规内容
对于您的LUIS模型,您将需要您的意图-BookFlight
和None
.在BookFlight
意图下,您将拥有Utterances
-您希望能够触发BookFlight
意图的所有短语.
For your LUIS model you will need your intents - BookFlight
and None
. Under your BookFlight
intent you will have your Utterances
- all the phrases you want to be able to trigger the BookFlight
intent.
MyLuisApp
--BookFlight
----I want to book a flight
----Book a flight
----I need a plane ticket
----etc
--None
----Utterances that don't match any of your intents
按照此文档.
将此功能添加到新的漫游器或核心漫游器模板
提供了几个有关如何实现此目标的示例,但是最好的方法是使用对话框.您想要的是
There are a couple different samples provided on how you could achieve this, but the best way is using Dialogs. What you want is a Waterfall Dialog. Inside this Dialog you can define each stage in the waterfall e.g. Ask for destination, ask for date etc.
为了触发BookFlight瀑布,您需要一个MainDialog来处理每个请求,并与LUIS调度程序进行检查 link2 来根据
In order to trigger the BookFlight waterfall you would have a MainDialog that handled every request, and checks with the LUIS dispatcher link1 and link2 to find out the users intent as per this example. If the intent is BookFlight
then you would start the BookFlightDialog which contains the book flight waterfall.
...
// Check dispatch result
var dispatchResult = await cognitiveModels.DispatchService.RecognizeAsync<DispatchLuis>(dc.Context, CancellationToken.None);
var intent = dispatchResult.TopIntent().intent;
if (intent == "BookFlight")
{
// Start BookFlightDialog
await dc.BeginDialogAsync(nameof(BookFlightDialog));
}
常规瀑布对话框的内容
您将步骤定义为:
var waterfallSteps = new WaterfallStep[]
{
AskDestinationAsync,
AskDepartureDateAsync,
ConfirmStepAsync,
FinishDialogAsync,
};
对于您的方案,实际上已经使用BookFlight意图创建了一个示例,官方文档.因此,您可以进行测试以查看一切工作原理,然后根据需要对其进行修改.
For your scenario there is actually a sample that has already been created with the BookFlight intent available here. There is a full guide on how to get this setup and working in the official documentation. So you can test to see how everything works then modify it as you need.
其他有趣的链接:
- 多回合样本-瀑布对话框.
- Custom prompt sample - roll your own.
- Multi-turn sample - waterfall dialog.
虚拟助手的东西
一旦了解了上述工作原理,您将可以通过执行以下操作来修改Virtual Assistant模板以处理BookFlight意图:
Once you understand how the above works you will be able to modify the Virtual Assistant template to handle the BookFlight intent by taking the following actions:
- 向连接到VA模板的现有LUIS DISPATCH 应用添加BookFlight意图.
- 为BookFlight意图添加语音.
- 保存并培训您的LUIS应用.
- 发布您的LUIS应用.
- 按照说明运行PowerShell Core 并从项目目录的根目录开始,即在Virtual Assistant文件夹中.
- Adding a BookFlight intent to your existing LUIS DISPATCH app that is connected to your VA template.
- Adding utterances to the BookFlight intent.
- Save and train your LUIS app.
- Publish your LUIS app.
- Running the update_cognitive_models.ps1 script as per step 3 of the instructions here which will pull down the changes (your new intent and utterances).
.\Deployment\Scripts\update_cognitive_models.ps1 -RemoteToLocal
- NOTE: This command must be run using PowerShell Core and from the root of your project Directory, i.e. inside your Virtual Assistant folder.
运行此脚本的结果应该是在本地创建的一堆文件,以及正在更新的
DispatchLuis.cs
文件以包括您的新意图.您还应该检查创建的Summary.html
文件,以查看是否有新的意图.现在,您将必须更新VA代码以在触发新的意图时实际执行某些操作-在MainDialog.cs
文件的RouteAsync
方法内添加另一个if/case语句-请参见The result of running this script should be a bunch of files created locally, as well as the
DispatchLuis.cs
file being updated to include your new intent. You should also check theSummary.html
file that is created to see that your new intent is there. You will now have to update the VA code to actually do something when your new intent is triggered - add another if/case statement inside theRouteAsync
method of theMainDialog.cs
file - see here for an example.类似这样的东西:
MainDialog.cs protected override async Task RouteAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken)) { // Call to dispatch to get intent if (intent == DispatchLuis.Intent.bookflight) { // Start BookFlightDialog await dc.BeginDialogAsync(nameof(BookFlightDialog)); } ... }
这篇关于LUIS中用于多轮对话的新意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!