问题描述
我正在尝试在瀑布对话框步骤中呼叫 QnA Maker .
如何在此 watterfall
步骤中调用它,我是否需要设置QnA?在瀑布步骤中,我是否需要从中调用 QnA ?LUIS意图,我该怎么办?
How do I call it from this watterfall
step, do I need to set up QnA On the waterfall step, do I need to call QnA from a LUIS intent, what can I do?
我需要它使用上一个问题的步骤上下文从QnA中获得第一个结果.
I need it to get the first result from the QnA using the step context from the previous question.
任何人都可以帮忙吗?
代码:
private async Task<DialogTurnResult> QnaAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
var response = await qnaMaker.GetAnswersAsync(stepContext);
// use answer found in qnaResults[0].answer
return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text(response[0].Answer)}, cancellationToken);
}
推荐答案
似乎您的上面的代码中没有定义 qnaMaker
.只要您在某处定义了QnAMaker服务,您就可以真正从任何地方调用QnAMaker.
It looks like you don't have qnaMaker
defined in your code above, there. You can really call QnAMaker from anywhere, so long as you have a QnAMaker service defined somewhere.
我建议遵循此示例.它相当复杂,但却是在瀑布对话框中使用QnAMaker的最佳示例.
I recommend following this sample. It's fairly complex, but is the best example of using QnAMaker within a Waterfall Dialog.
我将指出一些您会发现最有用的部分:
I'll point out some pieces that you will find most useful:
- Create the QnAMaker service
- Use dependency injection so that you can access the BotServices from anywhere in the project
- Add the services to the dialog's constructor
- Call the QnAMaker service
同样,该样本相当复杂.如果您需要其他指针,请使用您尝试的代码更新您的问题,我会帮助您.
Again, that sample is fairly complex. If you need additional pointers, please update your question with the code that you've tried and I'll see if I can help.
这篇关于如何使用C#在瀑布对话框上调用QnA Maker?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!